[Lldb-commits] [PATCH] D40473: DWZ 08/11: Adjust existing code for the DWZ support.

2018-03-11 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 137962.
jankratochvil added a comment.

bugfix


https://reviews.llvm.org/D40473

Files:
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -734,6 +734,8 @@
 
 DWARFUnit *dwarf_cu =
 info->GetCompileUnit((dw_offset_t)comp_unit->GetID());
+if (dwarf_cu)
+  dwarf_cu = dwarf_cu->GetMainCU();
 if (dwarf_cu && dwarf_cu->GetUserData() == NULL)
   dwarf_cu->SetUserData(comp_unit);
 return dwarf_cu;
@@ -763,6 +765,7 @@
uint32_t cu_idx) {
   CompUnitSP cu_sp;
   if (dwarf_cu) {
+dwarf_cu = dwarf_cu->GetMainCU();
 CompileUnit *comp_unit = (CompileUnit *)dwarf_cu->GetUserData();
 if (comp_unit) {
   // We already parsed this compile unit, had out a shared pointer to it
@@ -1370,6 +1373,9 @@
 
 Type *SymbolFileDWARF::ResolveTypeUID(const DWARFDIE ,
   bool assert_not_being_parsed) {
+  // this can be neither die.GetDWARF() nor die.GetMainDWARF().
+  if (die.GetMainDWARF() != this)
+return die.GetMainDWARF()->ResolveTypeUID(die, assert_not_being_parsed);
   if (die) {
 Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
 if (log)
@@ -1482,6 +1488,10 @@
 Type *SymbolFileDWARF::ResolveType(const DWARFDIE ,
bool assert_not_being_parsed,
bool resolve_function_context) {
+  // this can be neither die.GetDWARF() nor die.GetMainDWARF().
+  if (die.GetMainDWARF() != this)
+return die.GetMainDWARF()->ResolveType(
+die, assert_not_being_parsed, resolve_function_context);
   if (die) {
 Type *type = GetTypeForDIE(die, resolve_function_context).get();
 
@@ -1502,6 +1512,7 @@
 CompileUnit *
 SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFUnit *dwarf_cu,
  uint32_t cu_idx) {
+  dwarf_cu = dwarf_cu->GetMainCU();
   // Check if the symbol vendor already knows about this compile unit?
   if (dwarf_cu->GetUserData() == NULL) {
 // The symbol vendor doesn't know about this compile unit, we
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -151,6 +151,11 @@
   }
   dw_offset_t GetNextCompileUnitFileOffset() const;
 
+  // DW_TAG_compile_unit with DW_TAG_imported_unit for this DW_TAG_partial_unit.
+  DWARFUnit *GetMainCU() const {
+return const_cast(this);
+  }
+
 protected:
   virtual DWARFCompileUnit () = 0;
   virtual const DWARFCompileUnit () const = 0;
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -162,7 +162,8 @@
   // Don't specify the compile unit offset as we don't know it because the
   // DIE belongs to
   // a different compile unit in the same symbol file.
-  return Data().m_dwarf2Data->DebugInfo()->GetDIEForDIEOffset(die_offset);
+  return GetMainCU()->Data().m_dwarf2Data->DebugInfo()
+  ->GetDIEForDIEOffset(die_offset);
 }
   }
   Data().m_dwarf2Data->GetObjectFile()->GetModule()->ReportError(
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -570,7 +570,8 @@
   if (ranges.IsEmpty() || name == NULL || mangled == NULL) {
 for (const DIERef _ref : die_refs) {
   if (die_ref.die_offset != DW_INVALID_OFFSET) {
-DWARFDIE die = dwarf2Data->GetDIE(die_ref);
+DWARFDIE die = cu->GetMainCU()->GetSymbolFileDWARF()
+->GetDIE(die_ref);
 if (die)
   die.GetDIE()->GetDIENamesAndRanges(
   die.GetDWARF(), die.GetCU(), name, mangled, ranges, decl_file,
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -78,6 +78,8 @@
 for (size_t idx = 

[Lldb-commits] [PATCH] D40473: DWZ 08/11: Adjust existing code for the DWZ support.

2018-02-20 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 135059.
jankratochvil retitled this revision from "DWZ 10/12: Adjust existing code for 
the DWZ support." to "DWZ 08/11: Adjust existing code for the DWZ support.".

https://reviews.llvm.org/D40473

Files:
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -734,6 +734,8 @@
 
 DWARFUnit *dwarf_cu =
 info->GetCompileUnit((dw_offset_t)comp_unit->GetID());
+if (dwarf_cu)
+  dwarf_cu = dwarf_cu->GetMainCU();
 if (dwarf_cu && dwarf_cu->GetUserData() == NULL)
   dwarf_cu->SetUserData(comp_unit);
 return dwarf_cu;
@@ -763,6 +765,7 @@
uint32_t cu_idx) {
   CompUnitSP cu_sp;
   if (dwarf_cu) {
+dwarf_cu = dwarf_cu->GetMainCU();
 CompileUnit *comp_unit = (CompileUnit *)dwarf_cu->GetUserData();
 if (comp_unit) {
   // We already parsed this compile unit, had out a shared pointer to it
@@ -1370,6 +1373,9 @@
 
 Type *SymbolFileDWARF::ResolveTypeUID(const DWARFDIE ,
   bool assert_not_being_parsed) {
+  // this can be neither die.GetDWARF() nor die.GetMainDWARF().
+  if (die.GetMainDWARF() != this)
+return die.GetMainDWARF()->ResolveTypeUID(die, assert_not_being_parsed);
   if (die) {
 Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
 if (log)
@@ -1482,6 +1488,10 @@
 Type *SymbolFileDWARF::ResolveType(const DWARFDIE ,
bool assert_not_being_parsed,
bool resolve_function_context) {
+  // this can be neither die.GetDWARF() nor die.GetMainDWARF().
+  if (die.GetMainDWARF() != this)
+return die.GetMainDWARF()->ResolveType(
+die, assert_not_being_parsed, resolve_function_context);
   if (die) {
 Type *type = GetTypeForDIE(die, resolve_function_context).get();
 
@@ -1502,6 +1512,7 @@
 CompileUnit *
 SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFUnit *dwarf_cu,
  uint32_t cu_idx) {
+  dwarf_cu = dwarf_cu->GetMainCU();
   // Check if the symbol vendor already knows about this compile unit?
   if (dwarf_cu->GetUserData() == NULL) {
 // The symbol vendor doesn't know about this compile unit, we
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -151,6 +151,11 @@
   }
   dw_offset_t GetNextCompileUnitFileOffset() const;
 
+  // DW_TAG_compile_unit with DW_TAG_imported_unit for this DW_TAG_partial_unit.
+  DWARFUnit *GetMainCU() const {
+return const_cast(this);
+  }
+
 protected:
   virtual DWARFCompileUnit () = 0;
   virtual const DWARFCompileUnit () const = 0;
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -162,7 +162,8 @@
   // Don't specify the compile unit offset as we don't know it because the
   // DIE belongs to
   // a different compile unit in the same symbol file.
-  return Data().m_dwarf2Data->DebugInfo()->GetDIEForDIEOffset(die_offset);
+  return GetMainCU()->Data().m_dwarf2Data->DebugInfo()
+  ->GetDIEForDIEOffset(die_offset);
 }
   }
   Data().m_dwarf2Data->GetObjectFile()->GetModule()->ReportError(
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -570,7 +570,8 @@
   if (ranges.IsEmpty() || name == NULL || mangled == NULL) {
 for (const DIERef _ref : die_refs) {
   if (die_ref.die_offset != DW_INVALID_OFFSET) {
-DWARFDIE die = dwarf2Data->GetDIE(die_ref);
+DWARFDIE die = cu->GetMainCU()->GetSymbolFileDWARF()
+->GetDIE(die_ref);
 if (die)
   die.GetDIE()->GetDIENamesAndRanges(
   die.GetDWARF(), die.GetCU(), name, mangled, ranges, decl_file,
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
===
---