-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[lldb] Index static const members of classes, structs and unions as global variables in DWARF 4 and earlier #111859
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
Changes from all commits
4c394ec
8f7c944
e34cd8f
86390ef
dd67524
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 | ||||
---|---|---|---|---|---|---|
|
@@ -222,6 +222,13 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit, | |||||
case DW_TAG_variable: | ||||||
break; | ||||||
|
||||||
case DW_TAG_member: | ||||||
// Only in DWARF 4 and earlier `static const` members of a struct, a class | ||||||
// or a union have an entry tag `DW_TAG_member` | ||||||
if (unit.GetVersion() >= 5) | ||||||
continue; | ||||||
break; | ||||||
|
||||||
default: | ||||||
continue; | ||||||
} | ||||||
|
@@ -362,6 +369,18 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit, | |||||
set.namespaces.Insert(ConstString(name), ref); | ||||||
break; | ||||||
|
||||||
case DW_TAG_member: { | ||||||
// In DWARF 4 and earlier `static const` members of a struct, a class or a | ||||||
// union have an entry tag `DW_TAG_member`, and are also tagged as | ||||||
// `DW_AT_declaration`, but otherwise follow the same rules as | ||||||
// `DW_TAG_variable`. | ||||||
bool parent_is_class_type = false; | ||||||
if (auto parent = die.GetParent()) | ||||||
parent_is_class_type = DWARFDIE(&unit, parent).IsStructUnionOrClass(); | ||||||
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. Can this just be:
Suggested change
? 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. No, because It's a (not entirely fortunate) result of trying to avoid any high level (expensive) operations, and of the fact that lldb's DWARFDebugInfoEntry (unlike the llvm) fork actually provides some functionality instead of being a simple data holder. 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. Ah right, yea that's unfortunate |
||||||
if (!parent_is_class_type || !is_declaration) | ||||||
break; | ||||||
[[fallthrough]]; | ||||||
} | ||||||
case DW_TAG_variable: | ||||||
if (name && has_location_or_const_value && is_global_or_static_variable) { | ||||||
set.globals.Insert(ConstString(name), ref); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2402,7 +2402,7 @@ void SymbolFileDWARF::FindGlobalVariables( | |
sc.module_sp = m_objfile_sp->GetModule(); | ||
assert(sc.module_sp); | ||
|
||
if (die.Tag() != DW_TAG_variable) | ||
if (die.Tag() != DW_TAG_variable && die.Tag() != DW_TAG_member) | ||
return true; | ||
|
||
auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU()); | ||
|
@@ -3490,7 +3490,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, | |
ModuleSP module = GetObjectFile()->GetModule(); | ||
|
||
if (tag != DW_TAG_variable && tag != DW_TAG_constant && | ||
(tag != DW_TAG_formal_parameter || !sc.function)) | ||
tag != DW_TAG_member && (tag != DW_TAG_formal_parameter || !sc.function)) | ||
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. Should we bail out (or at least assert) if we detect a 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. Added an assert, but maybe I should just add that as a condition for detecting a 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 don't think that should be an assert unless some piece of code (where?) alredy makes sure that these kinds of DIEs don't make their way here. Debug info can come from all kinds of compilers (including those from the past and the future), so we shouldn't be crashing just because we've ran into debug info (aka "user input") that we don't understand. Logging something or reporting a warning might be more appropriate. Checking for this member when detecting a static const member might be okay, but it doesn't really count as the check I mention above, since it only works for the manual index. The other indexes come straight from the compiler (past, future, etc.) so they can't be relied upon in the same way. For this reason (and because we want to make the indexing step as fast as possible), I'd put the check into the indexing step only if it's necessary to properly detect static members. |
||
return nullptr; | ||
|
||
DWARFAttributes attributes = die.GetAttributes(); | ||
|
@@ -3796,7 +3796,7 @@ void SymbolFileDWARF::ParseAndAppendGlobalVariable( | |
return; | ||
|
||
dw_tag_t tag = die.Tag(); | ||
if (tag != DW_TAG_variable && tag != DW_TAG_constant) | ||
if (tag != DW_TAG_variable && tag != DW_TAG_constant && tag != DW_TAG_member) | ||
return; | ||
|
||
// Check to see if we have already parsed this variable or constant? | ||
|
Uh oh!
There was an error while loading. Please reload this page.