clayborg added a comment.
So looks like this function needs to be fixed:
llvm::Optional<DIERef> DWARFBaseDIE::GetDIERef() const {
if (!IsValid())
return llvm::None;
return DIERef(m_cu->GetSymbolFileDWARF().GetDwoNum(),
m_cu->GetDebugSection(),
m_die->GetOffset());
}
This currently only works for DWO files, but not for OSO files. If we make the
DIERef constructor that this function uses "protected", then only this function
can use it. And it should be able to do things correctly.
If we switched the DIERef constructor to take a SymbolFileDWARF as a mandatory
first arg, then we can manually supply the section + offset, then DWARFBaseDie
can always do this correctly for both DWO files and OSO files.
We might need to add an accessor to SymbolFileDWARF like:
virtual uint32_t SymbolFileDWARF::GetFileIndex();
And there can be a setter for this as well. Then the OSO stuff would set the
file index to a 1 based index, and the DWO files would also set this as the
file index in the SymoblFileDWARF base class and then this all works.
So my suggestion would be:
- make only one DIERef constructor: "DIERef(SymbolFileDWARF *dwarf, Section
section, dw_offset_t die_offset)"
- add SymbolFileDWARF::GetFileIndex() and SymbolFileDWARF::SetFileIndex(...)
and a backing ivar
- OSO and DWO files will set the file index manually early on so it is always
available and can always create valid DIERef objects in DWARFBaseDIE::GetDIERef
- Change DWARFBaseDIE::GetDIERef to use the GetFileIndex() where it expects
zero for a non DWO or OSO file and a 1 based index for DWO or OSO stuff
- Don't allow anyone else to create manually DIERef objects unless you ask for
it from a DWARFBaseDie except for the encode/decode functions for saving
to/from cache
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138618/new/
https://reviews.llvm.org/D138618
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits