Consider having a global variable 'a' and a static variable with the same name inside a class. This resolves the arbitrary choice when resolving the name 'a'.
Details
Diff Detail
Event Timeline
See inlined comments.
source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | ||
---|---|---|
7389 | I would do this as: const DWARFDebugInfoEntry *parent_die = GetDeclContextDIEContainingDIE(dwarf_cu, die); if (parent_die->Tag() != DW_TAG_class_type && parent_die->Tag() != DW_TAG_structure_type) { VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, LLDB_INVALID_ADDRESS)); if (var_sp) { variables->AddVariableIfUnique (var_sp); ++vars_added; } This will avoid parsing extra global variables by figuring out we don't need it _before_ we go and parse a global variable. I would rather not have the SymbolFileDWARF::ParseGlobalVariableDIE(...) function because it doesn't make sense at as global variables can exist in classes and structures and I would expect a function named SymbolFileDWARF::ParseGlobalVariableDIE(...) to parse that variable, but SymbolFileDWARF:: ParseVariableDIE(...) already does this so there is really no need for SymbolFileDWARF::ParseGlobalVariableDIE(). | |
7413–7437 | Remove this. See inlined comment above. | |
source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | ||
325–330 | Remove this. |
Please make sure that the following works after your changes:
(lldb) r Process 35421 launched: '/private/tmp/a.out' (x86_64) Process 35421 stopped * thread #1: tid = 0xb659be, 0x0000000100000f9d a.out main + 13, stop reason = breakpoint 1.1, queue = com.apple.main-thread frame #0: 0x0000000100000f9d a.out main + 13 at main.cpp:24 21 22 int main() 23 { -> 24 return 0; // break here 25 } (lldb) target variable Global variables for /tmp/main.cpp in /private/tmp/a.out: (int) A::a = 1111 (int) B::a = 2222 (int) C::a = 3333 (int) ::a = 4444
I've changed the commit so that ParseVariableDIE now detects if a variable is static inside a class or struct. Now "target variable" works since the variables are not removed from the variable list of the compile unit, but filtered when searching for a specific variable.
Remove this.