Author: gclayton Date: Mon Apr 25 18:39:19 2016 New Revision: 267494 URL: http://llvm.org/viewvc/llvm-project?rev=267494&view=rev Log: Make sure that the following SymbolFileDWARF functions can handle getting a lldb::user_id_t for another SymbolFileDWARF:
CompilerDecl SymbolFileDWARF::GetDeclForUID (lldb::user_id_t type_uid); CompilerDeclContext SymbolFileDWARF::GetDeclContextForUID (lldb::user_id_t type_uid) CompilerDeclContext SymbolFileDWARF::GetDeclContextContainingUID (lldb::user_id_t type_uid) Type* SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid) <rdar://problem/25592223> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=267494&r1=267493&r2=267494&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Apr 25 18:39:19 2016 @@ -1459,10 +1459,45 @@ SymbolFileDWARF::ParseDeclsForContext (C ast_parser->GetDeclForUIDFromDWARF(decl); } +SymbolFileDWARF * +SymbolFileDWARF::GetDWARFForUID (lldb::user_id_t uid) +{ + // Anytime we get a "lldb::user_id_t" from an lldb_private::SymbolFile API + // we must make sure we use the correct DWARF file when resolving things. + // On MacOSX, when using SymbolFileDWARFDebugMap, we will use multiple + // SymbolFileDWARF classes, one for each .o file. We can often end up + // with references to other DWARF objects and we must be ready to receive + // a "lldb::user_id_t" that specifies a DIE from another SymbolFileDWARF + // instance. + SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile(); + if (debug_map) + return debug_map->GetSymbolFileByOSOIndex(debug_map->GetOSOIndexFromUserID(uid)); + return this; +} + +DWARFDIE +SymbolFileDWARF::GetDIEFromUID (lldb::user_id_t uid) +{ + // Anytime we get a "lldb::user_id_t" from an lldb_private::SymbolFile API + // we must make sure we use the correct DWARF file when resolving things. + // On MacOSX, when using SymbolFileDWARFDebugMap, we will use multiple + // SymbolFileDWARF classes, one for each .o file. We can often end up + // with references to other DWARF objects and we must be ready to receive + // a "lldb::user_id_t" that specifies a DIE from another SymbolFileDWARF + // instance. + SymbolFileDWARF *dwarf = GetDWARFForUID(uid); + if (dwarf) + return dwarf->GetDIE(DIERef(uid, dwarf)); + return DWARFDIE(); +} + CompilerDecl SymbolFileDWARF::GetDeclForUID (lldb::user_id_t type_uid) { - DWARFDIE die = GetDIE(DIERef(type_uid, this)); + // Anytime we have a lldb::user_id_t, we must get the DIE by + // calling SymbolFileDWARF::GetDIEFromUID(). See comments inside + // the SymbolFileDWARF::GetDIEFromUID() for details. + DWARFDIE die = GetDIEFromUID(type_uid); if (die) return die.GetDecl(); return CompilerDecl(); @@ -1471,7 +1506,10 @@ SymbolFileDWARF::GetDeclForUID (lldb::us CompilerDeclContext SymbolFileDWARF::GetDeclContextForUID (lldb::user_id_t type_uid) { - DWARFDIE die = GetDIE(DIERef(type_uid, this)); + // Anytime we have a lldb::user_id_t, we must get the DIE by + // calling SymbolFileDWARF::GetDIEFromUID(). See comments inside + // the SymbolFileDWARF::GetDIEFromUID() for details. + DWARFDIE die = GetDIEFromUID(type_uid); if (die) return die.GetDeclContext(); return CompilerDeclContext(); @@ -1480,7 +1518,10 @@ SymbolFileDWARF::GetDeclContextForUID (l CompilerDeclContext SymbolFileDWARF::GetDeclContextContainingUID (lldb::user_id_t type_uid) { - DWARFDIE die = GetDIE (DIERef(type_uid, this)); + // Anytime we have a lldb::user_id_t, we must get the DIE by + // calling SymbolFileDWARF::GetDIEFromUID(). See comments inside + // the SymbolFileDWARF::GetDIEFromUID() for details. + DWARFDIE die = GetDIEFromUID(type_uid); if (die) return die.GetContainingDeclContext(); return CompilerDeclContext(); @@ -1490,13 +1531,14 @@ SymbolFileDWARF::GetDeclContextContainin Type* SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid) { - DWARFDIE type_die = GetDIE (DIERef(type_uid, this)); + // Anytime we have a lldb::user_id_t, we must get the DIE by + // calling SymbolFileDWARF::GetDIEFromUID(). See comments inside + // the SymbolFileDWARF::GetDIEFromUID() for details. + DWARFDIE type_die = GetDIEFromUID(type_uid); if (type_die) - { - const bool assert_not_being_parsed = true; - return ResolveTypeUID (type_die, assert_not_being_parsed); - } - return NULL; + return type_die.ResolveType(); + else + return nullptr; } Type* Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=267494&r1=267493&r2=267494&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Mon Apr 25 18:39:19 2016 @@ -160,6 +160,12 @@ public: bool assert_not_being_parsed = true, bool resolve_function_context = false); + SymbolFileDWARF * + GetDWARFForUID (lldb::user_id_t uid); + + DWARFDIE + GetDIEFromUID (lldb::user_id_t uid); + lldb_private::CompilerDecl GetDeclForUID (lldb::user_id_t uid) override; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits