-
Notifications
You must be signed in to change notification settings - Fork 18.4k
[CodeView] Read and dump LF_ALIAS #218243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPETYPEDEFALIAS_H | ||
| #define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPETYPEDEFALIAS_H | ||
|
|
||
| #include "llvm/DebugInfo/CodeView/TypeRecord.h" | ||
| #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" | ||
| #include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" | ||
| #include "llvm/DebugInfo/PDB/PDBTypes.h" | ||
|
|
||
| namespace llvm { | ||
|
|
||
| class raw_ostream; | ||
|
|
||
| namespace pdb { | ||
|
|
||
| class NativeSession; | ||
|
|
||
| /// A typedef from the TPI stream (LF_ALIAS). | ||
| class LLVM_ABI NativeTypeTypedefAlias : public NativeRawSymbol { | ||
| public: | ||
| NativeTypeTypedefAlias(NativeSession &Session, SymIndexId Id, | ||
| codeview::TypeIndex TI, codeview::AliasRecord Typedef); | ||
|
|
||
| NativeTypeTypedefAlias(NativeSession &Session, SymIndexId Id, | ||
| NativeTypeTypedefAlias &UnmodifiedType, | ||
| codeview::ModifierRecord Modifier); | ||
|
|
||
| ~NativeTypeTypedefAlias() override; | ||
|
|
||
| void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, | ||
| PdbSymbolIdField RecurseIdFields) const override; | ||
|
|
||
| std::string getName() const override; | ||
| SymIndexId getTypeId() const override; | ||
|
|
||
| SymIndexId getUnmodifiedTypeId() const override; | ||
| bool isConstType() const override; | ||
| bool isUnalignedType() const override; | ||
| bool isVolatileType() const override; | ||
|
|
||
| protected: | ||
| codeview::AliasRecord Record; | ||
| NativeTypeTypedefAlias *UnmodifiedType = nullptr; | ||
| std::optional<codeview::ModifierRecord> Modifiers; | ||
| }; | ||
|
|
||
| } // namespace pdb | ||
| } // namespace llvm | ||
|
|
||
| #endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPETYPEDEFALIAS_H |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "llvm/DebugInfo/PDB/Native/NativeTypeTypedefAlias.h" | ||
| #include "llvm/DebugInfo/PDB/Native/NativeSession.h" | ||
| #include "llvm/DebugInfo/PDB/PDBExtras.h" | ||
|
|
||
| using namespace llvm; | ||
| using namespace llvm::codeview; | ||
| using namespace llvm::pdb; | ||
|
|
||
| NativeTypeTypedefAlias::NativeTypeTypedefAlias(NativeSession &Session, | ||
| SymIndexId Id, | ||
| TypeIndex /* TI */, | ||
| codeview::AliasRecord Typedef) | ||
| : NativeRawSymbol(Session, PDB_SymType::Typedef, Id), | ||
| Record(std::move(Typedef)) {} | ||
|
|
||
| NativeTypeTypedefAlias::NativeTypeTypedefAlias( | ||
| NativeSession &Session, SymIndexId Id, | ||
| NativeTypeTypedefAlias &UnmodifiedType, codeview::ModifierRecord Modifier) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused - where does this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like dead functionality, perhaps exercised by the original PR. I would leave it out of scope if you don't need it for the core parsing / dumping code.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't dead - it's used in |
||
| : NativeRawSymbol(Session, PDB_SymType::Typedef, Id), | ||
| UnmodifiedType(&UnmodifiedType), Modifiers(Modifier) {} | ||
|
|
||
| NativeTypeTypedefAlias::~NativeTypeTypedefAlias() = default; | ||
|
|
||
| void NativeTypeTypedefAlias::dump(raw_ostream &OS, int Indent, | ||
| PdbSymbolIdField ShowIdFields, | ||
| PdbSymbolIdField RecurseIdFields) const { | ||
| NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields); | ||
| dumpSymbolField(OS, "name", getName(), Indent); | ||
| dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session, | ||
| PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields); | ||
| dumpSymbolField(OS, "constType", isConstType(), Indent); | ||
| dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent); | ||
| dumpSymbolField(OS, "volatileType", isVolatileType(), Indent); | ||
| } | ||
|
|
||
| std::string NativeTypeTypedefAlias::getName() const { | ||
| if (UnmodifiedType) | ||
| return UnmodifiedType->getName(); | ||
| return std::string(Record.Name); | ||
| } | ||
|
|
||
| SymIndexId NativeTypeTypedefAlias::getTypeId() const { | ||
| if (UnmodifiedType) | ||
| return UnmodifiedType->getTypeId(); | ||
|
|
||
| return Session.getSymbolCache().findSymbolByTypeIndex(Record.UnderlyingType); | ||
| } | ||
|
|
||
| SymIndexId NativeTypeTypedefAlias::getUnmodifiedTypeId() const { | ||
| if (UnmodifiedType) | ||
| return UnmodifiedType->getSymIndexId(); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| bool NativeTypeTypedefAlias::isConstType() const { | ||
| if (!Modifiers) | ||
| return false; | ||
| return (Modifiers->Modifiers & ModifierOptions::Const) != | ||
| ModifierOptions::None; | ||
| } | ||
|
|
||
| bool NativeTypeTypedefAlias::isUnalignedType() const { | ||
| if (!Modifiers) | ||
| return false; | ||
| return (Modifiers->Modifiers & ModifierOptions::Unaligned) != | ||
| ModifierOptions::None; | ||
| } | ||
|
|
||
| bool NativeTypeTypedefAlias::isVolatileType() const { | ||
| if (!Modifiers) | ||
| return false; | ||
| return (Modifiers->Modifiers & ModifierOptions::Volatile) != | ||
| ModifierOptions::None; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "llvm/DebugInfo/PDB/Native/NativeTypeTypedefUDT.h" | ||
| #include "llvm/DebugInfo/PDB/Native/NativeSession.h" | ||
| #include "llvm/DebugInfo/PDB/PDBExtras.h" | ||
|
|
||
| using namespace llvm; | ||
| using namespace llvm::codeview; | ||
| using namespace llvm::pdb; | ||
|
|
||
| NativeTypeTypedefUDT::NativeTypeTypedefUDT(NativeSession &Session, | ||
| SymIndexId Id, | ||
| codeview::UDTSym Typedef) | ||
| : NativeRawSymbol(Session, PDB_SymType::Typedef, Id), | ||
| Record(std::move(Typedef)) {} | ||
|
|
||
| NativeTypeTypedefUDT::~NativeTypeTypedefUDT() = default; | ||
|
|
||
| void NativeTypeTypedefUDT::dump(raw_ostream &OS, int Indent, | ||
| PdbSymbolIdField ShowIdFields, | ||
| PdbSymbolIdField RecurseIdFields) const { | ||
| NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields); | ||
| dumpSymbolField(OS, "name", getName(), Indent); | ||
| dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session, | ||
| PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields); | ||
| } | ||
|
|
||
| std::string NativeTypeTypedefUDT::getName() const { | ||
| return std::string(Record.Name); | ||
| } | ||
|
|
||
| SymIndexId NativeTypeTypedefUDT::getTypeId() const { | ||
| return Session.getSymbolCache().findSymbolByTypeIndex(Record.Type); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any change to
getSizeInBytesForTypeRecord- I don't think the default case is correct though, should we be forwarding the size of the underlying type?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - it returns (essentially) garbage for non-aggregates, the comment above says that
I don't see
LF_ALIASas an aggregate. And given the function signature, it shouldn't read in the TPI stream. In my opinion, it should return an optional and only return the size in the documented cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm that also seems wrong - it should handle modifiers too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #218715 for this.