[Lldb-commits] [PATCH] D109231: [lldb] Improve error handling around GetRngListData()

2021-09-23 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:522
+entry->getContribution(llvm::DW_SECT_RNGLISTS)) {
+  Offset = contribution->Offset;
   return DWARFDataExtractor(data, contribution->Offset,

shafik wrote:
> If I am reading this correctly, it looks like this will only be set on the 
> non-error case which will leave `contribution_off` in the caller 
> uninitialized in the cases you care about logging.
Sorry for the very late reply (I had a long vacation)! And thanks for the 
comment.

If `GetRnglistData` didn't work, the error will be thrown below (line 526) in 
here. However, if it is successful, but another problem occurs (callers of 
`GetRnglistData` throw an error) the Offset will be initialized, and it can be 
logged. Example: `ParseListTableHeader` using it in ll. 548. Does that make 
sense?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109231/new/

https://reviews.llvm.org/D109231

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D106270: [DWARF5] Fix offset check when using .debug_names

2021-07-19 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh created this revision.
Herald added a subscriber: arphaman.
kimanh added a subscriber: pfaffe.
kimanh edited the summary of this revision.
kimanh added a reviewer: labath.
kimanh published this revision for review.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When going through the CU entries in the name index,
make sure to compare against the name entry's CU
offset against the skeleton CU's offset.

Previously there would be a mismatch, since the
wrong offset was compared, and thus no suitable
entry was found.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106270

Files:
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/Shell/SymbolFile/DWARF/x86/find-variable-file.cpp

Index: lldb/test/Shell/SymbolFile/DWARF/x86/find-variable-file.cpp
===
--- lldb/test/Shell/SymbolFile/DWARF/x86/find-variable-file.cpp
+++ lldb/test/Shell/SymbolFile/DWARF/x86/find-variable-file.cpp
@@ -27,6 +27,17 @@
 // RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \
 // RUN:   FileCheck --check-prefix=TWO %s
 
+// Run the same test with split dwarf and pubnames to check whether we can find
+// the compile unit using the name index if it is split.
+// RUN: %clang -c -o %t-1.o --target=x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -gpubnames %s
+// RUN: %clang -c -o %t-2.o --target=x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -gpubnames %S/Inputs/find-variable-file-2.cpp
+// RUN: ld.lld %t-1.o %t-2.o -o %t
+// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
+// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \
+// RUN:   FileCheck --check-prefix=ONE %s
+// RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \
+// RUN:   FileCheck --check-prefix=TWO %s
+
 // NAMES: Name: .debug_names
 
 // ONE: Found 1 variables:
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3020,16 +3020,14 @@
 variables = std::make_shared();
 sc.comp_unit->SetVariableList(variables);
 
-m_index->GetGlobalVariables(
-dwarf_cu->GetNonSkeletonUnit(), [&](DWARFDIE die) {
-  VariableSP var_sp(
-  ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS));
-  if (var_sp) {
-variables->AddVariableIfUnique(var_sp);
-++vars_added;
-  }
-  return true;
-});
+m_index->GetGlobalVariables(*dwarf_cu, [&](DWARFDIE die) {
+  VariableSP var_sp(ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS));
+  if (var_sp) {
+variables->AddVariableIfUnique(var_sp);
+++vars_added;
+  }
+  return true;
+});
   }
   return vars_added;
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -33,7 +33,7 @@
   GetGlobalVariables(const RegularExpression ®ex,
  llvm::function_ref callback) override;
   void
-  GetGlobalVariables(const DWARFUnit &unit,
+  GetGlobalVariables(DWARFUnit &unit,
  llvm::function_ref callback) override;
   void GetObjCMethods(ConstString class_name,
   llvm::function_ref callback) override;
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -358,9 +358,10 @@
 }
 
 void ManualDWARFIndex::GetGlobalVariables(
-const DWARFUnit &unit, llvm::function_ref callback) {
+DWARFUnit &unit, llvm::function_ref callback) {
   Index();
-  m_set.globals.FindAllEntriesForUnit(unit, DIERefCallback(callback));
+  m_set.globals.FindAllEntriesForUnit(unit.GetNonSkeletonUnit(),
+  DIERefCallback(callback));
 }
 
 void ManualDWARFIndex::GetObjCMethods(
Index: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ lld

[Lldb-commits] [PATCH] D106270: [DWARF5] Fix offset check when using .debug_names

2021-07-19 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp:82
 
+  const DWARFUnit &non_skeleton_cu = cu.GetNonSkeletonUnit();
   DWARFMappedHash::DIEInfoArray hash_data;

JDevlieghere wrote:
> I assume the `const` of the `DWARFUnit` is being dropped because 
> `GetNonSkeletonUnit`? Rather than doing that, can't that function be const 
> instead? 
Yes correct. I agree with your point that dropping `const` here is not very 
nice, but I'm not sure whether we can make that function const easily. 
As is `GetNonSkeletonUnit` is updating itself in `ExtractUnitDIEIfNeeded()`, 
which kicks off many non-const operations for updating itself. As far as I 
understand, if we would want to make it const, we'd need to change the 
architectural logic in how the skeleton and non-skeleton units are connected. 
I'm not very familiar with the code base, so any advice here is welcome!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106270/new/

https://reviews.llvm.org/D106270

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D106355: [DWARF5] Only fallback to manual index if no entry was found

2021-07-20 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh created this revision.
Herald added a subscriber: arphaman.
kimanh updated this revision to Diff 360084.
kimanh added a comment.
kimanh retitled this revision from "[Index] Only fallback to manual index if no 
entry was found" to "[DWARF5] Only fallback to manual index if no entry was 
found".
kimanh added a reviewer: labath.
kimanh added a subscriber: pfaffe.
kimanh published this revision for review.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Minor: rename variable


kimanh added a comment.

Hello Pavel,

we are currently looking at the usage of the .debug_names section. For 
`DebugNamesDWARFIndex::GetGlobalVariables(DWARFUnit &cu, 
llvm::function_ref callback)` we do not see a clear reason 
why one would need to still call the fallback. In this case, we only look at 
that particular CU, and if there's already a name index for that CU, going 
through the name index should be enough? If we are missing something, please 
let us know! Otherwise, here is a CL that would only conditionally create the 
manual index.


If we succeed at gathering global variables for a compile
unit, there is no need to fallback to generating a manual index.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106355

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -125,6 +125,7 @@
 void DebugNamesDWARFIndex::GetGlobalVariables(
 DWARFUnit &cu, llvm::function_ref callback) {
   uint64_t cu_offset = cu.GetOffset();
+  bool found_entry_for_cu = false;
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 for (DebugNames::NameTableEntry nte: ni) {
   uint64_t entry_offset = nte.getEntryOffset();
@@ -135,6 +136,7 @@
 if (entry_or->getCUOffset() != cu_offset)
   continue;
 
+found_entry_for_cu = true;
 if (!ProcessEntry(*entry_or, callback,
   llvm::StringRef(nte.getString(
   return;
@@ -142,8 +144,11 @@
   MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
 }
   }
-
-  m_fallback.GetGlobalVariables(cu, callback);
+  // If no name index for that particular CU was found, fallback to
+  // creating the manual index.
+  if (!found_entry_for_cu) {
+m_fallback.GetGlobalVariables(cu, callback);
+  }
 }
 
 void DebugNamesDWARFIndex::GetCompleteObjCClass(


Index: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -125,6 +125,7 @@
 void DebugNamesDWARFIndex::GetGlobalVariables(
 DWARFUnit &cu, llvm::function_ref callback) {
   uint64_t cu_offset = cu.GetOffset();
+  bool found_entry_for_cu = false;
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 for (DebugNames::NameTableEntry nte: ni) {
   uint64_t entry_offset = nte.getEntryOffset();
@@ -135,6 +136,7 @@
 if (entry_or->getCUOffset() != cu_offset)
   continue;
 
+found_entry_for_cu = true;
 if (!ProcessEntry(*entry_or, callback,
   llvm::StringRef(nte.getString(
   return;
@@ -142,8 +144,11 @@
   MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
 }
   }
-
-  m_fallback.GetGlobalVariables(cu, callback);
+  // If no name index for that particular CU was found, fallback to
+  // creating the manual index.
+  if (!found_entry_for_cu) {
+m_fallback.GetGlobalVariables(cu, callback);
+  }
 }
 
 void DebugNamesDWARFIndex::GetCompleteObjCClass(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D106355: [DWARF5] Only fallback to manual index if no entry was found

2021-07-22 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

Thanks for having a look at the CL!

In D106355#2893959 , @jankratochvil 
wrote:

> Is it really just a microoptimization or can you measure any improvement? 
> That `ManualDWARFIndex::Index` will be called is expected. But there should 
> be `m_units_to_avoid` covering all the units so it will quickly return 
> without indexing anything:

Yes, we are aware that it filters out the units that are already indexed by the 
the name index. In our case we have some third-party libraries that were not 
built by us, and therefore they don't have any name index. Our main focus, is 
however, not to debug those third party libraries necessarily, but only our 
main code that we are compiling. Given that the manual index is taking some 
time to be generated, we could be lazy about generating it only if we need it.

WDYT?

> Maybe there is rather some other more serious bug to fix (I am aware for 
> example D99850  but that would behave 
> differently).

No, there's no serious bug that I'm aware of that is linked to this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106355/new/

https://reviews.llvm.org/D106355

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D106355: [DWARF5] Only fallback to manual index if no entry was found

2021-07-25 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.



> If you do not want to debug those libraries cannot you just strip debug info 
> from them (`llvm-strip -g`)?

Oh, stripping debug info may work. We're on the Chrome DevTools team and we're 
working on a DWARF-based debugging extension for C/C++. Ideally we'd like to 
have as few steps as possible that are required for our users to take, in order 
to successfully debug their application on the web. We'll keep this in mind.

> Wouldn't be best to generate `.debug_names` for those 3rd party libraries? 
> GDB has `gdb-add-index` but its `.gdb_index` has not enough information to be 
> useful for LLDB. Still LLDB could generate `.debug_names` out of its internal 
> representation in `ManualDWARFIndex`. That would be useful also for debugging 
> binaries from non-clang compilers.

Ah, to make sure that I understand it correctly: using `gdb-add-index` would 
help `ManualDWARFIndex` to generate a `.debug_names`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106355/new/

https://reviews.llvm.org/D106355

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D106270: [DWARF5] Fix offset check when using .debug_names

2021-07-25 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

Ping on this thread, any comment/guidance on this would help us a lot!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106270/new/

https://reviews.llvm.org/D106270

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D106270: [DWARF5] Fix offset check when using .debug_names

2021-07-26 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3024
-m_index->GetGlobalVariables(
-dwarf_cu->GetNonSkeletonUnit(), [&](DWARFDIE die) {
-  VariableSP var_sp(

shafik wrote:
> So is the problem that calling `GetNonSkeletonUnit()` does not work here b/c 
> in `DebugNamesDWARFIndex` case we don't want this but in the other cases we 
> do? 
> 
> 
Yes, that's correct!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106270/new/

https://reviews.llvm.org/D106270

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D106355: [DWARF5] Only fallback to manual index if no entry was found

2021-07-27 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh updated this revision to Diff 362287.
kimanh marked an inline comment as done.
kimanh added a comment.

Remove braces.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106355/new/

https://reviews.llvm.org/D106355

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -125,6 +125,7 @@
 void DebugNamesDWARFIndex::GetGlobalVariables(
 const DWARFUnit &cu, llvm::function_ref callback) {
   uint64_t cu_offset = cu.GetOffset();
+  bool found_entry_for_cu = false;
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 for (DebugNames::NameTableEntry nte: ni) {
   uint64_t entry_offset = nte.getEntryOffset();
@@ -135,6 +136,7 @@
 if (entry_or->getCUOffset() != cu_offset)
   continue;
 
+found_entry_for_cu = true;
 if (!ProcessEntry(*entry_or, callback,
   llvm::StringRef(nte.getString(
   return;
@@ -142,8 +144,10 @@
   MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
 }
   }
-
-  m_fallback.GetGlobalVariables(cu, callback);
+  // If no name index for that particular CU was found, fallback to
+  // creating the manual index.
+  if (!found_entry_for_cu)
+m_fallback.GetGlobalVariables(cu, callback);
 }
 
 void DebugNamesDWARFIndex::GetCompleteObjCClass(


Index: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -125,6 +125,7 @@
 void DebugNamesDWARFIndex::GetGlobalVariables(
 const DWARFUnit &cu, llvm::function_ref callback) {
   uint64_t cu_offset = cu.GetOffset();
+  bool found_entry_for_cu = false;
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 for (DebugNames::NameTableEntry nte: ni) {
   uint64_t entry_offset = nte.getEntryOffset();
@@ -135,6 +136,7 @@
 if (entry_or->getCUOffset() != cu_offset)
   continue;
 
+found_entry_for_cu = true;
 if (!ProcessEntry(*entry_or, callback,
   llvm::StringRef(nte.getString(
   return;
@@ -142,8 +144,10 @@
   MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
 }
   }
-
-  m_fallback.GetGlobalVariables(cu, callback);
+  // If no name index for that particular CU was found, fallback to
+  // creating the manual index.
+  if (!found_entry_for_cu)
+m_fallback.GetGlobalVariables(cu, callback);
 }
 
 void DebugNamesDWARFIndex::GetCompleteObjCClass(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D106355: [DWARF5] Only fallback to manual index if no entry was found

2021-07-28 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh marked an inline comment as not done.
kimanh added a comment.

Thanks once more for reviewing! If I should rename the variable (or anything 
else), let me know! Otherwise, could you help me to land this change (since I 
do not have committer rights)?




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp:136
   continue;
 if (entry_or->getCUOffset() != cu_offset)
   continue;

jankratochvil wrote:
> It would be nice to reverse these two comparisons for `found_entry_for_cu` 
> but `getCUOffset()` is much more expensive. Just saying.
> 
Ah, yes, that's true. I could call it `found_variable_entry_for_cu` though?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106355/new/

https://reviews.llvm.org/D106355

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D106355: [DWARF5] Only fallback to manual index if no entry was found

2021-07-29 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

In D106355#2913605 , @jankratochvil 
wrote:

> You can also consider coding `lldb-add-index` for better performance as that 
> is too much for my available time.

I don't think that I'll get to it either. But we'll also evaluate the 
performance for our users and may need to do more, and in that case we might 
have a look!

> I guess you could already ask for a commit access, you have multiple patches 
> checked in.

Thanks for the suggestion, I just requested it now!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106355/new/

https://reviews.llvm.org/D106355

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D107161: [lldb] Fix lookup of .debug_loclists with split-dwarf

2021-07-30 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh created this revision.
kimanh edited the summary of this revision.
kimanh added reviewers: labath, jankratochvil.
kimanh published this revision for review.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch fixes the lookup of locations in
.debug_loclists, if they are split in a .dwp file.

Mainly, we need to consider the cu index offsets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107161

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwp.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwp.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwp.s
@@ -0,0 +1,237 @@
+## This tests if .debug_loclists.dwo are correctly read if they are part
+## of a dwp file.
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym MAIN=0 > %t
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t.dwp
+# RUN: %lldb %t -o "image lookup -v -s lookup_loclists" -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_loclists
+# CHECK: Variable: id = {{.*}}, name = "x0", type = "int", location = DW_OP_reg0 RAX,
+# CHECK: Variable: id = {{.*}}, name = "x1", type = "int", location = DW_OP_reg1 RDX,
+
+## This part is kept in both the main and the dwp file to be able to reference the offsets.
+loclists:
+nop
+.Ltmp0:
+nop
+.Ltmp1:
+lookup_loclists:
+nop
+.Ltmp2:
+nop
+.Ltmp3:
+nop
+.Lloclists_end:
+
+## The main file.
+.ifdef MAIN
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   74  # DW_TAG_compile_unit
+.byte   0   # DW_CHILDREN_no
+.byte   0x76# DW_AT_dwo_name
+.byte   8   # DW_FORM_string
+.byte   115 # DW_AT_addr_base
+.byte   23  # DW_FORM_sec_offset
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   85  # DW_AT_ranges
+.byte   35  # DW_FORM_rnglistx
+.byte   116 # DW_AT_rnglists_base
+.byte   23  # DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+.short  5   # DWARF version number
+.byte   4   # DWARF Unit Type
+.byte   8   # Address Size (in bytes)
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.quad   1026699901672188186  # DWO id
+.byte   1   # Abbrev [1] 0xc:0x5f DW_TAG_compile_unit
+.asciz  "debug_loclists-dwp.dwo"  # DW_AT_dwo_name
+.long   .Laddr_table_base0  # DW_AT_addr_base
+.quad   loclists# DW_AT_low_pc
+.byte   0   # DW_AT_ranges
+.long   .Lskel_rnglists_table_base # DW_AT_rnglists_base
+.Ldebug_info_end0:
+.section.debug_rnglists,"",@progbits
+.long   .Lskel_rnglist_table_end-.Lskel_rnglist_table_start # Length
+.Lskel_rnglist_table_start:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   1   # Offset entry count
+.Lskel_rnglists_table_base:
+.long   .Lskel_ranges0-.Lskel_rnglists_table_base
+.Lskel_ranges0:
+.byte   7   # DW_RLE_start_length
+.quad   loclists
+.uleb128   .Lloclists_end-loclists
+.byte   0   # DW_RLE_end_of_list
+.Lskel_rnglist_table_end:
+.section.debug_addr,"",@progbits
+.long   .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+.short  5   # DWARF version number
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.Laddr_table_base0:
+.quad   loclists
+.quad   .Ltmp1
+.Ldebug_addr_end0:
+
+.else
+## DWP file starts here.
+
+.section.debug_loclists.dwo,"e",@progbits
+## Start the section with an unused table to check that the reading offset
+## of the real table is correctly adjusted.
+.long .LLLDummyEnd-.LLLDummyVersion # Length of Unit
+.LLLDummyVersion:
+.short 5# Version
+.byte 8   

[Lldb-commits] [PATCH] D107161: [lldb] Fix lookup of .debug_loclists with split-dwarf

2021-08-02 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh updated this revision to Diff 363407.
kimanh marked 7 inline comments as done.
kimanh added a comment.

Address reviews:

- remove unused tmp label
- remove invalid offsets
- add ReportError when no loclist contribution was found
- adapt ReportError logging to include offset and loclist base


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107161/new/

https://reviews.llvm.org/D107161

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwp.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwp.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwp.s
@@ -0,0 +1,236 @@
+## This tests if .debug_loclists.dwo are correctly read if they are part
+## of a dwp file.
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym MAIN=0 > %t
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t.dwp
+# RUN: %lldb %t -o "image lookup -v -s lookup_loclists" -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_loclists
+# CHECK: Variable: id = {{.*}}, name = "x0", type = "int", location = DW_OP_reg0 RAX,
+# CHECK: Variable: id = {{.*}}, name = "x1", type = "int", location = DW_OP_reg1 RDX,
+
+## This part is kept in both the main and the dwp file to be able to reference the offsets.
+loclists:
+nop
+nop
+.Ltmp1:
+lookup_loclists:
+nop
+.Ltmp2:
+nop
+.Ltmp3:
+nop
+.Lloclists_end:
+
+## The main file.
+.ifdef MAIN
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   74  # DW_TAG_compile_unit
+.byte   0   # DW_CHILDREN_no
+.byte   0x76# DW_AT_dwo_name
+.byte   8   # DW_FORM_string
+.byte   115 # DW_AT_addr_base
+.byte   23  # DW_FORM_sec_offset
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   85  # DW_AT_ranges
+.byte   35  # DW_FORM_rnglistx
+.byte   116 # DW_AT_rnglists_base
+.byte   23  # DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+.short  5   # DWARF version number
+.byte   4   # DWARF Unit Type
+.byte   8   # Address Size (in bytes)
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.quad   1026699901672188186  # DWO id
+.byte   1   # Abbrev [1] DW_TAG_compile_unit
+.asciz  "debug_loclists-dwp.dwo"  # DW_AT_dwo_name
+.long   .Laddr_table_base0  # DW_AT_addr_base
+.quad   loclists# DW_AT_low_pc
+.byte   0   # DW_AT_ranges
+.long   .Lskel_rnglists_table_base # DW_AT_rnglists_base
+.Ldebug_info_end0:
+.section.debug_rnglists,"",@progbits
+.long   .Lskel_rnglist_table_end-.Lskel_rnglist_table_start # Length
+.Lskel_rnglist_table_start:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   1   # Offset entry count
+.Lskel_rnglists_table_base:
+.long   .Lskel_ranges0-.Lskel_rnglists_table_base
+.Lskel_ranges0:
+.byte   7   # DW_RLE_start_length
+.quad   loclists
+.uleb128   .Lloclists_end-loclists
+.byte   0   # DW_RLE_end_of_list
+.Lskel_rnglist_table_end:
+.section.debug_addr,"",@progbits
+.long   .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+.short  5   # DWARF version number
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.Laddr_table_base0:
+.quad   loclists
+.quad   .Ltmp1
+.Ldebug_addr_end0:
+
+.else
+## DWP file starts here.
+
+.section.debug_loclists.dwo,"e",@progbits
+## Start the section with an unused table to check that the reading offset
+## of the real table is correctly adjusted.
+.long .LLLDummyEnd-.LLLDummyVersion # Length of Unit
+.LLLDummyVersion:
+.short 5# Version
+.byte 8 # Address s

[Lldb-commits] [PATCH] D107161: [lldb] Fix lookup of .debug_loclists with split-dwarf

2021-08-04 Thread Kim-Anh Tran via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0092dbcd80f2: [lldb] Fix lookup of .debug_loclists with 
split-dwarf (authored by kimanh).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107161/new/

https://reviews.llvm.org/D107161

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwp.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwp.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwp.s
@@ -0,0 +1,236 @@
+## This tests if .debug_loclists.dwo are correctly read if they are part
+## of a dwp file.
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym MAIN=0 > %t
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t.dwp
+# RUN: %lldb %t -o "image lookup -v -s lookup_loclists" -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_loclists
+# CHECK: Variable: id = {{.*}}, name = "x0", type = "int", location = DW_OP_reg0 RAX,
+# CHECK: Variable: id = {{.*}}, name = "x1", type = "int", location = DW_OP_reg1 RDX,
+
+## This part is kept in both the main and the dwp file to be able to reference the offsets.
+loclists:
+nop
+nop
+.Ltmp1:
+lookup_loclists:
+nop
+.Ltmp2:
+nop
+.Ltmp3:
+nop
+.Lloclists_end:
+
+## The main file.
+.ifdef MAIN
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   74  # DW_TAG_compile_unit
+.byte   0   # DW_CHILDREN_no
+.byte   0x76# DW_AT_dwo_name
+.byte   8   # DW_FORM_string
+.byte   115 # DW_AT_addr_base
+.byte   23  # DW_FORM_sec_offset
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   85  # DW_AT_ranges
+.byte   35  # DW_FORM_rnglistx
+.byte   116 # DW_AT_rnglists_base
+.byte   23  # DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+.short  5   # DWARF version number
+.byte   4   # DWARF Unit Type
+.byte   8   # Address Size (in bytes)
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.quad   1026699901672188186  # DWO id
+.byte   1   # Abbrev [1] DW_TAG_compile_unit
+.asciz  "debug_loclists-dwp.dwo"  # DW_AT_dwo_name
+.long   .Laddr_table_base0  # DW_AT_addr_base
+.quad   loclists# DW_AT_low_pc
+.byte   0   # DW_AT_ranges
+.long   .Lskel_rnglists_table_base # DW_AT_rnglists_base
+.Ldebug_info_end0:
+.section.debug_rnglists,"",@progbits
+.long   .Lskel_rnglist_table_end-.Lskel_rnglist_table_start # Length
+.Lskel_rnglist_table_start:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   1   # Offset entry count
+.Lskel_rnglists_table_base:
+.long   .Lskel_ranges0-.Lskel_rnglists_table_base
+.Lskel_ranges0:
+.byte   7   # DW_RLE_start_length
+.quad   loclists
+.uleb128   .Lloclists_end-loclists
+.byte   0   # DW_RLE_end_of_list
+.Lskel_rnglist_table_end:
+.section.debug_addr,"",@progbits
+.long   .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+.short  5   # DWARF version number
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.Laddr_table_base0:
+.quad   loclists
+.quad   .Ltmp1
+.Ldebug_addr_end0:
+
+.else
+## DWP file starts here.
+
+.section.debug_loclists.dwo,"e",@progbits
+## Start the section with an unused table to check that the reading offset
+## of the real table is correctly adjusted.
+.long .LLLDummyEnd-.LLLDummyVersion # Length of Unit
+.LLLDummyVersion:
+.short 5# Version
+.byte 8 # Address size
+.byte 0 # Segment se

[Lldb-commits] [PATCH] D107456: [lldb] Support .debug_rnglists.dwo sections in dwp file

2021-08-04 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh created this revision.
kimanh updated this revision to Diff 364081.
kimanh added a comment.
kimanh updated this revision to Diff 364364.
kimanh added reviewers: labath, jankratochvil.
kimanh published this revision for review.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Include all commits.


kimanh added a comment.

Simplifying test and add comments.


This patch considers the CU index entry
when reading the .debug_rnglists.dwo section.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107456

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s
@@ -0,0 +1,187 @@
+## This tests if .debug_rnglists.dwo are correctly read if they are part
+## of a dwp file.
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym MAIN=0 > %t
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t.dwp
+# RUN: %lldb %t -o "image lookup -v -s lookup_rnglists" -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_rnglists
+# CHECK:  Function: id = {{.*}}, name = "rnglists", range = [0x-0x0003)
+# CHECK:Blocks: id = {{.*}}, range = [0x-0x0003)
+# CHECK-NEXT:   id = {{.*}}, range = [0x0001-0x0002)
+
+.text
+rnglists:
+nop
+.Lblock1_begin:
+lookup_rnglists:
+nop
+.Lblock1_end:
+nop
+.Lrnglists_end:
+
+## The main file.
+.ifdef MAIN
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   0   # DW_CHILDREN_no
+.byte   0x76# DW_AT_dwo_name
+.byte   8   # DW_FORM_string
+.byte   115 # DW_AT_addr_base
+.byte   23  # DW_FORM_sec_offset
+.byte   85  # DW_AT_ranges
+.byte   35  # DW_FORM_rnglistx
+.byte   116 # DW_AT_rnglists_base
+.byte   23  # DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+.short  5   # DWARF version number
+.byte   4   # DWARF Unit Type
+.byte   8   # Address Size (in bytes)
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.quad   1026699901672188186 # DWO id
+.byte   1   # Abbrev [1] DW_TAG_compile_unit
+.asciz  "debug_rnglists-dwp.s.tmp.dwo"  # DW_AT_dwo_name
+.long   .Laddr_table_base0  # DW_AT_addr_base
+.byte   0   # DW_AT_ranges
+.long   .Lskel_rnglists_table_base # DW_AT_rnglists_base
+.Ldebug_info_end0:
+
+.section.debug_addr,"",@progbits
+.long   .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+.short  5   # DWARF version number
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.Laddr_table_base0:
+.quad   rnglists
+.quad   .Lblock1_begin
+.Ldebug_addr_end0:
+
+.section.debug_rnglists,"",@progbits
+.long   .Lskel_rnglist_table_end-.Lskel_rnglist_table_start # Length
+.Lskel_rnglist_table_start:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   1   # Offset entry count
+.Lskel_rnglists_table_base:
+.long   .Lskel_ranges0-.Lskel_rnglists_table_base
+.Lskel_ranges0:
+.byte   7   # DW_RLE_start_length
+.quad   rnglists
+.uleb128   .Lrnglists_end-rnglists
+.byte   0   # DW_RLE_end_of_list
+.Lskel_rnglist_table_end:
+ .else
+ ## DWP file starts here.
+.section.debug_abbrev.dwo,"e",@progbits
+.LAbbrevBegin:
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   0  

[Lldb-commits] [PATCH] D106270: [DWARF5] Fix offset check when using .debug_names

2021-08-09 Thread Kim-Anh Tran via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0dda5425318a: [DWARF5] Fix offset check when using 
.debug_names (authored by kimanh).

Changed prior to commit:
  https://reviews.llvm.org/D106270?vs=359763&id=365154#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106270/new/

https://reviews.llvm.org/D106270

Files:
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/Shell/SymbolFile/DWARF/x86/find-variable-file.cpp

Index: lldb/test/Shell/SymbolFile/DWARF/x86/find-variable-file.cpp
===
--- lldb/test/Shell/SymbolFile/DWARF/x86/find-variable-file.cpp
+++ lldb/test/Shell/SymbolFile/DWARF/x86/find-variable-file.cpp
@@ -27,6 +27,17 @@
 // RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \
 // RUN:   FileCheck --check-prefix=TWO %s
 
+// Run the same test with split dwarf and pubnames to check whether we can find
+// the compile unit using the name index if it is split.
+// RUN: %clang -c -o %t-1.o --target=x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -gpubnames %s
+// RUN: %clang -c -o %t-2.o --target=x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -gpubnames %S/Inputs/find-variable-file-2.cpp
+// RUN: ld.lld %t-1.o %t-2.o -o %t
+// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
+// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \
+// RUN:   FileCheck --check-prefix=ONE %s
+// RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \
+// RUN:   FileCheck --check-prefix=TWO %s
+
 // NAMES: Name: .debug_names
 
 // ONE: Found 1 variables:
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3069,16 +3069,14 @@
 variables = std::make_shared();
 sc.comp_unit->SetVariableList(variables);
 
-m_index->GetGlobalVariables(
-dwarf_cu->GetNonSkeletonUnit(), [&](DWARFDIE die) {
-  VariableSP var_sp(
-  ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS));
-  if (var_sp) {
-variables->AddVariableIfUnique(var_sp);
-++vars_added;
-  }
-  return true;
-});
+m_index->GetGlobalVariables(*dwarf_cu, [&](DWARFDIE die) {
+  VariableSP var_sp(ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS));
+  if (var_sp) {
+variables->AddVariableIfUnique(var_sp);
+++vars_added;
+  }
+  return true;
+});
   }
   return vars_added;
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -33,7 +33,7 @@
   GetGlobalVariables(const RegularExpression ®ex,
  llvm::function_ref callback) override;
   void
-  GetGlobalVariables(const DWARFUnit &unit,
+  GetGlobalVariables(DWARFUnit &unit,
  llvm::function_ref callback) override;
   void GetObjCMethods(ConstString class_name,
   llvm::function_ref callback) override;
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -358,9 +358,10 @@
 }
 
 void ManualDWARFIndex::GetGlobalVariables(
-const DWARFUnit &unit, llvm::function_ref callback) {
+DWARFUnit &unit, llvm::function_ref callback) {
   Index();
-  m_set.globals.FindAllEntriesForUnit(unit, DIERefCallback(callback));
+  m_set.globals.FindAllEntriesForUnit(unit.GetNonSkeletonUnit(),
+  DIERefCallback(callback));
 }
 
 void ManualDWARFIndex::GetObjCMethods(
Index: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
@@ -32,7 +32,7 @@
   GetGlobalVariables(const RegularExpression ®ex,
  llvm::function_r

[Lldb-commits] [PATCH] D106270: [DWARF5] Fix offset check when using .debug_names

2021-08-09 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

Thanks for the review! Landing now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106270/new/

https://reviews.llvm.org/D106270

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D107659: [nfc] [lldb] Assertions for D106270 - [DWARF5] Fix offset check when using .debug_names

2021-08-09 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh accepted this revision.
kimanh added a comment.
This revision is now accepted and ready to land.

LGTM, I also support that assertions are added. This gives confidence in what's 
expected and also makes it easier to read/understand whether it's a 
skeleton/non-skeleton unit that we are dealing with.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107659/new/

https://reviews.llvm.org/D107659

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D107456: [lldb] Support .debug_rnglists.dwo sections in dwp file

2021-08-20 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh updated this revision to Diff 367758.
kimanh marked 2 inline comments as done.
kimanh added a comment.

- Incorporating Jan's patch
- Adding error message


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107456/new/

https://reviews.llvm.org/D107456

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s
@@ -0,0 +1,187 @@
+## This tests if .debug_rnglists.dwo are correctly read if they are part
+## of a dwp file.
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym MAIN=0 > %t
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t.dwp
+# RUN: %lldb %t -o "image lookup -v -s lookup_rnglists" -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_rnglists
+# CHECK:  Function: id = {{.*}}, name = "rnglists", range = [0x-0x0003)
+# CHECK:Blocks: id = {{.*}}, range = [0x-0x0003)
+# CHECK-NEXT:   id = {{.*}}, range = [0x0001-0x0002)
+
+.text
+rnglists:
+nop
+.Lblock1_begin:
+lookup_rnglists:
+nop
+.Lblock1_end:
+nop
+.Lrnglists_end:
+
+## The main file.
+.ifdef MAIN
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   0   # DW_CHILDREN_no
+.byte   0x76# DW_AT_dwo_name
+.byte   8   # DW_FORM_string
+.byte   115 # DW_AT_addr_base
+.byte   23  # DW_FORM_sec_offset
+.byte   85  # DW_AT_ranges
+.byte   35  # DW_FORM_rnglistx
+.byte   116 # DW_AT_rnglists_base
+.byte   23  # DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+.short  5   # DWARF version number
+.byte   4   # DWARF Unit Type
+.byte   8   # Address Size (in bytes)
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.quad   1026699901672188186 # DWO id
+.byte   1   # Abbrev [1] DW_TAG_compile_unit
+.asciz  "debug_rnglists-dwp.s.tmp.dwo"  # DW_AT_dwo_name
+.long   .Laddr_table_base0  # DW_AT_addr_base
+.byte   0   # DW_AT_ranges
+.long   .Lskel_rnglists_table_base # DW_AT_rnglists_base
+.Ldebug_info_end0:
+
+.section.debug_addr,"",@progbits
+.long   .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+.short  5   # DWARF version number
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.Laddr_table_base0:
+.quad   rnglists
+.quad   .Lblock1_begin
+.Ldebug_addr_end0:
+
+.section.debug_rnglists,"",@progbits
+.long   .Lskel_rnglist_table_end-.Lskel_rnglist_table_start # Length
+.Lskel_rnglist_table_start:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   1   # Offset entry count
+.Lskel_rnglists_table_base:
+.long   .Lskel_ranges0-.Lskel_rnglists_table_base
+.Lskel_ranges0:
+.byte   7   # DW_RLE_start_length
+.quad   rnglists
+.uleb128   .Lrnglists_end-rnglists
+.byte   0   # DW_RLE_end_of_list
+.Lskel_rnglist_table_end:
+ .else
+ ## DWP file starts here.
+.section.debug_abbrev.dwo,"e",@progbits
+.LAbbrevBegin:
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   46  # DW_TAG_subprogram
+.byte   1   # DW_CHILDREN_yes

[Lldb-commits] [PATCH] D107456: [lldb] Support .debug_rnglists.dwo sections in dwp file

2021-08-20 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

Thanks a lot for the review! Very sorry for my late update, I was out on 
vacation and then had to catch up with mails. Updated the revision now.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:537
+if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
+  const auto *contribution = 
entry->getContribution(llvm::DW_SECT_RNGLISTS);
+  if (!contribution) {

jankratochvil wrote:
> I have found this `getContribution` adjustment duplication, are there some 
> reasons it is not unified?  
> https://www.jankratochvil.net/t/D107456-unify.patch
> The issue is the code then handles two different `.debug_rnglists` 
> `DWARFDataExtractor`s with different offsets.
> 
Thanks a lot for the patch, I unified it in the latest update. IIRC (some time 
ago, so I don't recall completely) there was a mismatch in offsets maybe 
because I missed to update `GetRnglistOffset` to use `getRnglistData` too.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:556
+  " (ranges list base: 0x%" PRIx64 "): %s",
+  offset, m_ranges_base, toString(table_or_error.takeError()).c_str());
   }

jankratochvil wrote:
> One such reason can be missing DWP absolute offset for the error report. That 
> could be returned from `GetRnglistData()`.
> 
If I understand your comment correctly, you are suggesting to incorporate the 
contribution offset into the error message of `GetRnglistData`, is that 
correct? However, `GetRnglistData` will only return an error message if the 
contribution offset cannot be read, so the contribution offset cannot be 
specified in the error message (and thus the absolute offset cannot be 
inferred) . Or maybe I'm misunderstanding your comment here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107456/new/

https://reviews.llvm.org/D107456

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108816: [lldb] Return all line entries matchign a line if no column is specified

2021-08-27 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh created this revision.
kimanh added reviewers: mib, JDevlieghere.
kimanh published this revision for review.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Previously, if no column was specified, ResolveSymbolContext would take
the first match returned by FindLineEntryIndexByFileIndex, and reuse it
to find subsequent exact matches. With the introduction of columns, columns
are now considered when matching the line entries.

This leads to a problem if one wants to get all existing line entries
that match that line, since now the column is also used for the exact match.
This way, all line entries are filtered out that have a different
column number, but the same line number.

This patch changes that by ignoring the column information of the first match
if the original request of ResolveSymbolContext was also ignoring it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108816

Files:
  lldb/source/Symbol/CompileUnit.cpp
  lldb/unittests/Symbol/TestLineEntry.cpp

Index: lldb/unittests/Symbol/TestLineEntry.cpp
===
--- lldb/unittests/Symbol/TestLineEntry.cpp
+++ lldb/unittests/Symbol/TestLineEntry.cpp
@@ -38,7 +38,8 @@
   void SetUp() override;
 
 protected:
-  llvm::Expected GetLineEntryForLine(uint32_t line);
+  llvm::Expected
+  GetLineEntriesForLine(uint32_t line, llvm::Optional column);
   llvm::Optional m_file;
   ModuleSP m_module_sp;
 };
@@ -50,8 +51,9 @@
   m_module_sp = std::make_shared(m_file->moduleSpec());
 }
 
-llvm::Expected LineEntryTest::GetLineEntryForLine(uint32_t line) {
   // TODO: Handle SourceLocationSpec column information
+llvm::Expected LineEntryTest::GetLineEntriesForLine(
+uint32_t line, llvm::Optional column = llvm::None) {
   SymbolContextList sc_comp_units;
   SymbolContextList sc_line_entries;
   FileSpec file_spec("inlined-functions.cpp");
@@ -62,7 +64,7 @@
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"No comp unit found on the test object.");
 
-  SourceLocationSpec location_spec(file_spec, line, /*column=*/llvm::None,
+  SourceLocationSpec location_spec(file_spec, line, column,
/*check_inlines=*/true,
/*exact_match=*/true);
 
@@ -71,33 +73,53 @@
   if (sc_line_entries.GetSize() == 0)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"No line entry found on the test object.");
-  return sc_line_entries[0].line_entry;
+  return sc_line_entries;
+}
+
+// This tests if we can get all line entries that match the passed line, if
+// no column is specified.
+TEST_F(LineEntryTest, GetAllExactLineMatchesWithoutColumn) {
+  auto sc_line_entries = GetLineEntriesForLine(12);
+  ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded());
+  ASSERT_EQ(sc_line_entries->NumLineEntriesWithLine(12), 6u);
+}
+
+// This tests if we can get exact line and column matches.
+TEST_F(LineEntryTest, GetAllExactLineColumnMatches) {
+  auto sc_line_entries = GetLineEntriesForLine(12, 39);
+  ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded());
+  ASSERT_EQ(sc_line_entries->NumLineEntriesWithLine(12), 1u);
+  auto line_entry = sc_line_entries.get()[0].line_entry;
+  ASSERT_EQ(line_entry.column, 39);
 }
 
 TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeNoInlines) {
-  auto line_entry = GetLineEntryForLine(18);
-  ASSERT_THAT_EXPECTED(line_entry, llvm::Succeeded());
+  auto sc_line_entries = GetLineEntriesForLine(18);
+  ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded());
+  auto line_entry = sc_line_entries.get()[0].line_entry;
   bool include_inlined_functions = false;
   auto range =
-  line_entry->GetSameLineContiguousAddressRange(include_inlined_functions);
+  line_entry.GetSameLineContiguousAddressRange(include_inlined_functions);
   ASSERT_EQ(range.GetByteSize(), (uint64_t)0x24);
 }
 
 TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeOneInline) {
-  auto line_entry = GetLineEntryForLine(18);
-  ASSERT_THAT_EXPECTED(line_entry, llvm::Succeeded());
+  auto sc_line_entries = GetLineEntriesForLine(18);
+  ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded());
+  auto line_entry = sc_line_entries.get()[0].line_entry;
   bool include_inlined_functions = true;
   auto range =
-  line_entry->GetSameLineContiguousAddressRange(include_inlined_functions);
+  line_entry.GetSameLineContiguousAddressRange(include_inlined_functions);
   ASSERT_EQ(range.GetByteSize(), (uint64_t)0x49);
 }
 
 TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeNestedInline) {
-  auto line_entry = GetLineEntryForLine(12);
-  ASSERT_THAT_EXPECTED(line_entry, llvm::Succeeded());
+  auto sc_line_entries = GetLineEntriesForLine(12);
+  ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded());
+  auto line_entry = sc_line_entries.get()[0].line_entry;
   bool include_inlined_functions = true;
   auto 

[Lldb-commits] [PATCH] D107456: [lldb] Support .debug_rnglists.dwo sections in dwp file

2021-08-27 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

Friendly ping!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107456/new/

https://reviews.llvm.org/D107456

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108816: [lldb] Return all line entries matchign a line if no column is specified

2021-08-30 Thread Kim-Anh Tran via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3973d8b29e24: [lldb] Return all line entries matchign a line 
if no column is specified (authored by kimanh).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108816/new/

https://reviews.llvm.org/D108816

Files:
  lldb/source/Symbol/CompileUnit.cpp
  lldb/unittests/Symbol/TestLineEntry.cpp

Index: lldb/unittests/Symbol/TestLineEntry.cpp
===
--- lldb/unittests/Symbol/TestLineEntry.cpp
+++ lldb/unittests/Symbol/TestLineEntry.cpp
@@ -38,7 +38,8 @@
   void SetUp() override;
 
 protected:
-  llvm::Expected GetLineEntryForLine(uint32_t line);
+  llvm::Expected
+  GetLineEntriesForLine(uint32_t line, llvm::Optional column);
   llvm::Optional m_file;
   ModuleSP m_module_sp;
 };
@@ -50,8 +51,9 @@
   m_module_sp = std::make_shared(m_file->moduleSpec());
 }
 
-llvm::Expected LineEntryTest::GetLineEntryForLine(uint32_t line) {
   // TODO: Handle SourceLocationSpec column information
+llvm::Expected LineEntryTest::GetLineEntriesForLine(
+uint32_t line, llvm::Optional column = llvm::None) {
   SymbolContextList sc_comp_units;
   SymbolContextList sc_line_entries;
   FileSpec file_spec("inlined-functions.cpp");
@@ -62,7 +64,7 @@
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"No comp unit found on the test object.");
 
-  SourceLocationSpec location_spec(file_spec, line, /*column=*/llvm::None,
+  SourceLocationSpec location_spec(file_spec, line, column,
/*check_inlines=*/true,
/*exact_match=*/true);
 
@@ -71,33 +73,53 @@
   if (sc_line_entries.GetSize() == 0)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"No line entry found on the test object.");
-  return sc_line_entries[0].line_entry;
+  return sc_line_entries;
+}
+
+// This tests if we can get all line entries that match the passed line, if
+// no column is specified.
+TEST_F(LineEntryTest, GetAllExactLineMatchesWithoutColumn) {
+  auto sc_line_entries = GetLineEntriesForLine(12);
+  ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded());
+  ASSERT_EQ(sc_line_entries->NumLineEntriesWithLine(12), 6u);
+}
+
+// This tests if we can get exact line and column matches.
+TEST_F(LineEntryTest, GetAllExactLineColumnMatches) {
+  auto sc_line_entries = GetLineEntriesForLine(12, 39);
+  ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded());
+  ASSERT_EQ(sc_line_entries->NumLineEntriesWithLine(12), 1u);
+  auto line_entry = sc_line_entries.get()[0].line_entry;
+  ASSERT_EQ(line_entry.column, 39);
 }
 
 TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeNoInlines) {
-  auto line_entry = GetLineEntryForLine(18);
-  ASSERT_THAT_EXPECTED(line_entry, llvm::Succeeded());
+  auto sc_line_entries = GetLineEntriesForLine(18);
+  ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded());
+  auto line_entry = sc_line_entries.get()[0].line_entry;
   bool include_inlined_functions = false;
   auto range =
-  line_entry->GetSameLineContiguousAddressRange(include_inlined_functions);
+  line_entry.GetSameLineContiguousAddressRange(include_inlined_functions);
   ASSERT_EQ(range.GetByteSize(), (uint64_t)0x24);
 }
 
 TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeOneInline) {
-  auto line_entry = GetLineEntryForLine(18);
-  ASSERT_THAT_EXPECTED(line_entry, llvm::Succeeded());
+  auto sc_line_entries = GetLineEntriesForLine(18);
+  ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded());
+  auto line_entry = sc_line_entries.get()[0].line_entry;
   bool include_inlined_functions = true;
   auto range =
-  line_entry->GetSameLineContiguousAddressRange(include_inlined_functions);
+  line_entry.GetSameLineContiguousAddressRange(include_inlined_functions);
   ASSERT_EQ(range.GetByteSize(), (uint64_t)0x49);
 }
 
 TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeNestedInline) {
-  auto line_entry = GetLineEntryForLine(12);
-  ASSERT_THAT_EXPECTED(line_entry, llvm::Succeeded());
+  auto sc_line_entries = GetLineEntriesForLine(12);
+  ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded());
+  auto line_entry = sc_line_entries.get()[0].line_entry;
   bool include_inlined_functions = true;
   auto range =
-  line_entry->GetSameLineContiguousAddressRange(include_inlined_functions);
+  line_entry.GetSameLineContiguousAddressRange(include_inlined_functions);
   ASSERT_EQ(range.GetByteSize(), (uint64_t)0x33);
 }
 
Index: lldb/source/Symbol/CompileUnit.cpp
===
--- lldb/source/Symbol/CompileUnit.cpp
+++ lldb/source/Symbol/CompileUnit.cpp
@@ -319,8 +319,13 @@
   // subsequent line exact matches below.
   const bool inlines = false;
   const bool exact = true;
- 

[Lldb-commits] [PATCH] D108816: [lldb] Return all line entries matchign a line if no column is specified

2021-08-30 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108816/new/

https://reviews.llvm.org/D108816

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D107456: [lldb] Support .debug_rnglists.dwo sections in dwp file

2021-08-30 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh updated this revision to Diff 369547.
kimanh added a comment.

- Updating error messages


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107456/new/

https://reviews.llvm.org/D107456

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s
@@ -0,0 +1,187 @@
+## This tests if .debug_rnglists.dwo are correctly read if they are part
+## of a dwp file.
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym MAIN=0 > %t
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t.dwp
+# RUN: %lldb %t -o "image lookup -v -s lookup_rnglists" -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_rnglists
+# CHECK:  Function: id = {{.*}}, name = "rnglists", range = [0x-0x0003)
+# CHECK:Blocks: id = {{.*}}, range = [0x-0x0003)
+# CHECK-NEXT:   id = {{.*}}, range = [0x0001-0x0002)
+
+.text
+rnglists:
+nop
+.Lblock1_begin:
+lookup_rnglists:
+nop
+.Lblock1_end:
+nop
+.Lrnglists_end:
+
+## The main file.
+.ifdef MAIN
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   0   # DW_CHILDREN_no
+.byte   0x76# DW_AT_dwo_name
+.byte   8   # DW_FORM_string
+.byte   115 # DW_AT_addr_base
+.byte   23  # DW_FORM_sec_offset
+.byte   85  # DW_AT_ranges
+.byte   35  # DW_FORM_rnglistx
+.byte   116 # DW_AT_rnglists_base
+.byte   23  # DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+.short  5   # DWARF version number
+.byte   4   # DWARF Unit Type
+.byte   8   # Address Size (in bytes)
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.quad   1026699901672188186 # DWO id
+.byte   1   # Abbrev [1] DW_TAG_compile_unit
+.asciz  "debug_rnglists-dwp.s.tmp.dwo"  # DW_AT_dwo_name
+.long   .Laddr_table_base0  # DW_AT_addr_base
+.byte   0   # DW_AT_ranges
+.long   .Lskel_rnglists_table_base # DW_AT_rnglists_base
+.Ldebug_info_end0:
+
+.section.debug_addr,"",@progbits
+.long   .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+.short  5   # DWARF version number
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.Laddr_table_base0:
+.quad   rnglists
+.quad   .Lblock1_begin
+.Ldebug_addr_end0:
+
+.section.debug_rnglists,"",@progbits
+.long   .Lskel_rnglist_table_end-.Lskel_rnglist_table_start # Length
+.Lskel_rnglist_table_start:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   1   # Offset entry count
+.Lskel_rnglists_table_base:
+.long   .Lskel_ranges0-.Lskel_rnglists_table_base
+.Lskel_ranges0:
+.byte   7   # DW_RLE_start_length
+.quad   rnglists
+.uleb128   .Lrnglists_end-rnglists
+.byte   0   # DW_RLE_end_of_list
+.Lskel_rnglist_table_end:
+ .else
+ ## DWP file starts here.
+.section.debug_abbrev.dwo,"e",@progbits
+.LAbbrevBegin:
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   46  # DW_TAG_subprogram
+.byte   1   # DW_CHILDREN_y

[Lldb-commits] [PATCH] D107456: [lldb] Support .debug_rnglists.dwo sections in dwp file

2021-08-30 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:556
+  " (ranges list base: 0x%" PRIx64 "): %s",
+  offset, m_ranges_base, toString(table_or_error.takeError()).c_str());
   }

jankratochvil wrote:
> kimanh wrote:
> > jankratochvil wrote:
> > > One such reason can be missing DWP absolute offset for the error report. 
> > > That could be returned from `GetRnglistData()`.
> > > 
> > If I understand your comment correctly, you are suggesting to incorporate 
> > the contribution offset into the error message of `GetRnglistData`, is that 
> > correct? However, `GetRnglistData` will only return an error message if the 
> > contribution offset cannot be read, so the contribution offset cannot be 
> > specified in the error message (and thus the absolute offset cannot be 
> > inferred) . Or maybe I'm misunderstanding your comment here?
> Not so correct. The callers of `GetRnglistData` need to know the contribution 
> offset to properly report it during parsing errors in the callers. 
> `GetRnglistTable` can report error if `extractHeaderAndOffsets` finds invalid 
> header data. In such case LLDB will report (with 
> https://www.jankratochvil.net/t/debug_rnglists-dwp.s.patch):
> ```
> error: debug_rnglists-dwp.s.tmp Failed to extract range list table at offset 
> 0xc: parsing .debug_rnglists table at offset 0x0: unsupported reserved unit 
> length of value 0xfff0
> ```
> And one has no idea which DWO in that DWP file was invalid, that `0xc` is 
> relative to start of contribution, not to start of the `.debug_rnglists.dwo` 
> section. `GetRnglistData` knows the contribution offset but its caller 
> `DWARFDebugRnglistTable` does not.
> I am not sure how perfect the error messages should be so giving an approval 
> (if I am authorized to give one) but it would be nice to improve the error 
> reporting.
> 
Ahh, okay, thanks a lot for the clarification! I updated a patch to address the 
error message. Please take a look if the updated patch is what you'd like to 
see.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107456/new/

https://reviews.llvm.org/D107456

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D107456: [lldb] Support .debug_rnglists.dwo sections in dwp file

2021-09-03 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh updated this revision to Diff 370562.
kimanh added a comment.

- splitting up new code (for error handling) into a different CL
- keep code that was already accepted


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107456/new/

https://reviews.llvm.org/D107456

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s
@@ -0,0 +1,187 @@
+## This tests if .debug_rnglists.dwo are correctly read if they are part
+## of a dwp file.
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym MAIN=0 > %t
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t.dwp
+# RUN: %lldb %t -o "image lookup -v -s lookup_rnglists" -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_rnglists
+# CHECK:  Function: id = {{.*}}, name = "rnglists", range = [0x-0x0003)
+# CHECK:Blocks: id = {{.*}}, range = [0x-0x0003)
+# CHECK-NEXT:   id = {{.*}}, range = [0x0001-0x0002)
+
+.text
+rnglists:
+nop
+.Lblock1_begin:
+lookup_rnglists:
+nop
+.Lblock1_end:
+nop
+.Lrnglists_end:
+
+## The main file.
+.ifdef MAIN
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   0   # DW_CHILDREN_no
+.byte   0x76# DW_AT_dwo_name
+.byte   8   # DW_FORM_string
+.byte   115 # DW_AT_addr_base
+.byte   23  # DW_FORM_sec_offset
+.byte   85  # DW_AT_ranges
+.byte   35  # DW_FORM_rnglistx
+.byte   116 # DW_AT_rnglists_base
+.byte   23  # DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+.short  5   # DWARF version number
+.byte   4   # DWARF Unit Type
+.byte   8   # Address Size (in bytes)
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.quad   1026699901672188186 # DWO id
+.byte   1   # Abbrev [1] DW_TAG_compile_unit
+.asciz  "debug_rnglists-dwp.s.tmp.dwo"  # DW_AT_dwo_name
+.long   .Laddr_table_base0  # DW_AT_addr_base
+.byte   0   # DW_AT_ranges
+.long   .Lskel_rnglists_table_base # DW_AT_rnglists_base
+.Ldebug_info_end0:
+
+.section.debug_addr,"",@progbits
+.long   .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+.short  5   # DWARF version number
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.Laddr_table_base0:
+.quad   rnglists
+.quad   .Lblock1_begin
+.Ldebug_addr_end0:
+
+.section.debug_rnglists,"",@progbits
+.long   .Lskel_rnglist_table_end-.Lskel_rnglist_table_start # Length
+.Lskel_rnglist_table_start:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   1   # Offset entry count
+.Lskel_rnglists_table_base:
+.long   .Lskel_ranges0-.Lskel_rnglists_table_base
+.Lskel_ranges0:
+.byte   7   # DW_RLE_start_length
+.quad   rnglists
+.uleb128   .Lrnglists_end-rnglists
+.byte   0   # DW_RLE_end_of_list
+.Lskel_rnglist_table_end:
+ .else
+ ## DWP file starts here.
+.section.debug_abbrev.dwo,"e",@progbits
+.LAbbrevBegin:
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   46  # DW_TAG_subprogram
+.byte   1   # DW_C

[Lldb-commits] [PATCH] D109231: [lldb] Improve error handling around GetRngListData()

2021-09-03 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh created this revision.
kimanh added a reviewer: jankratochvil.
kimanh published this revision for review.
kimanh added a comment.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

I've split up the other CL (https://reviews.llvm.org/D107456) into the part 
that was reviewed, and this: the error handling that was requested on that CL. 
Please take a look whenever you have time!


This adds more informative error handling around the
usage of GetRngListData.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109231

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s

Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
===
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
@@ -29,7 +29,7 @@
 # RUN:   -o exit 2>&1 | FileCheck --check-prefix=RNGLISTBASE %s
 
 # RNGLISTBASE-LABEL: image lookup -v -s lookup_rnglists
-# RNGLISTBASE: error: {{.*}}-rnglistbase {0x0043}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 24), please file a bug and attach the file at the start of this error message
+# RNGLISTBASE: error: DW_AT_range-DW_FORM_sec_offset.s.tmp-rnglistbase {0x0043}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 24, offset to range list table is 0x18), please file a bug and attach the file at the start of this error message
 
 .text
 rnglists:
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -286,7 +286,7 @@
 
   const llvm::Optional &GetRnglistTable();
 
-  lldb_private::DWARFDataExtractor GetRnglistData() const;
+  lldb_private::DWARFDataExtractor GetRnglistData(uint32_t &Offset) const;
 
   SymbolFileDWARF &m_dwarf;
   std::shared_ptr m_dwo;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -513,14 +513,16 @@
   return data;
 }
 
-DWARFDataExtractor DWARFUnit::GetRnglistData() const {
+DWARFDataExtractor DWARFUnit::GetRnglistData(uint32_t &Offset) const {
   DWARFContext &Ctx = GetSymbolFileDWARF().GetDWARFContext();
   const DWARFDataExtractor &data = Ctx.getOrLoadRngListsData();
   if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
 if (const auto *contribution =
-entry->getContribution(llvm::DW_SECT_RNGLISTS))
+entry->getContribution(llvm::DW_SECT_RNGLISTS)) {
+  Offset = contribution->Offset;
   return DWARFDataExtractor(data, contribution->Offset,
 contribution->Length);
+}
 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
 "Failed to find range list contribution for CU with signature "
 "0x%" PRIx64,
@@ -541,14 +543,18 @@
 DWARFUnit::GetRnglistTable() {
   if (GetVersion() >= 5 && !m_rnglist_table_done) {
 m_rnglist_table_done = true;
+uint32_t contribution_off;
 if (auto table_or_error =
 ParseListTableHeader(
-GetRnglistData().GetAsLLVM(), m_ranges_base, DWARF32))
+GetRnglistData(contribution_off).GetAsLLVM(), m_ranges_base,
+DWARF32))
   m_rnglist_table = std::move(table_or_error.get());
 else
   GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-  "Failed to extract range list table at offset 0x%" PRIx64 ": %s",
-  m_ranges_base, toString(table_or_error.takeError()).c_str());
+  "Failed to extract range list table at offset 0x%" PRIx64
+  " (DW_AT_rnglists_base is %" PRIu64 "): %s",
+  m_ranges_base + contribution_off, m_ranges_base,
+  toString(table_or_error.takeError()).c_str());
   }
   return m_rnglist_table;
 }
@@ -563,14 +569,17 @@
"DW_FORM_rnglistx cannot be used without "
"DW_AT_rnglists_base for CU at 0x%8.8x",
GetOffset());
+  uint32_t contribution_off;
   if (llvm::Optional off = GetRnglistTable()->getOffsetEntry(
-  GetRnglistData().GetAsLLVM(), Index))
+  GetRnglistData(contribution_off).GetAsLLVM(), Index))
 return *off + m_ranges_base;
   return llvm::createStringError(
   errc::invalid_argument,
   "invalid range list table in

[Lldb-commits] [PATCH] D107456: [lldb] Support .debug_rnglists.dwo sections in dwp file

2021-09-03 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

I've split up the code that addresses the .debug_rnglists from the code that 
takes care of better error handling (https://reviews.llvm.org/D109231). I'll 
commit the reviewed part (this).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107456/new/

https://reviews.llvm.org/D107456

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D107456: [lldb] Support .debug_rnglists.dwo sections in dwp file

2021-09-03 Thread Kim-Anh Tran via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGec671f3ea00b: [lldb] Support .debug_rnglists.dwo sections in 
dwp file (authored by kimanh).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107456/new/

https://reviews.llvm.org/D107456

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s
@@ -0,0 +1,187 @@
+## This tests if .debug_rnglists.dwo are correctly read if they are part
+## of a dwp file.
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym MAIN=0 > %t
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t.dwp
+# RUN: %lldb %t -o "image lookup -v -s lookup_rnglists" -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_rnglists
+# CHECK:  Function: id = {{.*}}, name = "rnglists", range = [0x-0x0003)
+# CHECK:Blocks: id = {{.*}}, range = [0x-0x0003)
+# CHECK-NEXT:   id = {{.*}}, range = [0x0001-0x0002)
+
+.text
+rnglists:
+nop
+.Lblock1_begin:
+lookup_rnglists:
+nop
+.Lblock1_end:
+nop
+.Lrnglists_end:
+
+## The main file.
+.ifdef MAIN
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   0   # DW_CHILDREN_no
+.byte   0x76# DW_AT_dwo_name
+.byte   8   # DW_FORM_string
+.byte   115 # DW_AT_addr_base
+.byte   23  # DW_FORM_sec_offset
+.byte   85  # DW_AT_ranges
+.byte   35  # DW_FORM_rnglistx
+.byte   116 # DW_AT_rnglists_base
+.byte   23  # DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+.section.debug_info,"",@progbits
+.Lcu_begin0:
+.long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+.short  5   # DWARF version number
+.byte   4   # DWARF Unit Type
+.byte   8   # Address Size (in bytes)
+.long   .debug_abbrev   # Offset Into Abbrev. Section
+.quad   1026699901672188186 # DWO id
+.byte   1   # Abbrev [1] DW_TAG_compile_unit
+.asciz  "debug_rnglists-dwp.s.tmp.dwo"  # DW_AT_dwo_name
+.long   .Laddr_table_base0  # DW_AT_addr_base
+.byte   0   # DW_AT_ranges
+.long   .Lskel_rnglists_table_base # DW_AT_rnglists_base
+.Ldebug_info_end0:
+
+.section.debug_addr,"",@progbits
+.long   .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+.short  5   # DWARF version number
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.Laddr_table_base0:
+.quad   rnglists
+.quad   .Lblock1_begin
+.Ldebug_addr_end0:
+
+.section.debug_rnglists,"",@progbits
+.long   .Lskel_rnglist_table_end-.Lskel_rnglist_table_start # Length
+.Lskel_rnglist_table_start:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   1   # Offset entry count
+.Lskel_rnglists_table_base:
+.long   .Lskel_ranges0-.Lskel_rnglists_table_base
+.Lskel_ranges0:
+.byte   7   # DW_RLE_start_length
+.quad   rnglists
+.uleb128   .Lrnglists_end-rnglists
+.byte   0   # DW_RLE_end_of_list
+.Lskel_rnglist_table_end:
+ .else
+ ## DWP file starts here.
+.section.debug_abbrev.dwo,"e",@progbits
+.LAbbrevBegin:
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   46 

[Lldb-commits] [PATCH] D98619: [lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF

2021-03-14 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh created this revision.
kimanh added reviewers: labath, jasonmolenda.
kimanh added a project: LLDB.
Herald added subscribers: JDevlieghere, arphaman.
kimanh requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, sstefan1.

SymbolFileDWARF::ResolveSymbolContext is currently unaware that in DWARF5 the 
primary file is specified at file index 0. As a result it misses to correctly 
resolve the symbol context for the primary file when DWARF5 debug data is used 
and the primary file is only specified at index 0.

This change makes use of CompileUnit::ResolveSymbolContext to resolve the 
symbol context. The ResolveSymbolContext in CompileUnit has been previously 
already updated to reflect changes in DWARF5
and contains a more readable version. It can resolve more, but will also do a 
bit more work than
SymbolFileDWARF::ResolveSymbolContext (getting the Module, and going through 
SymbolFileDWARF::ResolveSymbolContextForAddress), however, it's mostly directed 
by $resolve_scope
what will be resolved, and ensures that code is easier to maintain if there's 
only one path.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98619

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Symbol/CompileUnit.cpp
  lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s

Index: lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
@@ -0,0 +1,134 @@
+# Test handling of DWARF5 file index 0.
+
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -o %t -triple x86_64-pc-linux %s
+# RUN: %lldb %t -o "image lookup -f hello.c -l 1" \
+# RUN:   -o exit | FileCheck %s
+
+# CHECK: 2 matches found in hello.c:1
+	.text
+.Lfunc_begin0:
+	.file	0 "." "hello.c"
+	.loc	0 1 0   # hello.c:1:0
+		nop
+	.loc	0 1 13 prologue_end # hello.c:1:13
+		nop
+.Lfunc_end0:
+	.section	.debug_abbrev,"",@progbits
+	.byte	1   # Abbreviation Code
+	.byte	17  # DW_TAG_compile_unit
+	.byte	1   # DW_CHILDREN_yes
+	.byte	37  # DW_AT_producer
+	.byte	37  # DW_FORM_strx1
+	.byte	19  # DW_AT_language
+	.byte	5   # DW_FORM_data2
+	.byte	3   # DW_AT_name
+	.byte	37  # DW_FORM_strx1
+	.byte	114 # DW_AT_str_offsets_base
+	.byte	23  # DW_FORM_sec_offset
+	.byte	16  # DW_AT_stmt_list
+	.byte	23  # DW_FORM_sec_offset
+	.byte	27  # DW_AT_comp_dir
+	.byte	37  # DW_FORM_strx1
+	.byte	17  # DW_AT_low_pc
+	.byte	27  # DW_FORM_addrx
+	.byte	18  # DW_AT_high_pc
+	.byte	6   # DW_FORM_data4
+	.byte	115 # DW_AT_addr_base
+	.byte	23  # DW_FORM_sec_offset
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	2   # Abbreviation Code
+	.byte	46  # DW_TAG_subprogram
+	.byte	0   # DW_CHILDREN_no
+	.byte	17  # DW_AT_low_pc
+	.byte	27  # DW_FORM_addrx
+	.byte	18  # DW_AT_high_pc
+	.byte	6   # DW_FORM_data4
+	.byte	64  # DW_AT_frame_base
+	.byte	24  # DW_FORM_exprloc
+	.byte	3   # DW_AT_name
+	.byte	37  # DW_FORM_strx1
+	.byte	58  # DW_AT_decl_file
+	.byte	11  # DW_FORM_data1
+	.byte	59  # DW_AT_decl_line
+	.byte	11  # DW_FORM_data1
+	.byte	73  # DW_AT_type
+	.byte	19  # DW_FORM_ref4
+	.byte	63  # DW_AT_external
+	.byte	25  # DW_FORM_flag_present
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	3   # Abbreviation Code
+	.byte	36  # DW_TAG_base_type
+	.byte	0   # DW_CHILDREN_no
+	.byte	3   # DW_AT_name
+	.byte	37  # DW_FORM_strx1
+	.byte	62  # DW_AT_encoding
+	.byte	11  # DW_FORM_data1
+	.byte	11 

[Lldb-commits] [PATCH] D98619: [lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF

2021-03-18 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh updated this revision to Diff 331547.
kimanh added a comment.

Removing subprogram and base_type tags (as they are not needed for the test)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98619/new/

https://reviews.llvm.org/D98619

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Symbol/CompileUnit.cpp
  lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s

Index: lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
@@ -0,0 +1,119 @@
+# Test handling of DWARF5 file index 0.
+
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -o %t -triple x86_64-pc-linux %s
+# RUN: %lldb %t -o "image lookup -f hello.c -l 1" \
+# RUN:   -o exit | FileCheck %s
+
+# CHECK: 2 matches found in hello.c:1
+	.text
+.Lfunc_begin0:
+	.file	0 "." "hello.c"
+	.loc	0 1 0   # hello.c:1:0
+		nop
+	.loc	0 1 13 prologue_end # hello.c:1:13
+		nop
+.Lfunc_end0:
+	.section	.debug_abbrev,"",@progbits
+	.byte	1   # Abbreviation Code
+	.byte	17  # DW_TAG_compile_unit
+	.byte	1   # DW_CHILDREN_yes
+	.byte	37  # DW_AT_producer
+	.byte	37  # DW_FORM_strx1
+	.byte	19  # DW_AT_language
+	.byte	5   # DW_FORM_data2
+	.byte	3   # DW_AT_name
+	.byte	37  # DW_FORM_strx1
+	.byte	114 # DW_AT_str_offsets_base
+	.byte	23  # DW_FORM_sec_offset
+	.byte	16  # DW_AT_stmt_list
+	.byte	23  # DW_FORM_sec_offset
+	.byte	27  # DW_AT_comp_dir
+	.byte	37  # DW_FORM_strx1
+	.byte	17  # DW_AT_low_pc
+	.byte	27  # DW_FORM_addrx
+	.byte	18  # DW_AT_high_pc
+	.byte	6   # DW_FORM_data4
+	.byte	115 # DW_AT_addr_base
+	.byte	23  # DW_FORM_sec_offset
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	2   # Abbreviation Code
+	.byte	46  # DW_TAG_subprogram
+	.byte	0   # DW_CHILDREN_no
+	.byte	17  # DW_AT_low_pc
+	.byte	27  # DW_FORM_addrx
+	.byte	18  # DW_AT_high_pc
+	.byte	6   # DW_FORM_data4
+	.byte	64  # DW_AT_frame_base
+	.byte	24  # DW_FORM_exprloc
+	.byte	3   # DW_AT_name
+	.byte	37  # DW_FORM_strx1
+	.byte	58  # DW_AT_decl_file
+	.byte	11  # DW_FORM_data1
+	.byte	59  # DW_AT_decl_line
+	.byte	11  # DW_FORM_data1
+	.byte	73  # DW_AT_type
+	.byte	19  # DW_FORM_ref4
+	.byte	63  # DW_AT_external
+	.byte	25  # DW_FORM_flag_present
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	3   # Abbreviation Code
+	.byte	36  # DW_TAG_base_type
+	.byte	0   # DW_CHILDREN_no
+	.byte	3   # DW_AT_name
+	.byte	37  # DW_FORM_strx1
+	.byte	62  # DW_AT_encoding
+	.byte	11  # DW_FORM_data1
+	.byte	11  # DW_AT_byte_size
+	.byte	11  # DW_FORM_data1
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	0   # EOM(3)
+	.section	.debug_info,"",@progbits
+.Lcu_begin0:
+	.long	.Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+	.short	5   # DWARF version number
+	.byte	1   # DWARF Unit Type
+	.byte	8   # Address Size (in bytes)
+	.long	.debug_abbrev   # Offset Into Abbrev. Section
+	.byte	1   # Abbrev [1] 0xc:0x2b DW_TAG_compile_unit
+	.byte	0   # DW_AT_producer
+	.short	12  # DW_AT_language
+	.byte	1   # DW_AT_name
+	.long	.Lstr_offsets_base0 # DW_AT_str_offsets_base
+	.long	.

[Lldb-commits] [PATCH] D98619: [lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF

2021-03-18 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh marked an inline comment as done.
kimanh added a comment.

Thanks a lot for the review Pavel! I've updated the test. If it looks fine like 
this, could you help me to commit this change?




Comment at: lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s:98
+   .byte   86
+   .byte   3   # DW_AT_name
+   .byte   0   # DW_AT_decl_file

labath wrote:
> I was puzzled by this line as the string 3 is nowhere to be found. I take it 
> this was manually reduced? If so, I think you should be able to delete the 
> entire subprogram and base_type tags (and the relevant abbreviations), as 
> that is not necessary for the line tables to work.
Thanks for the guidance here! Yes, that's correct, I've manually reduced it but 
wasn't sure what else I could safely remove. I've now removed the subprogram 
parts, and the base_type tags. Hope that looks better now!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98619/new/

https://reviews.llvm.org/D98619

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D98619: [lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF

2021-03-22 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh marked an inline comment as done.
kimanh added a comment.

Unfortunately the test seems to run and fail on the ARM. I thoughty adding 
REQUIRES: x85 would skip no x86 ones, but maybe I did something wrong.




Comment at: lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s:3
+
+# REQUIRES: x86
+

I can see that my CL is failing on the ARM. From looking at the other tests I 
thought this line would prevent it from running on the ARM, but apparently it 
doesn't. How can I fix this?

https://lab.llvm.org/buildbot/#/builders/17/builds/5500


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98619/new/

https://reviews.llvm.org/D98619

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D98619: [lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF

2021-03-22 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

Thanks for having a look, and for the explanation! Please let me know if I can 
do anything to help debugging this!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98619/new/

https://reviews.llvm.org/D98619

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D98619: [lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF

2021-03-22 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

It seems as if it's the same for windows (I don't have windows unfortunately to 
check):

https://lab.llvm.org/buildbot/#/builders/83/builds/4884


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98619/new/

https://reviews.llvm.org/D98619

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D98619: [lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF

2021-03-22 Thread Kim-Anh Tran via Phabricator via lldb-commits
kimanh added a comment.

I'm very sorry for the incorrect reduction, and thanks for fixing this!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98619/new/

https://reviews.llvm.org/D98619

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits