[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.

2018-09-23 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg, aprantl, dblaikie, probinson.
Herald added a subscriber: JDevlieghere.

DWARF5 spec describes single file split dwarf case (when .dwo sections are in 
the .o files).

Problem is that LLDB does not work correctly in that case. The issue is that, 
for example, both .debug_info and .debug_info.dwo
has the same type: `eSectionTypeDWARFDebugInfo`. And when code searches section 
by type it might find the regular debug section
and not the .dwo one. It seems can be easily fixed though, patch shows the fix 
I am suggesting.

Note that currently, clang is unable to produce such output, the patch is on 
review atm: https://reviews.llvm.org/D52296.
It is still would be possible to use assembler to produce such files though.
But the test case refers to the flag from the review mentioned.


https://reviews.llvm.org/D52403

Files:
  include/lldb/Core/Section.h
  
packages/Python/lldbsuite/test/functionalities/single-file-split-dwarf/TestSingleFileSplitDwarf.py
  
packages/Python/lldbsuite/test/functionalities/single-file-split-dwarf/test.o.yaml
  
packages/Python/lldbsuite/test/functionalities/single-file-split-dwarf/test.yaml
  source/Core/Section.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -32,7 +32,8 @@
   const SectionList *section_list =
   m_obj_file->GetSectionList(false /* update_module_section_list */);
   if (section_list) {
-SectionSP section_sp(section_list->FindSectionByType(sect_type, true));
+SectionSP section_sp(section_list->FindSectionByType(
+sect_type, true, 0 /*start_idx*/, true /*onlyDwo*/));
 if (section_sp) {
   // See if we memory mapped the DWARF segment?
   if (m_dwarf_data.GetByteSize()) {
@@ -63,11 +64,12 @@
 DWARFUnit *SymbolFileDWARFDwo::GetCompileUnit() {
   // A clang module is found via a skeleton CU, but is not a proper DWO.
   // Clang modules have a .debug_info section instead of the *_dwo variant.
-  if (auto *section_list = m_obj_file->GetSectionList(false))
-if (auto section_sp =
-section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true))
-  if (!section_sp->GetName().GetStringRef().endswith("dwo"))
-return nullptr;
+  if (auto *section_list = m_obj_file->GetSectionList(false)) {
+auto section_sp = section_list->FindSectionByType(
+eSectionTypeDWARFDebugInfo, true, 0 /*start_idx*/, true /*onlyDwo*/);
+if (!section_sp)
+  return nullptr;
+  }
 
   // Only dwo files with 1 compile unit is supported
   if (GetNumCompileUnits() == 1)
Index: source/Core/Section.cpp
===
--- source/Core/Section.cpp
+++ source/Core/Section.cpp
@@ -536,12 +536,15 @@
 }
 
 SectionSP SectionList::FindSectionByType(SectionType sect_type,
- bool check_children,
- size_t start_idx) const {
+ bool check_children, size_t start_idx,
+ bool onlyDwo) const {
   SectionSP sect_sp;
   size_t num_sections = m_sections.size();
   for (size_t idx = start_idx; idx < num_sections; ++idx) {
 if (m_sections[idx]->GetType() == sect_type) {
+  if (onlyDwo && !m_sections[idx]->GetName().GetStringRef().endswith("dwo"))
+continue;
+
   sect_sp = m_sections[idx];
   break;
 } else if (check_children) {
Index: packages/Python/lldbsuite/test/functionalities/single-file-split-dwarf/test.yaml
===
--- packages/Python/lldbsuite/test/functionalities/single-file-split-dwarf/test.yaml
+++ packages/Python/lldbsuite/test/functionalities/single-file-split-dwarf/test.yaml
@@ -0,0 +1,61 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x00400440
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00400440
+AddressAlign:0x0010
+Content: 31ED4989D15E4889E24883E4F0505449C7C0B005400048C7C14005400048C7C720054000E8B7FFF4660F1F4455B820204000483D202040004889E57417B84885C0740D5DBF20204000FFE00F1F445DC3660F1F44BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B84885C0740B5DBF20204000FFE00F1F005DC3660F1F44803D391B007517554889E5E87EFFC605271B015DC30F1F44F3C30F1F4000662E0F1F8400554889E55DEB89660F1F8400554889E531C0C745FC5DC390554889E55DC3662E0F1F8400415741

[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.

2018-09-25 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

Thanks for all the comments!

In https://reviews.llvm.org/D52403#1243127, @clayborg wrote:

> So the main questions is: do we need a new section enum called 
> eSectionTypeDWARFDebugInfoDWO? If so, then this patch changes. I think I 
> would prefer adding a new enum.


Yeah, that is what I thought at the first place too. I found that when code 
looks for some section, it seems sometimes assumes it can find .dwo section by 
regular section enum value.
I thought that time that much more changes might be required (for example, 
introducing enum values for each .dwo section and perhaps fixing callers)
and so selected the simplest solution (this patch), because original code 
already used filtering by section name "dwo" suffix.

I'll try to investigate it again, want to check a few ideas I have in mind.


https://reviews.llvm.org/D52403



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


[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.

2018-09-27 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 167287.
grimar added a comment.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

- Addressed review comments.


https://reviews.llvm.org/D52403

Files:
  include/lldb/lldb-enumerations.h
  lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
  lit/Breakpoint/Inputs/single-file-split-dwarf.yaml
  lit/Breakpoint/single-file-split-dwarf.test
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -344,11 +344,13 @@
 return AddressClass::eData;
   case eSectionTypeDebug:
   case eSectionTypeDWARFDebugAbbrev:
+  case eSectionTypeDWARFDebugAbbrevDwo:
   case eSectionTypeDWARFDebugAddr:
   case eSectionTypeDWARFDebugAranges:
   case eSectionTypeDWARFDebugCuIndex:
   case eSectionTypeDWARFDebugFrame:
   case eSectionTypeDWARFDebugInfo:
+  case eSectionTypeDWARFDebugInfoDwo:
   case eSectionTypeDWARFDebugLine:
   case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
@@ -359,7 +361,9 @@
   case eSectionTypeDWARFDebugPubTypes:
   case eSectionTypeDWARFDebugRanges:
   case eSectionTypeDWARFDebugStr:
+  case eSectionTypeDWARFDebugStrDwo:
   case eSectionTypeDWARFDebugStrOffsets:
+  case eSectionTypeDWARFDebugStrOffsetsDwo:
   case eSectionTypeDWARFDebugTypes:
   case eSectionTypeDWARFAppleNames:
   case eSectionTypeDWARFAppleTypes:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -50,6 +50,12 @@
 
   DWARFUnit *GetBaseCompileUnit() override;
 
+  const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_info_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_str_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override;
+
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
lldb_private::DWARFDataExtractor &data) override;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -61,14 +61,6 @@
 }
 
 DWARFUnit *SymbolFileDWARFDwo::GetCompileUnit() {
-  // A clang module is found via a skeleton CU, but is not a proper DWO.
-  // Clang modules have a .debug_info section instead of the *_dwo variant.
-  if (auto *section_list = m_obj_file->GetSectionList(false))
-if (auto section_sp =
-section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true))
-  if (!section_sp->GetName().GetStringRef().endswith("dwo"))
-return nullptr;
-
   // Only dwo files with 1 compile unit is supported
   if (GetNumCompileUnits() == 1)
 return DebugInfo()->GetCompileUnitAtIndex(0);
@@ -126,6 +118,37 @@
   return m_base_dwarf_cu;
 }
 
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_abbrev_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugAbbrevDwo,
+  m_data_debug_abbrev);
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() {
+  // For single file split dwarf case (when we have .dwo sections in a .o),
+  // we do not want to use the .debug_addr section from .o file,
+  // but want to get one from the final executable.
+  // For regular split debug case, .dwo file does not contain the
+  // .debug_addr, so we would always fall back to such lookup anyways.
+  llvm::call_once(m_data_debug_addr.m_flag, [this] {
+SymbolFileDWARF::LoadSectionData(eSectionTypeDWARFDebugAddr,
+ std::ref(m_data_debug_addr.m_data));
+  });
+  return m_data_debug_addr.m_data;
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, m_data_debug_info);
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugStrDwo, m_data_debug_str);
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_offsets_data() {
+  return GetCachedSectionData(eSectionTypeDWARFD

[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.

2018-09-28 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: include/lldb/lldb-enumerations.h:643-660
+  eSectionTypeDWARFDebugAbbrevDwo,
   eSectionTypeDWARFDebugAddr,
   eSectionTypeDWARFDebugAranges,
   eSectionTypeDWARFDebugCuIndex,
   eSectionTypeDWARFDebugFrame,
   eSectionTypeDWARFDebugInfo,
+  eSectionTypeDWARFDebugInfoDwo,

clayborg wrote:
> Add all of these to the end of this enum for API stability since this is a 
> public header used in the API. If an older binary runs against a newer 
> liblldb.so, all of these enums will be off.
Done.



Comment at: source/Symbol/ObjectFile.cpp:347
   case eSectionTypeDWARFDebugAbbrev:
+  case eSectionTypeDWARFDebugAbbrevDwo:
   case eSectionTypeDWARFDebugAddr:

clayborg wrote:
> Check for other ObjectFile subclasses that override this function. I believe 
> ObjectFileMachO does.
Yes, and my patch already has the change for ObjectFileMachO :)
All other classes are fine too I think.


https://reviews.llvm.org/D52403



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


[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.

2018-09-28 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 167440.
grimar marked an inline comment as done.
grimar added a comment.

- Addressed review comments.


https://reviews.llvm.org/D52403

Files:
  include/lldb/lldb-enumerations.h
  lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
  lit/Breakpoint/Inputs/single-file-split-dwarf.yaml
  lit/Breakpoint/single-file-split-dwarf.test
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -344,11 +344,13 @@
 return AddressClass::eData;
   case eSectionTypeDebug:
   case eSectionTypeDWARFDebugAbbrev:
+  case eSectionTypeDWARFDebugAbbrevDwo:
   case eSectionTypeDWARFDebugAddr:
   case eSectionTypeDWARFDebugAranges:
   case eSectionTypeDWARFDebugCuIndex:
   case eSectionTypeDWARFDebugFrame:
   case eSectionTypeDWARFDebugInfo:
+  case eSectionTypeDWARFDebugInfoDwo:
   case eSectionTypeDWARFDebugLine:
   case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
@@ -359,7 +361,9 @@
   case eSectionTypeDWARFDebugPubTypes:
   case eSectionTypeDWARFDebugRanges:
   case eSectionTypeDWARFDebugStr:
+  case eSectionTypeDWARFDebugStrDwo:
   case eSectionTypeDWARFDebugStrOffsets:
+  case eSectionTypeDWARFDebugStrOffsetsDwo:
   case eSectionTypeDWARFDebugTypes:
   case eSectionTypeDWARFAppleNames:
   case eSectionTypeDWARFAppleTypes:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -50,6 +50,12 @@
 
   DWARFUnit *GetBaseCompileUnit() override;
 
+  const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_info_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_str_data() override;
+  const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override;
+
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
lldb_private::DWARFDataExtractor &data) override;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -61,14 +61,6 @@
 }
 
 DWARFUnit *SymbolFileDWARFDwo::GetCompileUnit() {
-  // A clang module is found via a skeleton CU, but is not a proper DWO.
-  // Clang modules have a .debug_info section instead of the *_dwo variant.
-  if (auto *section_list = m_obj_file->GetSectionList(false))
-if (auto section_sp =
-section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true))
-  if (!section_sp->GetName().GetStringRef().endswith("dwo"))
-return nullptr;
-
   // Only dwo files with 1 compile unit is supported
   if (GetNumCompileUnits() == 1)
 return DebugInfo()->GetCompileUnitAtIndex(0);
@@ -126,6 +118,37 @@
   return m_base_dwarf_cu;
 }
 
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_abbrev_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugAbbrevDwo,
+  m_data_debug_abbrev);
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() {
+  // For single file split dwarf case (when we have .dwo sections in a .o),
+  // we do not want to use the .debug_addr section from .o file,
+  // but want to get one from the final executable.
+  // For regular split debug case, .dwo file does not contain the
+  // .debug_addr, so we would always fall back to such lookup anyways.
+  llvm::call_once(m_data_debug_addr.m_flag, [this] {
+SymbolFileDWARF::LoadSectionData(eSectionTypeDWARFDebugAddr,
+ std::ref(m_data_debug_addr.m_data));
+  });
+  return m_data_debug_addr.m_data;
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, m_data_debug_info);
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugStrDwo, m_data_debug_str);
+}
+
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_offsets_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugStrOffsetsDwo,
+  

[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.

2018-09-28 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

Thanks for the review! It still depends on -gsingle-file-split-dwarf 
(https://reviews.llvm.org/D52403), I'll wait for it some time.
It should be possible to rewrite the comment in the test case to avoid 
mentioning the flag, but I would prefer to use it.


https://reviews.llvm.org/D52403



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


[Lldb-commits] [PATCH] D52689: [LLDB] - Add support for DW_FORM_implicit_const.

2018-09-29 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg.
Herald added subscribers: JDevlieghere, aprantl.

LLDB does not support this DWARF5 form atm.
At least gcc emits it in some cases when doing optimization
for abbreviations.

As far I can tell, clang does not support it yet, though
the rest LLVM code already knows about it.

The patch adds the support.


https://reviews.llvm.org/D52689

Files:
  lit/Breakpoint/Inputs/implicit_const_form_support.yaml
  lit/Breakpoint/implicit_const_form_support.test
  source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
  source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h

Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -56,7 +56,8 @@
   };
 
   DWARFFormValue();
-  DWARFFormValue(const DWARFUnit *cu, dw_form_t form);
+  DWARFFormValue(const DWARFUnit *cu, dw_form_t form,
+ ValueType val = ValueType());
   const DWARFUnit *GetCompileUnit() const { return m_cu; }
   void SetCompileUnit(const DWARFUnit *cu) { m_cu = cu; }
   dw_form_t Form() const { return m_form; }
Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -154,8 +154,9 @@
 
 DWARFFormValue::DWARFFormValue() : m_cu(NULL), m_form(0), m_value() {}
 
-DWARFFormValue::DWARFFormValue(const DWARFUnit *cu, dw_form_t form)
-: m_cu(cu), m_form(form), m_value() {}
+DWARFFormValue::DWARFFormValue(const DWARFUnit *cu, dw_form_t form,
+   ValueType val)
+: m_cu(cu), m_form(form), m_value(val) {}
 
 void DWARFFormValue::Clear() {
   m_cu = nullptr;
@@ -165,6 +166,9 @@
 
 bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
   lldb::offset_t *offset_ptr) {
+  if (m_form == DW_FORM_implicit_const)
+return true;
+
   bool indirect = false;
   bool is_block = false;
   m_value.data = NULL;
@@ -366,6 +370,7 @@
 
   // 0 bytes values (implied from DW_FORM)
   case DW_FORM_flag_present:
+  case DW_FORM_implicit_const:
 return true;
 
 // 1 byte values
@@ -822,6 +827,7 @@
 case DW_FORM_ref_sig8:
 case DW_FORM_GNU_str_index:
 case DW_FORM_GNU_addr_index:
+case DW_FORM_implicit_const:
   return true;
 default:
   break;
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -174,6 +174,10 @@
   debug_info_data.GetU32(&offset);
 break;
 
+  case DW_FORM_implicit_const:
+form_size = 0;
+break;
+
   default:
 *offset_ptr = m_offset;
 return false;
@@ -287,6 +291,7 @@
 
   // 0 sized form
   case DW_FORM_flag_present:
+  case DW_FORM_implicit_const:
 form_size = 0;
 break;
 
@@ -378,6 +383,13 @@
   Dump(dwarf2Data, cu, s, recurse_depth);
 }
 
+static void setUnsignedOrSigned(int &dest, DWARFFormValue &val) {
+  if (val.Form() == DW_FORM_implicit_const)
+dest = val.Signed();
+  else
+dest = val.Unsigned();
+}
+
 //--
 // GetDIENamesAndRanges
 //
@@ -420,11 +432,13 @@
 uint32_t i;
 dw_attr_t attr;
 dw_form_t form;
+DWARFFormValue::ValueType val;
 bool do_offset = false;
 
 for (i = 0; i < numAttributes; ++i) {
-  abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
-  DWARFFormValue form_value(cu, form);
+  abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form, &val);
+  DWARFFormValue form_value(cu, form, val);
+
   if (form_value.ExtractValue(debug_info_data, &offset)) {
 switch (attr) {
 case DW_AT_low_pc:
@@ -491,32 +505,32 @@
 
 case DW_AT_decl_file:
   if (decl_file == 0)
-decl_file = form_value.Unsigned();
+setUnsignedOrSigned(decl_file, form_value);
   break;
 
 case DW_AT_decl_line:
-  if (decl_line == 0)
-decl_line = form_value.Unsigned();
+  if (decl_line != 0)
+setUnsignedOrSigned(decl_line, form_value);
   break;
 
 case DW_AT_decl_column:
-  if (decl_column == 0)
-decl_column = form_value.Unsigned();
+

[Lldb-commits] [PATCH] D52689: [LLDB] - Add support for DW_FORM_implicit_const.

2018-10-03 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

In https://reviews.llvm.org/D52689#1253175, @vsk wrote:

> Could you describe how the test exercises DW_FORM_implicit_const support? 
> It's not immediately clear to me.


The abbreviation for `foo1` and `foo2` subprograms use it for `DW_AT_decl_file` 
and `DW_AT_decl_column`:

  [1] DW_TAG_subprogram DW_CHILDREN_no
DW_AT_external  DW_FORM_flag_present
DW_AT_name  DW_FORM_strp
DW_AT_decl_file DW_FORM_implicit_const  1
DW_AT_decl_line DW_FORM_data1
DW_AT_decl_column   DW_FORM_implicit_const  5
DW_AT_linkage_name  DW_FORM_strp
DW_AT_type  DW_FORM_ref4
DW_AT_low_pcDW_FORM_addr
DW_AT_high_pc   DW_FORM_data8
DW_AT_frame_baseDW_FORM_exprloc
DW_AT_call_all_callsDW_FORM_flag_present




https://reviews.llvm.org/D52689



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


[Lldb-commits] [PATCH] D52981: [LLDB] - Add basic support for .debug_rnglists section (DWARF5)

2018-10-08 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg.
Herald added subscribers: JDevlieghere, arichardson, emaste.
Herald added a reviewer: espindola.

This adds a basic support of the .debug_rnglists section.
Only the DW_RLE_start_length and DW_RLE_end_of_list entries are supported.


https://reviews.llvm.org/D52981

Files:
  include/lldb/lldb-enumerations.h
  lit/Breakpoint/Inputs/debug_rnglist_basic.yaml
  lit/Breakpoint/debug_rnglist_basic.test
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -358,6 +358,7 @@
   case eSectionTypeDWARFDebugPubNames:
   case eSectionTypeDWARFDebugPubTypes:
   case eSectionTypeDWARFDebugRanges:
+  case eSectionTypeDWARFDebugRngLists:
   case eSectionTypeDWARFDebugStr:
   case eSectionTypeDWARFDebugStrOffsets:
   case eSectionTypeDWARFDebugTypes:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -54,6 +54,7 @@
 class DWARFDebugInfoEntry;
 class DWARFDebugLine;
 class DWARFDebugRanges;
+class DWARFDebugRngLists;
 class DWARFDeclContext;
 class DWARFDIECollection;
 class DWARFFormValue;
@@ -244,6 +245,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
   const lldb_private::DWARFDataExtractor &get_debug_loc_data();
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
+  const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
   const lldb_private::DWARFDataExtractor &get_debug_types_data();
@@ -474,6 +476,7 @@
   DWARFDataSegment m_data_debug_macro;
   DWARFDataSegment m_data_debug_loc;
   DWARFDataSegment m_data_debug_ranges;
+  DWARFDataSegment m_data_debug_rnglists;
   DWARFDataSegment m_data_debug_str;
   DWARFDataSegment m_data_debug_str_offsets;
   DWARFDataSegment m_data_debug_types;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -410,9 +410,9 @@
   m_debug_map_module_wp(), m_debug_map_symfile(NULL), m_data_debug_abbrev(),
   m_data_debug_aranges(), m_data_debug_frame(), m_data_debug_info(),
   m_data_debug_line(), m_data_debug_macro(), m_data_debug_loc(),
-  m_data_debug_ranges(), m_data_debug_str(), m_data_apple_names(),
-  m_data_apple_types(), m_data_apple_namespaces(), m_abbr(), m_info(),
-  m_line(), m_fetched_external_modules(false),
+  m_data_debug_ranges(), m_data_debug_rnglists(), m_data_debug_str(),
+  m_data_apple_names(), m_data_apple_types(), m_data_apple_namespaces(),
+  m_abbr(), m_info(), m_line(), m_fetched_external_modules(false),
   m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(),
   m_unique_ast_type_map() {}
 
@@ -659,6 +659,11 @@
   m_data_debug_ranges);
 }
 
+const DWARFDataExtractor &SymbolFileDWARF::get_debug_rnglists_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugRngLists,
+  m_data_debug_rnglists);
+}
+
 const DWARFDataExtractor &SymbolFileDWARF::get_debug_str_data() {
   return GetCachedSectionData(eSectionTypeDWARFDebugStr, m_data_debug_str);
 }
@@ -753,11 +758,14 @@
 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
 Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
static_cast(this));
-if (get_debug_ranges_data().GetByteSize() > 0) {
+
+if (get_debug_ranges_data().GetByteSize() > 0)
   m_ranges.reset(new DWARFDebugRanges());
-  if (m_ranges.get())
-m_ranges->Extract(this);
-}
+else if (get_debug_rnglists_data().GetByteSize() > 0)
+  m_ranges.reset(new DWARFDebugRngLists());
+
+if (m_ranges.get())
+  m_ranges->Extract(this);
   }
   return m_ranges.get();
 }
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -18,8 +18,9 @@
 class DWARFDebugRange

[Lldb-commits] [PATCH] D52981: [LLDB] - Add basic support for .debug_rnglists section (DWARF5)

2018-10-09 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 168759.
grimar added a comment.

- Addressed review comments.


https://reviews.llvm.org/D52981

Files:
  include/lldb/lldb-enumerations.h
  lit/Breakpoint/Inputs/debug_rnglist_basic.yaml
  lit/Breakpoint/debug_rnglist_basic.test
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -358,6 +358,7 @@
   case eSectionTypeDWARFDebugPubNames:
   case eSectionTypeDWARFDebugPubTypes:
   case eSectionTypeDWARFDebugRanges:
+  case eSectionTypeDWARFDebugRngLists:
   case eSectionTypeDWARFDebugStr:
   case eSectionTypeDWARFDebugStrOffsets:
   case eSectionTypeDWARFDebugTypes:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -54,6 +54,7 @@
 class DWARFDebugInfoEntry;
 class DWARFDebugLine;
 class DWARFDebugRanges;
+class DWARFDebugRngLists;
 class DWARFDeclContext;
 class DWARFDIECollection;
 class DWARFFormValue;
@@ -244,6 +245,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
   const lldb_private::DWARFDataExtractor &get_debug_loc_data();
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
+  const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
   const lldb_private::DWARFDataExtractor &get_debug_types_data();
@@ -474,6 +476,7 @@
   DWARFDataSegment m_data_debug_macro;
   DWARFDataSegment m_data_debug_loc;
   DWARFDataSegment m_data_debug_ranges;
+  DWARFDataSegment m_data_debug_rnglists;
   DWARFDataSegment m_data_debug_str;
   DWARFDataSegment m_data_debug_str_offsets;
   DWARFDataSegment m_data_debug_types;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -410,9 +410,9 @@
   m_debug_map_module_wp(), m_debug_map_symfile(NULL), m_data_debug_abbrev(),
   m_data_debug_aranges(), m_data_debug_frame(), m_data_debug_info(),
   m_data_debug_line(), m_data_debug_macro(), m_data_debug_loc(),
-  m_data_debug_ranges(), m_data_debug_str(), m_data_apple_names(),
-  m_data_apple_types(), m_data_apple_namespaces(), m_abbr(), m_info(),
-  m_line(), m_fetched_external_modules(false),
+  m_data_debug_ranges(), m_data_debug_rnglists(), m_data_debug_str(),
+  m_data_apple_names(), m_data_apple_types(), m_data_apple_namespaces(),
+  m_abbr(), m_info(), m_line(), m_fetched_external_modules(false),
   m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(),
   m_unique_ast_type_map() {}
 
@@ -659,6 +659,11 @@
   m_data_debug_ranges);
 }
 
+const DWARFDataExtractor &SymbolFileDWARF::get_debug_rnglists_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugRngLists,
+  m_data_debug_rnglists);
+}
+
 const DWARFDataExtractor &SymbolFileDWARF::get_debug_str_data() {
   return GetCachedSectionData(eSectionTypeDWARFDebugStr, m_data_debug_str);
 }
@@ -753,11 +758,14 @@
 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
 Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
static_cast(this));
-if (get_debug_ranges_data().GetByteSize() > 0) {
+
+if (get_debug_ranges_data().GetByteSize() > 0)
   m_ranges.reset(new DWARFDebugRanges());
-  if (m_ranges.get())
-m_ranges->Extract(this);
-}
+else if (get_debug_rnglists_data().GetByteSize() > 0)
+  m_ranges.reset(new DWARFDebugRngLists());
+
+if (m_ranges.get())
+  m_ranges->Extract(this);
   }
   return m_ranges.get();
 }
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -18,8 +18,9 @@
 class DWARFDebugRanges {
 public:
   DWARFDebugRanges();
-  ~DWARFDebugRanges();
-  void Extract(SymbolFileDWARF *dwarf2Data);
+  virtual ~DWARFDebugRanges();
+  virtual void Extract(SymbolFileDWARF *dwarf2Data);
+
   stati

[Lldb-commits] [PATCH] D52981: [LLDB] - Add basic support for .debug_rnglists section (DWARF5)

2018-10-09 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp:134-144
+uint8_t encoding = data.GetU8(offset_ptr);
+
+if (encoding == DW_RLE_end_of_list)
+  return true;
+
+if (encoding == DW_RLE_start_length) {
+  dw_addr_t begin = data.GetMaxU64(offset_ptr, addrSize);

clayborg wrote:
> Use a switch statement here? We also want to use a lldbassert for any non 
> supported encodings (in the default case of the switch statement) so we know 
> if/when a compiler starts emitting an encoding we don't yet support when 
> running the test suite with assertions enabled. That will let us know why 
> things are failing. 
Thanks! I was wondering if I can use some kind of an assert here. Because I 
noticed that usually lldb just return `false`
when is unable to parse some debug section (like a case of unknown form or 
attribute) or tries to skip the unknown constructions.
Having an assert definitely can simplify the further support here.


https://reviews.llvm.org/D52981



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


[Lldb-commits] [PATCH] D52689: [LLDB] - Add support for DW_FORM_implicit_const.

2018-10-09 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

Ping.


https://reviews.llvm.org/D52689



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


[Lldb-commits] [PATCH] D52981: [LLDB] - Add basic support for .debug_rnglists section (DWARF5)

2018-10-09 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

In https://reviews.llvm.org/D52981#1257888, @clayborg wrote:

> For space savings it seems like we would want to support the 
> DW_RLE_base_address and DW_RLE_offset_pair pretty soon.


I am working on a follow-up patch to support those.


https://reviews.llvm.org/D52981



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


[Lldb-commits] [PATCH] D52981: [LLDB] - Add basic support for .debug_rnglists section (DWARF5)

2018-10-10 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344119: [LLDB] - Add basic support for .debug_rnglists 
section (DWARF5) (authored by grimar, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52981?vs=168759&id=168946#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52981

Files:
  lldb/trunk/include/lldb/lldb-enumerations.h
  lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml
  lldb/trunk/lit/Breakpoint/debug_rnglist_basic.test
  lldb/trunk/source/Core/Section.cpp
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/trunk/source/Symbol/ObjectFile.cpp

Index: lldb/trunk/source/Core/Section.cpp
===
--- lldb/trunk/source/Core/Section.cpp
+++ lldb/trunk/source/Core/Section.cpp
@@ -87,6 +87,8 @@
 return "dwarf-pubtypes";
   case eSectionTypeDWARFDebugRanges:
 return "dwarf-ranges";
+  case eSectionTypeDWARFDebugRngLists:
+return "dwarf-rnglists";
   case eSectionTypeDWARFDebugStr:
 return "dwarf-str";
   case eSectionTypeDWARFDebugStrOffsets:
Index: lldb/trunk/source/Symbol/ObjectFile.cpp
===
--- lldb/trunk/source/Symbol/ObjectFile.cpp
+++ lldb/trunk/source/Symbol/ObjectFile.cpp
@@ -358,6 +358,7 @@
   case eSectionTypeDWARFDebugPubNames:
   case eSectionTypeDWARFDebugPubTypes:
   case eSectionTypeDWARFDebugRanges:
+  case eSectionTypeDWARFDebugRngLists:
   case eSectionTypeDWARFDebugStr:
   case eSectionTypeDWARFDebugStrOffsets:
   case eSectionTypeDWARFDebugTypes:
Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1796,6 +1796,7 @@
   static ConstString g_sect_name_dwarf_debug_pubnames(".debug_pubnames");
   static ConstString g_sect_name_dwarf_debug_pubtypes(".debug_pubtypes");
   static ConstString g_sect_name_dwarf_debug_ranges(".debug_ranges");
+  static ConstString g_sect_name_dwarf_debug_rnglists(".debug_rnglists");
   static ConstString g_sect_name_dwarf_debug_str(".debug_str");
   static ConstString g_sect_name_dwarf_debug_str_offsets(
   ".debug_str_offsets");
@@ -1879,6 +1880,8 @@
 sect_type = eSectionTypeDWARFDebugPubTypes;
   else if (name == g_sect_name_dwarf_debug_ranges)
 sect_type = eSectionTypeDWARFDebugRanges;
+  else if (name == g_sect_name_dwarf_debug_rnglists)
+sect_type = eSectionTypeDWARFDebugRngLists;
   else if (name == g_sect_name_dwarf_debug_str)
 sect_type = eSectionTypeDWARFDebugStr;
   else if (name == g_sect_name_dwarf_debug_types)
Index: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1205,6 +1205,7 @@
   case eSectionTypeDWARFDebugPubNames:
   case eSectionTypeDWARFDebugPubTypes:
   case eSectionTypeDWARFDebugRanges:
+  case eSectionTypeDWARFDebugRngLists:
   case eSectionTypeDWARFDebugStr:
   case eSectionTypeDWARFDebugStrOffsets:
   case eSectionTypeDWARFDebugTypes:
@@ -1494,7 +1495,7 @@
   if (section_name == g_sect_name_dwarf_debug_pubtypes)
 return eSectionTypeDWARFDebugPubTypes;
   if (section_name == g_sect_name_dwarf_debug_ranges)
-return eSectionTypeDWARFDebugRanges;
+return eSectionTypeDWARFDebugRanges; 
   if (section_name == g_sect_name_dwarf_debug_str)
 return eSectionTypeDWARFDebugStr;
   if (section_name == g_sect_name_dwarf_debug_types)
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -18,8 +18,9 @@
 class DWARFDebugRanges {
 public:
   DWARFDebugRanges();
-  ~DWARFDebugRanges();
-  void Extract(SymbolFileDWARF *dwarf2Data);
+  virtual ~DWARFDebugRanges();
+  virtual void Extract(SymbolFileDWARF *dwarf2Data);
+
   static void Dump(lldb_private::Stream &s,
const lldb_private::DWARFDataExtractor &debug_ranges_data,

[Lldb-commits] [PATCH] D52689: [LLDB] - Add support for DW_FORM_implicit_const.

2018-10-10 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 169005.
grimar marked 12 inline comments as done.
grimar added a comment.

- Addressed review comments.


https://reviews.llvm.org/D52689

Files:
  lit/Breakpoint/Inputs/implicit_const_form_support.yaml
  lit/Breakpoint/implicit_const_form_support.test
  source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
  source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h

Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -62,6 +62,7 @@
   dw_form_t Form() const { return m_form; }
   void SetForm(dw_form_t form) { m_form = form; }
   const ValueType &Value() const { return m_value; }
+  void SetValue(const ValueType &val) { m_value = val; }
   void Dump(lldb_private::Stream &s) const;
   bool ExtractValue(const lldb_private::DWARFDataExtractor &data,
 lldb::offset_t *offset_ptr);
Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -165,6 +165,9 @@
 
 bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
   lldb::offset_t *offset_ptr) {
+  if (m_form == DW_FORM_implicit_const)
+return true;
+
   bool indirect = false;
   bool is_block = false;
   m_value.data = NULL;
@@ -366,6 +369,7 @@
 
   // 0 bytes values (implied from DW_FORM)
   case DW_FORM_flag_present:
+  case DW_FORM_implicit_const:
 return true;
 
 // 1 byte values
@@ -822,6 +826,7 @@
 case DW_FORM_ref_sig8:
 case DW_FORM_GNU_str_index:
 case DW_FORM_GNU_addr_index:
+case DW_FORM_implicit_const:
   return true;
 default:
   break;
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -174,6 +174,10 @@
   debug_info_data.GetU32(&offset);
 break;
 
+  case DW_FORM_implicit_const:
+form_size = 0;
+break;
+
   default:
 *offset_ptr = m_offset;
 return false;
@@ -233,15 +237,16 @@
 
 // Skip all data in the .debug_info for the attributes
 const uint32_t numAttributes = abbrevDecl->NumAttributes();
-uint32_t i;
-dw_attr_t attr;
-dw_form_t form;
-for (i = 0; i < numAttributes; ++i) {
-  abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
+for (uint32_t i = 0; i < numAttributes; ++i) {
+  DWARFFormValue form_value;
+  form_value.SetCompileUnit(cu);
+
+  dw_attr_t attr;
+  abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
+  dw_form_t form = form_value.Form();
 
   if (isCompileUnitTag &&
   ((attr == DW_AT_entry_pc) || (attr == DW_AT_low_pc))) {
-DWARFFormValue form_value(cu, form);
 if (form_value.ExtractValue(debug_info_data, &offset)) {
   if (attr == DW_AT_low_pc || attr == DW_AT_entry_pc)
 const_cast(cu)->SetBaseAddress(
@@ -287,6 +292,7 @@
 
   // 0 sized form
   case DW_FORM_flag_present:
+  case DW_FORM_implicit_const:
 form_size = 0;
 break;
 
@@ -417,14 +423,15 @@
   return false;
 
 const uint32_t numAttributes = abbrevDecl->NumAttributes();
-uint32_t i;
-dw_attr_t attr;
-dw_form_t form;
 bool do_offset = false;
 
-for (i = 0; i < numAttributes; ++i) {
-  abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
-  DWARFFormValue form_value(cu, form);
+for (uint32_t i = 0; i < numAttributes; ++i) {
+  DWARFFormValue form_value;
+  form_value.SetCompileUnit(cu);
+
+  dw_attr_t attr;
+  abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
+
   if (form_value.ExtractValue(debug_info_data, &offset)) {
 switch (attr) {
 case DW_AT_low_pc:
@@ -614,14 +621,14 @@
 
 // Dump all data in the .debug_info for the attributes
 const uint32_t numAttributes = abbrevDecl->NumAttributes();
-uint32_t i;
-dw_attr_t attr;
-dw_form_t form;
-for (i = 0; i < numAttributes; ++i) {
-  abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
+for (uint32_t i = 0; i < numAttributes; ++i) {
+  DWARFFormVa

[Lldb-commits] [PATCH] D52689: [LLDB] - Add support for DW_FORM_implicit_const.

2018-10-10 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h:51
+  uint32_t idx, dw_attr_t &attr, dw_form_t &form,
+  DWARFFormValue::ValueType *val = nullptr) const {
+m_attributes[idx].get(attr, form, val);

clayborg wrote:
> Switch to using a "DWARFFormValue *form_value_ptr" so the form value can be 
> filled in automatically, not just the   DWARFFormValue::ValueType. See 
> comments below where this is called.
Answered below.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp:386
 
+static void setUnsignedOrSigned(int &dest, DWARFFormValue &val) {
+  if (val.Form() == DW_FORM_implicit_const)

clayborg wrote:
> Remove this as it won't be needed if we do the work of filling in the form 
> value in GetAttrAndFormByIndexUnchecked
Answered below.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp:439-440
 for (i = 0; i < numAttributes; ++i) {
-  abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
-  DWARFFormValue form_value(cu, form);
+  abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form, &val);
+  DWARFFormValue form_value(cu, form, val);
+

clayborg wrote:
> Maybe switch the order here and pass "form_value" to 
> GetAttrAndFormByIndexUnchecked?:
> 
> ```
>   DWARFFormValue form_value(cu, form);
>   abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form, &form_value);
> ```
> 
> DWARFFormValue form_value(cu, form);

We can not do this because at this point `form` is not yet known.
I changed the code in a bit different way though.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp:508
   if (decl_file == 0)
-decl_file = form_value.Unsigned();
+setUnsignedOrSigned(decl_file, form_value);
   break;

clayborg wrote:
> Revert this if we do the work inside "GetAttrAndFormByIndexUnchecked" as 
> form_value will be correct
The problem I see here is the following:

DWARF5 spec says (2.14 Declaration Coordinates, p50):
"Any debugging information entry representing the declaration of an object,
module, subprogram or type may have DW_AT_decl_file, DW_AT_decl_line and
DW_AT_decl_column attributes, each of whose value is an **unsigned integer
constant**."

But about `DW_FORM_implicit_const` it says (p207):

"The attribute form DW_FORM_implicit_const **is another special case**. For
attributes with this form, the attribute specification contains a third part, 
which is
a **signed LEB128 number**. The value of this number is used as the value of the
attribute, and no value is stored in the .debug_info section."

So I read `DW_FORM_implicit_const` to `value.sval` and I think we can not
use `form_value.Unsigned();` in that case because it reads from `uval`.
Writing to one union field and reading from the another is undefined behavior 
in C++ I believe.
Though it works with the modern compilers I think.

DWARFFormValue.h contains dead enum (it is unused)
https://github.com/llvm-mirror/lldb/blob/master/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h#L51
which intention seems was about to keep the value type information.
Should we start to set and check the type of form value?

I removed the helper for now, but this UB should be addressed somehow I think?

Should we create`DWARFFormValue::GetSignedOrUnsigned` may be? It perhaps will 
be consistent
with `DWARFFormValue::Address`/`AsCString`which check the form type and 
returned value depends
on that.


https://reviews.llvm.org/D52689



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


[Lldb-commits] [PATCH] D52689: [LLDB] - Add support for DW_FORM_implicit_const.

2018-10-11 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 169177.
grimar marked 4 inline comments as done.
grimar added a comment.

- Addressed review comments.


https://reviews.llvm.org/D52689

Files:
  lit/Breakpoint/Inputs/implicit_const_form_support.yaml
  lit/Breakpoint/implicit_const_form_support.test
  source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
  source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h

Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -60,8 +60,12 @@
   const DWARFUnit *GetCompileUnit() const { return m_cu; }
   void SetCompileUnit(const DWARFUnit *cu) { m_cu = cu; }
   dw_form_t Form() const { return m_form; }
+  dw_form_t& FormRef() { return m_form; }
   void SetForm(dw_form_t form) { m_form = form; }
   const ValueType &Value() const { return m_value; }
+  ValueType &ValueRef() { return m_value; }
+  void SetValue(const ValueType &val) { m_value = val; }
+
   void Dump(lldb_private::Stream &s) const;
   bool ExtractValue(const lldb_private::DWARFDataExtractor &data,
 lldb::offset_t *offset_ptr);
Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -165,6 +165,9 @@
 
 bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
   lldb::offset_t *offset_ptr) {
+  if (m_form == DW_FORM_implicit_const)
+return true;
+
   bool indirect = false;
   bool is_block = false;
   m_value.data = NULL;
@@ -366,6 +369,7 @@
 
   // 0 bytes values (implied from DW_FORM)
   case DW_FORM_flag_present:
+  case DW_FORM_implicit_const:
 return true;
 
 // 1 byte values
@@ -822,6 +826,7 @@
 case DW_FORM_ref_sig8:
 case DW_FORM_GNU_str_index:
 case DW_FORM_GNU_addr_index:
+case DW_FORM_implicit_const:
   return true;
 default:
   break;
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -178,7 +178,7 @@
   DumpAttribute(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
 const lldb_private::DWARFDataExtractor &debug_info_data,
 lldb::offset_t *offset_ptr, lldb_private::Stream &s,
-dw_attr_t attr, dw_form_t form);
+dw_attr_t attr, DWARFFormValue &form_value);
   // This one dumps the comp unit name, objfile name and die offset for this die
   // so the stream S.
   void DumpLocation(SymbolFileDWARF *dwarf2Data, DWARFUnit *cu,
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -174,6 +174,10 @@
   debug_info_data.GetU32(&offset);
 break;
 
+  case DW_FORM_implicit_const:
+form_size = 0;
+break;
+
   default:
 *offset_ptr = m_offset;
 return false;
@@ -233,15 +237,16 @@
 
 // Skip all data in the .debug_info for the attributes
 const uint32_t numAttributes = abbrevDecl->NumAttributes();
-uint32_t i;
-dw_attr_t attr;
-dw_form_t form;
-for (i = 0; i < numAttributes; ++i) {
-  abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
+for (uint32_t i = 0; i < numAttributes; ++i) {
+  DWARFFormValue form_value;
+  form_value.SetCompileUnit(cu);
+
+  dw_attr_t attr;
+  abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
+  dw_form_t form = form_value.Form();
 
   if (isCompileUnitTag &&
   ((attr == DW_AT_entry_pc) || (attr == DW_AT_low_pc))) {
-DWARFFormValue form_value(cu, form);
 if (form_value.ExtractValue(debug_info_data, &offset)) {
   if (attr == DW_AT_low_pc || attr == DW_AT_entry_pc)
 const_cast(cu)->SetBaseAddress(
@@ -287,6 +292,7 @@
 
   // 0 sized form
   case DW_FORM_flag_present:
+  case DW_FORM_implicit_const:
 form_size = 0;
 break;
 
@@ -417,14 +423,15 @@
   return false;
 
 const uint32_t numAttributes = abbrevDe

[Lldb-commits] [PATCH] D52689: [LLDB] - Add support for DW_FORM_implicit_const.

2018-10-11 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFAttribute.h:23
+  DWARFAttribute(dw_attr_t attr, dw_form_t form,
+ DWARFFormValue::ValueType value)
+  : m_attr(attr), m_form(form), m_value(value) {}

clayborg wrote:
> Do we need to use a "DWARFFormValue::ValueType" here? Right now we only need 
> a int64_t and DWARFFormValue::ValueType is larger than that. It does future 
> proof us a bit and there aren't all that many abbreviations, even in a large 
> DWARF file. Just thinking out loud here
My thoughts to use `DWARFFormValue::ValueType` were that it seems a bit more 
generic,
as standard can add other kinds of values rather than `int64_t` perhaps in 
future.
And it seems to be a bit cleaner because `DWARFFormValue::ValueType` is already
existent class representing the form value while `int64_t` would be kind of 
exception/special case.
I agree that for now, it is a bit excessive to have `DWARFFormValue::ValueType` 
here though. 



Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp:630-631
 
   DumpAttribute(dwarf2Data, cu, debug_info_data, &offset, s, attr,
-form);
+form_value.Form());
 }

clayborg wrote:
> DumpAttribute will need to take the full form_value in order to dump 
> DW_FORM_implicit_const forms correctly. Change DumpAttribute to take a 
> "form_value"
Done. I had to make it non-const `DWARFFormValue &form_value` because 
`ExtractValue` call inside `DumpAttribute` is not const.
As an alternative, we could probably use pass it by value here. But since there 
is a only one `DumpAttribute` call, I think its ok.


https://reviews.llvm.org/D52689



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


[Lldb-commits] [PATCH] D52689: [LLDB] - Add support for DW_FORM_implicit_const.

2018-10-11 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 169209.
grimar added a comment.

- Addressed review comments.


https://reviews.llvm.org/D52689

Files:
  lit/Breakpoint/Inputs/implicit_const_form_support.yaml
  lit/Breakpoint/implicit_const_form_support.test
  source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
  source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h

Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -56,12 +56,17 @@
   };
 
   DWARFFormValue();
+  DWARFFormValue(const DWARFUnit *cu);
   DWARFFormValue(const DWARFUnit *cu, dw_form_t form);
   const DWARFUnit *GetCompileUnit() const { return m_cu; }
   void SetCompileUnit(const DWARFUnit *cu) { m_cu = cu; }
   dw_form_t Form() const { return m_form; }
+  dw_form_t& FormRef() { return m_form; }
   void SetForm(dw_form_t form) { m_form = form; }
   const ValueType &Value() const { return m_value; }
+  ValueType &ValueRef() { return m_value; }
+  void SetValue(const ValueType &val) { m_value = val; }
+
   void Dump(lldb_private::Stream &s) const;
   bool ExtractValue(const lldb_private::DWARFDataExtractor &data,
 lldb::offset_t *offset_ptr);
Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -154,6 +154,8 @@
 
 DWARFFormValue::DWARFFormValue() : m_cu(NULL), m_form(0), m_value() {}
 
+DWARFFormValue::DWARFFormValue(const DWARFUnit *cu) : m_cu(cu), m_form(0), m_value() {}
+
 DWARFFormValue::DWARFFormValue(const DWARFUnit *cu, dw_form_t form)
 : m_cu(cu), m_form(form), m_value() {}
 
@@ -165,6 +167,9 @@
 
 bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
   lldb::offset_t *offset_ptr) {
+  if (m_form == DW_FORM_implicit_const)
+return true;
+
   bool indirect = false;
   bool is_block = false;
   m_value.data = NULL;
@@ -366,6 +371,7 @@
 
   // 0 bytes values (implied from DW_FORM)
   case DW_FORM_flag_present:
+  case DW_FORM_implicit_const:
 return true;
 
 // 1 byte values
@@ -822,6 +828,7 @@
 case DW_FORM_ref_sig8:
 case DW_FORM_GNU_str_index:
 case DW_FORM_GNU_addr_index:
+case DW_FORM_implicit_const:
   return true;
 default:
   break;
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -178,7 +178,7 @@
   DumpAttribute(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
 const lldb_private::DWARFDataExtractor &debug_info_data,
 lldb::offset_t *offset_ptr, lldb_private::Stream &s,
-dw_attr_t attr, dw_form_t form);
+dw_attr_t attr, DWARFFormValue &form_value);
   // This one dumps the comp unit name, objfile name and die offset for this die
   // so the stream S.
   void DumpLocation(SymbolFileDWARF *dwarf2Data, DWARFUnit *cu,
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -174,6 +174,10 @@
   debug_info_data.GetU32(&offset);
 break;
 
+  case DW_FORM_implicit_const:
+form_size = 0;
+break;
+
   default:
 *offset_ptr = m_offset;
 return false;
@@ -233,15 +237,14 @@
 
 // Skip all data in the .debug_info for the attributes
 const uint32_t numAttributes = abbrevDecl->NumAttributes();
-uint32_t i;
-dw_attr_t attr;
-dw_form_t form;
-for (i = 0; i < numAttributes; ++i) {
-  abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
+for (uint32_t i = 0; i < numAttributes; ++i) {
+  DWARFFormValue form_value(cu);
+  dw_attr_t attr;
+  abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
+  dw_form_t form = form_value.Form();
 
   if (isCompileUnitTag &&
   ((attr == DW_AT_entry_pc) || (attr == DW_AT_low_pc))) {
-DWARFFormValue form_value(cu, form);
 if (form_value.ExtractValue(debug_info_data, &offset)) {
   if (attr == DW_AT_low_pc || attr == DW_A

[Lldb-commits] [PATCH] D53140: [LLDB] - Add support for DW_RLE_base_address and DW_RLE_offset_pair entries (.debug_rnglists)

2018-10-11 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg.
Herald added a subscriber: JDevlieghere.

The patch implements the support for DW_RLE_base_address and DW_RLE_offset_pair
.debug_rnglists  entries


https://reviews.llvm.org/D53140

Files:
  lit/Breakpoint/Inputs/debug_rnglist_offset_pair.yaml
  lit/Breakpoint/debug_rnglist_offset_pair.test
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -53,8 +53,7 @@
 class DWARFDebugInfo;
 class DWARFDebugInfoEntry;
 class DWARFDebugLine;
-class DWARFDebugRanges;
-class DWARFDebugRngLists;
+class DWARFDebugRangesBase;
 class DWARFDeclContext;
 class DWARFDIECollection;
 class DWARFFormValue;
@@ -263,9 +262,9 @@
 
   const DWARFDebugInfo *DebugInfo() const;
 
-  DWARFDebugRanges *DebugRanges();
+  DWARFDebugRangesBase *DebugRanges();
 
-  const DWARFDebugRanges *DebugRanges() const;
+  const DWARFDebugRangesBase *DebugRanges() const;
 
   static bool SupportedVersion(uint16_t version);
 
@@ -506,7 +505,7 @@
   typedef std::shared_ptr> DIERefSetSP;
   typedef std::unordered_map NameToOffsetMap;
   NameToOffsetMap m_function_scope_qualified_name_map;
-  std::unique_ptr m_ranges;
+  std::unique_ptr m_ranges;
   UniqueDWARFASTTypeMap m_unique_ast_type_map;
   DIEToTypePtr m_die_to_type;
   DIEToVariableSP m_die_to_variable_sp;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -753,7 +753,7 @@
   return NULL;
 }
 
-DWARFDebugRanges *SymbolFileDWARF::DebugRanges() {
+DWARFDebugRangesBase *SymbolFileDWARF::DebugRanges() {
   if (m_ranges.get() == NULL) {
 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
 Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
@@ -770,7 +770,7 @@
   return m_ranges.get();
 }
 
-const DWARFDebugRanges *SymbolFileDWARF::DebugRanges() const {
+const DWARFDebugRangesBase *SymbolFileDWARF::DebugRanges() const {
   return m_ranges.get();
 }
 
@@ -3328,15 +3328,10 @@
   case DW_AT_start_scope: {
 if (form_value.Form() == DW_FORM_sec_offset) {
   DWARFRangeList dwarf_scope_ranges;
-  const DWARFDebugRanges *debug_ranges = DebugRanges();
-  debug_ranges->FindRanges(die.GetCU()->GetRangesBase(),
+  const DWARFDebugRangesBase *debug_ranges = DebugRanges();
+  debug_ranges->FindRanges(die.GetCU(),
form_value.Unsigned(),
dwarf_scope_ranges);
-
-  // All DW_AT_start_scope are relative to the base address of the
-  // compile unit. We add the compile unit base address to make
-  // sure all the addresses are properly fixed up.
-  dwarf_scope_ranges.Slide(die.GetCU()->GetBaseAddress());
 } else {
   // TODO: Handle the case when DW_AT_start_scope have form
   // constant. The
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -15,18 +15,26 @@
 
 #include 
 
-class DWARFDebugRanges {
+class DWARFDebugRangesBase {
+public:
+  virtual ~DWARFDebugRangesBase(){};
+
+  virtual void Extract(SymbolFileDWARF *dwarf2Data) = 0;
+  virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
+  DWARFRangeList &range_list) const = 0;
+};
+
+class DWARFDebugRanges final : public DWARFDebugRangesBase {
 public:
   DWARFDebugRanges();
-  virtual ~DWARFDebugRanges();
-  virtual void Extract(SymbolFileDWARF *dwarf2Data);
+
+  virtual void Extract(SymbolFileDWARF *dwarf2Data) override;
+  virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
+  DWARFRangeList &range_list) const override;
 
   static void Dump(lldb_private::Stream &s,
const lldb_private::DWARFDataExtractor &debug_ranges_data,
lldb::offset_t *offset_ptr, dw_addr_t cu_base_addr);
-  bool FindRanges(dw_addr_t debug_ranges_base,
-  dw_offset_t debug_ranges_offset,
-  DWARFRangeList &range_list) const;
 
 protected:
   bool Extract(SymbolFileDWARF *dwarf2Data, lldb::offset_t *offset_ptr,
@@ -39,16 +47,25 @@
 };
 
 // DWARF v5 .debug_rnglists section.
-cl

[Lldb-commits] [PATCH] D52689: [LLDB] - Add support for DW_FORM_implicit_const.

2018-10-12 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB344328: [LLDB] - Add support for DW_FORM_implicit_const. 
(authored by grimar, committed by ).
Herald added a subscriber: abidh.

Changed prior to commit:
  https://reviews.llvm.org/D52689?vs=169209&id=169359#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52689

Files:
  lit/Breakpoint/Inputs/implicit_const_form_support.yaml
  lit/Breakpoint/implicit_const_form_support.test
  source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
  source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h

Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -56,12 +56,17 @@
   };
 
   DWARFFormValue();
+  DWARFFormValue(const DWARFUnit *cu);
   DWARFFormValue(const DWARFUnit *cu, dw_form_t form);
   const DWARFUnit *GetCompileUnit() const { return m_cu; }
   void SetCompileUnit(const DWARFUnit *cu) { m_cu = cu; }
   dw_form_t Form() const { return m_form; }
+  dw_form_t& FormRef() { return m_form; }
   void SetForm(dw_form_t form) { m_form = form; }
   const ValueType &Value() const { return m_value; }
+  ValueType &ValueRef() { return m_value; }
+  void SetValue(const ValueType &val) { m_value = val; }
+
   void Dump(lldb_private::Stream &s) const;
   bool ExtractValue(const lldb_private::DWARFDataExtractor &data,
 lldb::offset_t *offset_ptr);
Index: source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
+++ source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
@@ -11,15 +11,17 @@
 #define SymbolFileDWARF_DWARFAttribute_h_
 
 #include "DWARFDefines.h"
+#include "DWARFFormValue.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
 
 class DWARFUnit;
-class DWARFFormValue;
 
 class DWARFAttribute {
 public:
-  DWARFAttribute(dw_attr_t attr, dw_form_t form) : m_attr(attr), m_form(form) {}
+  DWARFAttribute(dw_attr_t attr, dw_form_t form,
+ DWARFFormValue::ValueType value)
+  : m_attr(attr), m_form(form), m_value(value) {}
 
   void set(dw_attr_t attr, dw_form_t form) {
 m_attr = attr;
@@ -29,9 +31,11 @@
   void set_form(dw_form_t form) { m_form = form; }
   dw_attr_t get_attr() const { return m_attr; }
   dw_form_t get_form() const { return m_form; }
-  void get(dw_attr_t &attr, dw_form_t &form) const {
+  void get(dw_attr_t &attr, dw_form_t &form,
+   DWARFFormValue::ValueType &val) const {
 attr = m_attr;
 form = m_form;
+val = m_value;
   }
   bool operator==(const DWARFAttribute &rhs) const {
 return m_attr == rhs.m_attr && m_form == rhs.m_form;
@@ -43,6 +47,7 @@
 protected:
   dw_attr_t m_attr;
   dw_form_t m_form;
+  DWARFFormValue::ValueType m_value;
 };
 
 class DWARFAttributes {
Index: source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
@@ -26,10 +26,10 @@
   return UINT32_MAX;
 }
 
-void DWARFAttributes::Append(const DWARFUnit *cu,
- dw_offset_t attr_die_offset, dw_attr_t attr,
- dw_form_t form) {
-  AttributeValue attr_value = {cu, attr_die_offset, {attr, form}};
+void DWARFAttributes::Append(const DWARFUnit *cu, dw_offset_t attr_die_offset,
+ dw_attr_t attr, dw_form_t form) {
+  AttributeValue attr_value = {
+  cu, attr_die_offset, {attr, form, DWARFFormValue::ValueType()}};
   m_infos.push_back(attr_value);
 }
 
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -174,6 +174,10 @@
   debug_info_data.GetU32(&offset);
 break;
 
+  case DW_FORM_implicit_const:
+form_size = 0;
+break;
+
   default:
 *offset_ptr = m_offset;
 return false;
@@ -233,15 +237,14 @@
 
 // Skip all data in the .debug_info for the attributes
 const uint32_t numAttributes = abbrevDecl->NumAttributes();
-uint32_t i;
-dw_attr_t attr;
-dw_form_t form;
-for (i = 0; i < numAttributes; ++i) {
-  abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
+for 

[Lldb-commits] [PATCH] D53140: [LLDB] - Add support for DW_RLE_base_address and DW_RLE_offset_pair entries (.debug_rnglists)

2018-10-12 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h:51-55
+  struct RngListEntry {
+uint8_t encoding;
+uint64_t value0;
+uint64_t value1;
+  };

clayborg wrote:
> Do we really need to store all this? Can't we just convert to address ranges 
> on the fly in DWARFDebugRngLists::Extract? With the current 
> DW_RLE_base_address and DW_RLE_offset_pair stuff we can store the base 
> address locally inside the DWARFDebugRngLists::Extract function and skip 
> pushing an entry for it and then convert any DW_RLE_offset_pair stuff into 
> addresses by adding the base address before pushing the range. Or will this 
> be required to support other opcodes?
I think we can not do that in `DWARFDebugRngLists::Extract` because we should 
take
in account that we can have multiple CU with different address bases.

Example:
https://github.com/llvm-mirror/lldb/blob/master/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp#L1069
In this code `dwarf2Data->DebugRanges()` call `Extract` which extracts all 
ranges from `.debug_range` section.
But at the moment of extraction, it does not know the base address for a given 
CU and that is why code calls
`range.Slide` after that I believe.

Here is an example I have in mind for this patch. The executable below contains 
2 CUs and 2 contibution in `.debug_rnglists` (one for each CU)
```
.debug_info contents:
0x: Compile Unit: length = 0x00ac version = 0x0005 unit_type = 
DW_UT_compile abbr_offset = 0x addr_size = 0x08 (next unit at 0x00b0)

0x000c: DW_TAG_compile_unit [1] *
...
  DW_AT_low_pc [DW_FORM_addr]   (0x00400520)
  DW_AT_high_pc [DW_FORM_data4] (0x0034)
  DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x000c)

...
0x00b0: Compile Unit: length = 0x00a1 version = 0x0005 unit_type = 
DW_UT_compile abbr_offset = 0x00ad addr_size = 0x08 (next unit at 0x0155)

0x00bc: DW_TAG_compile_unit [1] *

  DW_AT_low_pc [DW_FORM_addr]   (0x00400560)
  DW_AT_high_pc [DW_FORM_data4] (0x0027)
  DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x001f)
```


```
.debug_rnglists contents:
0x: range list header: length = 0x000f, version = 0x0005, addr_size 
= 0x08, seg_size = 0x00, offset_entry_count = 0x
ranges:
0x000c: [DW_RLE_offset_pair]:  0x0005, 0x0012 => 
[0x0005, 0x0012)
0x000f: [DW_RLE_offset_pair]:  0x0017, 0x001d => 
[0x0017, 0x001d)
0x0012: [DW_RLE_end_of_list]
0x0013: range list header: length = 0x000f, version = 0x0005, addr_size 
= 0x08, seg_size = 0x00, offset_entry_count = 0x
ranges:
0x001f: [DW_RLE_offset_pair]:  0x0005, 0x0012 => 
[0x0005, 0x0012)
0x0022: [DW_RLE_offset_pair]:  0x0017, 0x001d => 
[0x0017, 0x001d)
0x0025: [DW_RLE_end_of_list]
```

With that, it seems we want to parse the `.debug_rnglists` section once, but 
for each CU we have different contribution offset (`DW_AT_rnglists_base`) and 
the different base address (`DW_AT_low_pc`), so I think should fix up the 
ranges parsed independently.
That is why I had to store `RngListEntry` list and doing the fixup in 
`FindRanges`.

As an improvement we might want to cache the result returned by `FindRanges` 
somehow I think, so for further calls of `FindRanges`
for a given CU we would not need to do a fixup and can just return the ranges 
list built earlier.


https://reviews.llvm.org/D53140



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


[Lldb-commits] [PATCH] D53193: [LLDB] - Add support for DW_RLE_start_end entries (.debug_rnglists)

2018-10-12 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg.
Herald added subscribers: JDevlieghere, aprantl.

DWARF5 describes DW_RLE_start_end as:

>   This is a form of bounded range entry that has two target address operands.
>   Each operand is the same size as used in DW_FORM_addr. These indicate
>   the starting and ending addresses, respectively, that define the address 
> range
>   for which the following location is valid.

The patch implements the support.


https://reviews.llvm.org/D53193

Files:
  lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
  lit/Breakpoint/debug_rnglist_rlestartend.test
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
@@ -143,10 +143,17 @@
   break;
 }
 
+case DW_RLE_start_end: {
+  dw_addr_t begin = data.GetMaxU64(offset_ptr, addrSize);
+  dw_addr_t end = data.GetMaxU64(offset_ptr, addrSize);
+  rangeList.Append(DWARFRangeList::Entry(begin, end - begin));
+  break;
+}
+
 default:
   // Next encodings are not yet supported:
   // DW_RLE_base_addressx, DW_RLE_startx_endx, DW_RLE_startx_length,
-  // DW_RLE_offset_pair, DW_RLE_base_address, DW_RLE_start_end
+  // DW_RLE_offset_pair, DW_RLE_base_address.
   lldbassert(0 && "unknown range list entry encoding");
   error = true;
 }
Index: lit/Breakpoint/debug_rnglist_rlestartend.test
===
--- lit/Breakpoint/debug_rnglist_rlestartend.test
+++ lit/Breakpoint/debug_rnglist_rlestartend.test
@@ -0,0 +1,28 @@
+# RUN: yaml2obj %p/Inputs/debug_rnglist_rlestartend.yaml > %ttest
+# RUN: lldb-test breakpoints %ttest %s | FileCheck %s
+
+# Test shows that LDLB is able to handle DW_RLE_start_end entries properly.
+
+# The following code and invocation were used to produce asm file.
+# clang -O0 -gdwarf-5 test.cpp -S -o test.s -fuse-ld=lld -ffunction-sections
+# It was edited to use DW_RLE_start_end, compiled and converted to yaml.
+# The yaml was manually reduced.
+#
+# //test.cpp:
+# int zed() { 
+#  return 1;
+# }
+#
+# int main() {
+#  return zed();
+# }
+#
+# clang and LLD versions were 8.0.0 (trunk 344035)
+
+b main
+# CHECK-LABEL: b main
+# CHECK: Address: {{.*}}`main + 15 at test.cpp:6:10
+
+b zed
+# CHECK-LABEL: b zed
+# CHECK: Address: {{.*}}`zed() + 4 at test.cpp:2:3
Index: lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
===
--- lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
+++ lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
@@ -0,0 +1,49 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x00201000
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00201000
+AddressAlign:0x0010
+Content: 31ED4989D15E4889E24883E4F0505449C7C08011200048C7C11011200048C7C7F0102000E89701F455B810202000483D102020004889E57417B84885C0740D5DBF10202000FFE00F1F445DC3660F1F44BE10202000554881EE102020004889E548C1FE034889F048C1E83F4801C648D1FE7415B84885C0740B5DBF10202000FFE00F1F005DC3660F1F44803D592F007517554889E5E87EFFC605472F015DC30F1F44F3C30F1F4000662E0F1F8400554889E55DEB89CC554889E5B801005DC3CC554889E54883EC10C745FCE8DCFF4883C4105DC3415741564189FF415541544C8D25E61E55488D2DE61E534989F64989D54C29E54883EC0848C1FD03E843004885ED742031DB0F1F84004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F8400F3C3
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 250004002B003900620027003400
+  - Name:.debug_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 696E7400636C616E672076657273696F6E20382E302E3020287472756E6B2033343430333529007A656400746573742E637070006D61696E002F686F6D652F756D622F74657374735F323031382F3130375F726E676C6973747374617274656E64005F5A337A65647600
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 011101252513050325721710171B25110155177417022E001101120640186E2503253A0B3B0B49133F19032E0011011206401803253A0B3B0B49133F1904240003253E0B0B0B00
+  - Name:.debug_info
+Type:SHT_PROGBITS
+Addre

[Lldb-commits] [PATCH] D53193: [LLDB] - Add support for DW_RLE_start_end entries (.debug_rnglists)

2018-10-16 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

In https://reviews.llvm.org/D53193#1266080, @JDevlieghere wrote:

> The code and test look correct, so this LGTM but I'll leave it open for now 
> in case someone else wants to have a look too.


Thanks for looking, Jonas!


https://reviews.llvm.org/D53193



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


[Lldb-commits] [PATCH] D53193: [LLDB] - Add support for DW_RLE_start_end entries (.debug_rnglists)

2018-10-17 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344674: [LLDB] - Add support for DW_RLE_start_end entries 
(.debug_rnglists) (authored by grimar, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53193?vs=169377&id=169956#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53193

Files:
  lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
  lldb/trunk/lit/Breakpoint/debug_rnglist_rlestartend.test
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp

Index: lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
===
--- lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
+++ lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
@@ -0,0 +1,49 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x00201000
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00201000
+AddressAlign:0x0010
+Content: 31ED4989D15E4889E24883E4F0505449C7C08011200048C7C11011200048C7C7F0102000E89701F455B810202000483D102020004889E57417B84885C0740D5DBF10202000FFE00F1F445DC3660F1F44BE10202000554881EE102020004889E548C1FE034889F048C1E83F4801C648D1FE7415B84885C0740B5DBF10202000FFE00F1F005DC3660F1F44803D592F007517554889E5E87EFFC605472F015DC30F1F44F3C30F1F4000662E0F1F8400554889E55DEB89CC554889E5B801005DC3CC554889E54883EC10C745FCE8DCFF4883C4105DC3415741564189FF415541544C8D25E61E55488D2DE61E534989F64989D54C29E54883EC0848C1FD03E843004885ED742031DB0F1F84004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F8400F3C3
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 250004002B003900620027003400
+  - Name:.debug_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 696E7400636C616E672076657273696F6E20382E302E3020287472756E6B2033343430333529007A656400746573742E637070006D61696E002F686F6D652F756D622F74657374735F323031382F3130375F726E676C6973747374617274656E64005F5A337A65647600
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 011101252513050325721710171B25110155177417022E001101120640186E2503253A0B3B0B49133F19032E0011011206401803253A0B3B0B49133F1904240003253E0B0B0B00
+  - Name:.debug_info
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 58000500010801000400010800020C000C0002E0102B00015603040101570003F01020001A00015606010557000405050400
+  - Name:.debug_rnglists
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 2B000500080006E0102000EB1026F0102A1120
+  - Name:.debug_macinfo
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: '00'
+  - Name:.debug_line
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 8200050008004C00010101FB0E0D000101010100010101011F01090003011F020F051E0200C404455D157064301CF8C713A4AC4CEE00C404455D157064301CF8C713A4AC4CEE000902E0102105030A4B0207000101000902F010200016050A0AE5050306580206000101
+  - Name:.debug_line_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 746573742E637070002F686F6D652F756D622F74657374735F323031382F3130375F726E676C6973747374617274656E6400
+Symbols:
Index: lldb/trunk/lit/Breakpoint/debug_rnglist_rlestartend.test
===
--- lldb/trunk/lit/Breakpoint/debug_rnglist_rlestartend.test
+++ lldb/trunk/lit/Breakpoint/debug_rnglist_rlestartend.test
@@ -0,0 +1,28 @@
+# RUN: yaml2obj %p/Inputs/debug_rnglist_rlestartend.yaml > %ttest
+# RUN: lldb-test breakpoints %ttest %s | FileCheck %s
+
+# Test shows that LDLB is able to handle DW_RLE_start_end entries properly.
+
+# The following code and invocation were used to produce asm file.
+# clang -O0 -gdwarf-5 test.cpp -S -o test.s -fuse-ld=lld -ffunction-sections
+# It was edited to use D

[Lldb-commits] [PATCH] D53140: [LLDB] - Add support for DW_RLE_base_address and DW_RLE_offset_pair entries (.debug_rnglists)

2018-10-18 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 170050.
grimar added a comment.

- Rebased, resolved conflicts.


https://reviews.llvm.org/D53140

Files:
  lit/Breakpoint/Inputs/debug_rnglist_offset_pair.yaml
  lit/Breakpoint/debug_rnglist_offset_pair.test
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -53,8 +53,7 @@
 class DWARFDebugInfo;
 class DWARFDebugInfoEntry;
 class DWARFDebugLine;
-class DWARFDebugRanges;
-class DWARFDebugRngLists;
+class DWARFDebugRangesBase;
 class DWARFDeclContext;
 class DWARFDIECollection;
 class DWARFFormValue;
@@ -263,9 +262,9 @@
 
   const DWARFDebugInfo *DebugInfo() const;
 
-  DWARFDebugRanges *DebugRanges();
+  DWARFDebugRangesBase *DebugRanges();
 
-  const DWARFDebugRanges *DebugRanges() const;
+  const DWARFDebugRangesBase *DebugRanges() const;
 
   static bool SupportedVersion(uint16_t version);
 
@@ -506,7 +505,7 @@
   typedef std::shared_ptr> DIERefSetSP;
   typedef std::unordered_map NameToOffsetMap;
   NameToOffsetMap m_function_scope_qualified_name_map;
-  std::unique_ptr m_ranges;
+  std::unique_ptr m_ranges;
   UniqueDWARFASTTypeMap m_unique_ast_type_map;
   DIEToTypePtr m_die_to_type;
   DIEToVariableSP m_die_to_variable_sp;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -753,7 +753,7 @@
   return NULL;
 }
 
-DWARFDebugRanges *SymbolFileDWARF::DebugRanges() {
+DWARFDebugRangesBase *SymbolFileDWARF::DebugRanges() {
   if (m_ranges.get() == NULL) {
 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
 Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
@@ -770,7 +770,7 @@
   return m_ranges.get();
 }
 
-const DWARFDebugRanges *SymbolFileDWARF::DebugRanges() const {
+const DWARFDebugRangesBase *SymbolFileDWARF::DebugRanges() const {
   return m_ranges.get();
 }
 
@@ -3328,15 +3328,10 @@
   case DW_AT_start_scope: {
 if (form_value.Form() == DW_FORM_sec_offset) {
   DWARFRangeList dwarf_scope_ranges;
-  const DWARFDebugRanges *debug_ranges = DebugRanges();
-  debug_ranges->FindRanges(die.GetCU()->GetRangesBase(),
+  const DWARFDebugRangesBase *debug_ranges = DebugRanges();
+  debug_ranges->FindRanges(die.GetCU(),
form_value.Unsigned(),
dwarf_scope_ranges);
-
-  // All DW_AT_start_scope are relative to the base address of the
-  // compile unit. We add the compile unit base address to make
-  // sure all the addresses are properly fixed up.
-  dwarf_scope_ranges.Slide(die.GetCU()->GetBaseAddress());
 } else {
   // TODO: Handle the case when DW_AT_start_scope have form
   // constant. The
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -15,18 +15,26 @@
 
 #include 
 
-class DWARFDebugRanges {
+class DWARFDebugRangesBase {
+public:
+  virtual ~DWARFDebugRangesBase(){};
+
+  virtual void Extract(SymbolFileDWARF *dwarf2Data) = 0;
+  virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
+  DWARFRangeList &range_list) const = 0;
+};
+
+class DWARFDebugRanges final : public DWARFDebugRangesBase {
 public:
   DWARFDebugRanges();
-  virtual ~DWARFDebugRanges();
-  virtual void Extract(SymbolFileDWARF *dwarf2Data);
+
+  virtual void Extract(SymbolFileDWARF *dwarf2Data) override;
+  virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
+  DWARFRangeList &range_list) const override;
 
   static void Dump(lldb_private::Stream &s,
const lldb_private::DWARFDataExtractor &debug_ranges_data,
lldb::offset_t *offset_ptr, dw_addr_t cu_base_addr);
-  bool FindRanges(dw_addr_t debug_ranges_base,
-  dw_offset_t debug_ranges_offset,
-  DWARFRangeList &range_list) const;
 
 protected:
   bool Extract(SymbolFileDWARF *dwarf2Data, lldb::offset_t *offset_ptr,
@@ -39,16 +47,25 @@
 };
 
 // DWARF v5 .debug_rnglists section.
-class DWARFDebugRngLists : public DWARFDebugRanges {
+class DWARFDebugRngLists final : public DWARFDebugRangesBase {
+

[Lldb-commits] [PATCH] D53436: [LLDB] - Implement the support for the .debug_loclists section.

2018-10-19 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: clayborg, LLDB.
Herald added subscribers: JDevlieghere, arichardson, aprantl, emaste.
Herald added a reviewer: espindola.

This implements the support for .debug_loclists section, which is
DWARF 5 version of .debug_loc.

Currently, clang is able to emit it with the use of 
https://reviews.llvm.org/D53365.


https://reviews.llvm.org/D53436

Files:
  include/lldb/Expression/DWARFExpression.h
  include/lldb/lldb-enumerations.h
  source/Core/Section.cpp
  source/Expression/DWARFExpression.cpp
  source/Expression/IRExecutionUnit.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -352,6 +352,7 @@
   case eSectionTypeDWARFDebugLine:
   case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
+  case eSectionTypeDWARFDebugLocLists:
   case eSectionTypeDWARFDebugMacInfo:
   case eSectionTypeDWARFDebugMacro:
   case eSectionTypeDWARFDebugNames:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
@@ -30,7 +30,7 @@
   case lldb::eSectionTypeDWARFDebugLine:
 return llvm::DW_SECT_LINE;
   case lldb::eSectionTypeDWARFDebugLoc:
-return llvm::DW_SECT_LOC;
+return llvm::DW_SECT_LOC; 
   case lldb::eSectionTypeDWARFDebugStrOffsets:
 return llvm::DW_SECT_STR_OFFSETS;
   // case lldb::eSectionTypeDWARFDebugMacinfo:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -244,6 +244,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
   const lldb_private::DWARFDataExtractor &get_debug_loc_data();
+  const lldb_private::DWARFDataExtractor &get_debug_loclists_data();
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_data();
@@ -267,6 +268,8 @@
 
   const DWARFDebugRanges *DebugRanges() const;
 
+  const lldb_private::DWARFDataExtractor &DebugLocData();
+
   static bool SupportedVersion(uint16_t version);
 
   DWARFDIE
@@ -475,6 +478,7 @@
   DWARFDataSegment m_data_debug_line_str;
   DWARFDataSegment m_data_debug_macro;
   DWARFDataSegment m_data_debug_loc;
+  DWARFDataSegment m_data_debug_loclists;
   DWARFDataSegment m_data_debug_ranges;
   DWARFDataSegment m_data_debug_rnglists;
   DWARFDataSegment m_data_debug_str;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -650,10 +650,22 @@
   return GetCachedSectionData(eSectionTypeDWARFDebugMacro, m_data_debug_macro);
 }
 
+const DWARFDataExtractor &SymbolFileDWARF::DebugLocData() {
+  const DWARFDataExtractor &debugLocData = get_debug_loc_data();
+  if (debugLocData.GetByteSize() > 0)
+return debugLocData;
+  return get_debug_loclists_data();
+}
+
 const DWARFDataExtractor &SymbolFileDWARF::get_debug_loc_data() {
   return GetCachedSectionData(eSectionTypeDWARFDebugLoc, m_data_debug_loc);
 }
 
+const DWARFDataExtractor &SymbolFileDWARF::get_debug_loclists_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugLocLists,
+  m_data_debug_loclists);
+}
+
 const DWARFDataExtractor &SymbolFileDWARF::get_debug_ranges_data() {
   return GetCachedSectionData(eSectionTypeDWARFDebugRanges,
   m_data_debug_ranges);
@@ -3307,7 +3319,7 @@
   uint32_t block_length = form_value.Unsigned();
   location.CopyOpcodeData(module, data, block_offset, block_length);
 } else {
-  const DWARFDataExtractor &debug_loc_data = get_debug_loc_data();
+  const DWARFDataExtractor &debug_loc_data = DebugLocData();
   const dw_offset_t debug_loc_offset = form_value.Unsigned();
 
   size_t loc_list_length = DWARFExpression::LocationListSize(
@@ -3821,6 +3833,8 @@
 
 DWARFExpression::LocationListFormat
 SymbolFileDW

[Lldb-commits] [PATCH] D53436: [LLDB] - Implement the support for the .debug_loclists section.

2018-10-19 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

Since .debug_loclists contains locations descriptions for objects
that can change location during lifetime, I do not see a way to
write the test without relying on a compiler that has support for
DWARF5. We should compile and run executable to test that location
was calculated properly I believe. Other our tests for DWARF5 sections
recently implemented used YAML and never run any executables.
So, the test case is not included.

At the same time I was able to test it with the following code and invocation:
(trunk clang + https://reviews.llvm.org/D53365 applied):

  ~/LLVM/build/bin/clang -gdwarf-5 test.cc  -o test_v5-fuse-ld=lld -fno-rtti



  struct A { 
int x = 0; 
virtual void foo(); 
  };
  
  void baz(struct A a) { 
   a.foo();
  }
  
  void A::foo() { int x = 0; ++x; }
  
  int main() {
A objA;
objA.x = 3;
baz(objA);
return 0;
  }

After executing the following commands, the location of `a` is properly 
evaluated:

  (lldb) target create "test_v5"
  Current executable set to 'test_v5' (x86_64).
  (lldb) b baz
  Breakpoint 1: where = test_v5`baz(A) + 4 at test.cc:9:6, address = 
0x002010e4
  (lldb) run
  Process 115974 launched: '/home/umb/tests_2018/110_lldbloclists/test_v5' 
(x86_64)
  Process 115974 stopped
  * thread #1, name = 'test_v5', stop reason = breakpoint 1.1
  frame #0: 0x002010e4 test_v5`baz(a=(x = 3)) at test.cc:9:6
 6};
 7   
 8void baz(struct A a) {
  -> 9   a.foo();
 10   }

Without this patch output will be:

  ...
  frame #0: 0x002010e4 test_v5`baz(a=) at test.cc:9:6
  ...


https://reviews.llvm.org/D53436



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


[Lldb-commits] [PATCH] D53436: [LLDB] - Implement the support for the .debug_loclists section.

2018-10-22 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 170468.
grimar added a comment.

- Used lldbassert as suggested.


https://reviews.llvm.org/D53436

Files:
  include/lldb/Expression/DWARFExpression.h
  include/lldb/lldb-enumerations.h
  source/Core/Section.cpp
  source/Expression/DWARFExpression.cpp
  source/Expression/IRExecutionUnit.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -352,6 +352,7 @@
   case eSectionTypeDWARFDebugLine:
   case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
+  case eSectionTypeDWARFDebugLocLists:
   case eSectionTypeDWARFDebugMacInfo:
   case eSectionTypeDWARFDebugMacro:
   case eSectionTypeDWARFDebugNames:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
@@ -30,7 +30,7 @@
   case lldb::eSectionTypeDWARFDebugLine:
 return llvm::DW_SECT_LINE;
   case lldb::eSectionTypeDWARFDebugLoc:
-return llvm::DW_SECT_LOC;
+return llvm::DW_SECT_LOC; 
   case lldb::eSectionTypeDWARFDebugStrOffsets:
 return llvm::DW_SECT_STR_OFFSETS;
   // case lldb::eSectionTypeDWARFDebugMacinfo:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -244,6 +244,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
   const lldb_private::DWARFDataExtractor &get_debug_loc_data();
+  const lldb_private::DWARFDataExtractor &get_debug_loclists_data();
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_data();
@@ -267,6 +268,8 @@
 
   const DWARFDebugRanges *DebugRanges() const;
 
+  const lldb_private::DWARFDataExtractor &DebugLocData();
+
   static bool SupportedVersion(uint16_t version);
 
   DWARFDIE
@@ -475,6 +478,7 @@
   DWARFDataSegment m_data_debug_line_str;
   DWARFDataSegment m_data_debug_macro;
   DWARFDataSegment m_data_debug_loc;
+  DWARFDataSegment m_data_debug_loclists;
   DWARFDataSegment m_data_debug_ranges;
   DWARFDataSegment m_data_debug_rnglists;
   DWARFDataSegment m_data_debug_str;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -650,10 +650,22 @@
   return GetCachedSectionData(eSectionTypeDWARFDebugMacro, m_data_debug_macro);
 }
 
+const DWARFDataExtractor &SymbolFileDWARF::DebugLocData() {
+  const DWARFDataExtractor &debugLocData = get_debug_loc_data();
+  if (debugLocData.GetByteSize() > 0)
+return debugLocData;
+  return get_debug_loclists_data();
+}
+
 const DWARFDataExtractor &SymbolFileDWARF::get_debug_loc_data() {
   return GetCachedSectionData(eSectionTypeDWARFDebugLoc, m_data_debug_loc);
 }
 
+const DWARFDataExtractor &SymbolFileDWARF::get_debug_loclists_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugLocLists,
+  m_data_debug_loclists);
+}
+
 const DWARFDataExtractor &SymbolFileDWARF::get_debug_ranges_data() {
   return GetCachedSectionData(eSectionTypeDWARFDebugRanges,
   m_data_debug_ranges);
@@ -3307,7 +3319,7 @@
   uint32_t block_length = form_value.Unsigned();
   location.CopyOpcodeData(module, data, block_offset, block_length);
 } else {
-  const DWARFDataExtractor &debug_loc_data = get_debug_loc_data();
+  const DWARFDataExtractor &debug_loc_data = DebugLocData();
   const dw_offset_t debug_loc_offset = form_value.Unsigned();
 
   size_t loc_list_length = DWARFExpression::LocationListSize(
@@ -3821,6 +3833,8 @@
 
 DWARFExpression::LocationListFormat
 SymbolFileDWARF::GetLocationListFormat() const {
+  if (m_data_debug_loclists.m_data.GetByteSize() > 0)
+return DWARFExpression::LocLists;
   return DWARFExpression::RegularLocationList;
 }
 
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp

[Lldb-commits] [PATCH] D53436: [LLDB] - Implement the support for the .debug_loclists section.

2018-10-23 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB345016: [LLDB] - Implement the support for the 
.debug_loclists section. (authored by grimar, committed by ).
Herald added a subscriber: abidh.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53436

Files:
  include/lldb/Expression/DWARFExpression.h
  include/lldb/lldb-enumerations.h
  source/Core/Section.cpp
  source/Expression/DWARFExpression.cpp
  source/Expression/IRExecutionUnit.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
  source/Symbol/ObjectFile.cpp

Index: include/lldb/Expression/DWARFExpression.h
===
--- include/lldb/Expression/DWARFExpression.h
+++ include/lldb/Expression/DWARFExpression.h
@@ -41,6 +41,7 @@
 NonLocationList, // Not a location list
 RegularLocationList, // Location list format used in non-split dwarf files
 SplitDwarfLocationList, // Location list format used in split dwarf files
+LocLists,   // Location list format used in DWARF v5 (.debug_loclists).
   };
 
   //--
Index: include/lldb/lldb-enumerations.h
===
--- include/lldb/lldb-enumerations.h
+++ include/lldb/lldb-enumerations.h
@@ -676,6 +676,7 @@
   eSectionTypeOther,
   eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str
   eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists
+  eSectionTypeDWARFDebugLocLists, // DWARF v5 .debug_loclists
 };
 
 FLAGS_ENUM(EmulateInstructionOptions){
Index: source/Core/Section.cpp
===
--- source/Core/Section.cpp
+++ source/Core/Section.cpp
@@ -77,6 +77,8 @@
 return "dwarf-line-str";
   case eSectionTypeDWARFDebugLoc:
 return "dwarf-loc";
+  case eSectionTypeDWARFDebugLocLists:
+return "dwarf-loclists";
   case eSectionTypeDWARFDebugMacInfo:
 return "dwarf-macinfo";
   case eSectionTypeDWARFDebugMacro:
Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -352,6 +352,7 @@
   case eSectionTypeDWARFDebugLine:
   case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
+  case eSectionTypeDWARFDebugLocLists:
   case eSectionTypeDWARFDebugMacInfo:
   case eSectionTypeDWARFDebugMacro:
   case eSectionTypeDWARFDebugNames:
Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1199,6 +1199,7 @@
   case eSectionTypeDWARFDebugLine:
   case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
+  case eSectionTypeDWARFDebugLocLists:
   case eSectionTypeDWARFDebugMacInfo:
   case eSectionTypeDWARFDebugMacro:
   case eSectionTypeDWARFDebugNames:
@@ -1457,6 +1458,7 @@
   static ConstString g_sect_name_dwarf_debug_info("__debug_info");
   static ConstString g_sect_name_dwarf_debug_line("__debug_line");
   static ConstString g_sect_name_dwarf_debug_loc("__debug_loc");
+  static ConstString g_sect_name_dwarf_debug_loclists("__debug_loclists");
   static ConstString g_sect_name_dwarf_debug_macinfo("__debug_macinfo");
   static ConstString g_sect_name_dwarf_debug_names("__debug_names");
   static ConstString g_sect_name_dwarf_debug_pubnames("__debug_pubnames");
@@ -1486,6 +1488,8 @@
 return eSectionTypeDWARFDebugLine;
   if (section_name == g_sect_name_dwarf_debug_loc)
 return eSectionTypeDWARFDebugLoc;
+  if (section_name == g_sect_name_dwarf_debug_loclists)
+return eSectionTypeDWARFDebugLocLists;
   if (section_name == g_sect_name_dwarf_debug_macinfo)
 return eSectionTypeDWARFDebugMacInfo;
   if (section_name == g_sect_name_dwarf_debug_names)
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -691,6 +691,7 @@
 static ConstString g_sect_name_dwarf_debug_info(".debug_info");
 static ConstString g_sect_name_dwarf_debug_line(".debug_line");
 static ConstString g_sect_name_dwarf_debug_loc(".debug_loc");
+static ConstString g_sect_name_dwarf_debug_loclists(".debug_loclists");
 st

[Lldb-commits] [PATCH] D53436: [LLDB] - Implement the support for the .debug_loclists section.

2018-10-23 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345016: [LLDB] - Implement the support for the 
.debug_loclists section. (authored by grimar, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53436?vs=170468&id=170595#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53436

Files:
  lldb/trunk/include/lldb/Expression/DWARFExpression.h
  lldb/trunk/include/lldb/lldb-enumerations.h
  lldb/trunk/source/Core/Section.cpp
  lldb/trunk/source/Expression/DWARFExpression.cpp
  lldb/trunk/source/Expression/IRExecutionUnit.cpp
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
  lldb/trunk/source/Symbol/ObjectFile.cpp

Index: lldb/trunk/source/Core/Section.cpp
===
--- lldb/trunk/source/Core/Section.cpp
+++ lldb/trunk/source/Core/Section.cpp
@@ -77,6 +77,8 @@
 return "dwarf-line-str";
   case eSectionTypeDWARFDebugLoc:
 return "dwarf-loc";
+  case eSectionTypeDWARFDebugLocLists:
+return "dwarf-loclists";
   case eSectionTypeDWARFDebugMacInfo:
 return "dwarf-macinfo";
   case eSectionTypeDWARFDebugMacro:
Index: lldb/trunk/source/Symbol/ObjectFile.cpp
===
--- lldb/trunk/source/Symbol/ObjectFile.cpp
+++ lldb/trunk/source/Symbol/ObjectFile.cpp
@@ -352,6 +352,7 @@
   case eSectionTypeDWARFDebugLine:
   case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
+  case eSectionTypeDWARFDebugLocLists:
   case eSectionTypeDWARFDebugMacInfo:
   case eSectionTypeDWARFDebugMacro:
   case eSectionTypeDWARFDebugNames:
Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -691,6 +691,7 @@
 static ConstString g_sect_name_dwarf_debug_info(".debug_info");
 static ConstString g_sect_name_dwarf_debug_line(".debug_line");
 static ConstString g_sect_name_dwarf_debug_loc(".debug_loc");
+static ConstString g_sect_name_dwarf_debug_loclists(".debug_loclists");
 static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo");
 static ConstString g_sect_name_dwarf_debug_names(".debug_names");
 static ConstString g_sect_name_dwarf_debug_pubnames(".debug_pubnames");
@@ -736,6 +737,8 @@
   section_type = eSectionTypeDWARFDebugLine;
 else if (const_sect_name == g_sect_name_dwarf_debug_loc)
   section_type = eSectionTypeDWARFDebugLoc;
+else if (const_sect_name == g_sect_name_dwarf_debug_loclists)
+  section_type = eSectionTypeDWARFDebugLocLists;
 else if (const_sect_name == g_sect_name_dwarf_debug_macinfo)
   section_type = eSectionTypeDWARFDebugMacInfo;
 else if (const_sect_name == g_sect_name_dwarf_debug_names)
Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1790,6 +1790,7 @@
   static ConstString g_sect_name_dwarf_debug_line(".debug_line");
   static ConstString g_sect_name_dwarf_debug_line_str(".debug_line_str");
   static ConstString g_sect_name_dwarf_debug_loc(".debug_loc");
+  static ConstString g_sect_name_dwarf_debug_loclists(".debug_loclists");
   static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo");
   static ConstString g_sect_name_dwarf_debug_macro(".debug_macro");
   static ConstString g_sect_name_dwarf_debug_names(".debug_names");
@@ -1807,6 +1808,7 @@
   static ConstString g_sect_name_dwarf_debug_line_str_dwo(".debug_line_str.dwo");
   static ConstString g_sect_name_dwarf_debug_macro_dwo(".debug_macro.dwo");
   static ConstString g_sect_name_dwarf_debug_loc_dwo(".debug_loc.dwo");
+  static ConstString g_sect_name_dwarf_debug_loclists_dwo(".debug_loclists.dwo");
   static ConstString g_sect_name_dwarf_debug_str_dwo(".debug_str.dwo");
   static ConstString g_sect_name_dwarf_debug_str_offsets_dwo(
   ".debug_str_offsets.dwo");
@@ -1868,6 +1870,8 @@
 sect_type = eSectionTypeDWARFDebugLineStr;
   else if (name == g_sect_name_dwarf_debug_loc)
 sect_type = eSectionTypeDWARF

[Lldb-commits] [PATCH] D53140: [LLDB] - Add support for DW_RLE_base_address and DW_RLE_offset_pair entries (.debug_rnglists)

2018-10-23 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

Ping.


https://reviews.llvm.org/D53140



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


[Lldb-commits] [PATCH] D53140: [LLDB] - Add support for DW_RLE_base_address and DW_RLE_offset_pair entries (.debug_rnglists)

2018-10-24 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345127: [LLDB] - Add support for DW_RLE_base_address and 
DW_RLE_offset_pair entries (. (authored by grimar, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53140?vs=170050&id=170833#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53140

Files:
  lldb/trunk/lit/Breakpoint/Inputs/debug_rnglist_offset_pair.yaml
  lldb/trunk/lit/Breakpoint/debug_rnglist_offset_pair.test
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -456,20 +456,15 @@
   break;
 
 case DW_AT_ranges: {
-  const DWARFDebugRanges *debug_ranges = dwarf2Data->DebugRanges();
-  if (debug_ranges) {
-debug_ranges->FindRanges(cu->GetRangesBase(), form_value.Unsigned(), ranges);
-// All DW_AT_ranges are relative to the base address of the compile
-// unit. We add the compile unit base address to make sure all the
-// addresses are properly fixed up.
-ranges.Slide(cu->GetBaseAddress());
-  } else {
+  const DWARFDebugRangesBase *debug_ranges = dwarf2Data->DebugRanges();
+  if (debug_ranges)
+debug_ranges->FindRanges(cu, form_value.Unsigned(), ranges);
+  else
 cu->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError(
 "{0x%8.8x}: DIE has DW_AT_ranges(0x%" PRIx64
 ") attribute yet DWARF has no .debug_ranges, please file a bug "
 "and attach the file at the start of this error message",
 m_offset, form_value.Unsigned());
-  }
 } break;
 
 case DW_AT_name:
@@ -1065,10 +1060,8 @@
   dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET,
   check_specification_or_abstract_origin);
   if (debug_ranges_offset != DW_INVALID_OFFSET) {
-if (DWARFDebugRanges *debug_ranges = dwarf2Data->DebugRanges())
-  debug_ranges->FindRanges(cu->GetRangesBase(), debug_ranges_offset,
-   ranges);
-ranges.Slide(cu->GetBaseAddress());
+if (DWARFDebugRangesBase *debug_ranges = dwarf2Data->DebugRanges())
+  debug_ranges->FindRanges(cu, debug_ranges_offset, ranges);
   } else if (check_hi_lo_pc) {
 dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
 dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
@@ -1723,12 +1716,9 @@
 dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
 if (debug_ranges_offset != DW_INVALID_OFFSET) {
   DWARFRangeList ranges;
-  DWARFDebugRanges *debug_ranges = dwarf2Data->DebugRanges();
-  debug_ranges->FindRanges(cu->GetRangesBase(), debug_ranges_offset, ranges);
-  // All DW_AT_ranges are relative to the base address of the compile
-  // unit. We add the compile unit base address to make sure all the
-  // addresses are properly fixed up.
-  ranges.Slide(cu->GetBaseAddress());
+  DWARFDebugRangesBase *debug_ranges = dwarf2Data->DebugRanges();
+  debug_ranges->FindRanges(cu, debug_ranges_offset, ranges);
+
   if (ranges.FindEntryThatContains(address)) {
 found_address = true;
 //  puts("***MATCH***");
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -53,8 +53,7 @@
 class DWARFDebugInfo;
 class DWARFDebugInfoEntry;
 class DWARFDebugLine;
-class DWARFDebugRanges;
-class DWARFDebugRngLists;
+class DWARFDebugRangesBase;
 class DWARFDeclContext;
 class DWARFDIECollection;
 class DWARFFormValue;
@@ -266,9 +265,9 @@
 
   const DWARFDebugInfo *DebugInfo() const;
 
-  DWARFDebugRanges *DebugRanges();
+  DWARFDebugRangesBase *DebugRanges();
 
-  const DWARFDebugRanges *DebugRanges() const;
+  const DWARFDebugRangesBase *DebugRanges() const;
 
   const lldb_private::DWARFDataExtractor &DebugLocData();
 
@@ -512,7 +511,7 @@
   typedef std::shared_ptr> DIERefSetSP;
   typedef std::unordered_map NameToOffsetMap;
   NameToOffsetMap m_function_scope_qualified_name_map;
-  std::unique_ptr m_ranges;
+  std::unique_ptr m_ranges;
   UniqueDWARFASTTypeMap m_unique_ast_type_map;
   DIEToTypePtr m_die_to_type;
   DIEToVariableSP m_die_to_variable_sp;
Ind

[Lldb-commits] [PATCH] D53646: [LLDB] - Parse the DW_LLE_startx_length correctly for DWARF v5 case.

2018-10-24 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg.
Herald added subscribers: JDevlieghere, aprantl.

Currently, we always parse the `length` field of DW_LLE_startx_length entry as 
U32.
That is correct for pre-standard definition:

https://gcc.gnu.org/wiki/DebugFission - "A start/length entry contains one 
unsigned LEB128 number
and a 4-byte unsigned value (as would be represented by the form code 
DW_FORM_const4u). The first
number is an index into the .debug_addr section that selects the beginning 
offset, and the second
number is the length of the range. ")

But DWARF v5 says: "This is a form of bounded location description that has two 
unsigned ULEB operands.
The first value is an address index (into the .debug_addr section) that 
indicates the beginning of the address
range over which the location is valid. The second value is the length of the 
range."

Fortunately, we can easily handle the difference. No test case because it seems 
impossible to test
until we will be ready to use DWARF v5 in tests that need to run the 
executables.


https://reviews.llvm.org/D53646

Files:
  include/lldb/Expression/DWARFExpression.h
  source/Expression/DWARFExpression.cpp


Index: source/Expression/DWARFExpression.cpp
===
--- source/Expression/DWARFExpression.cpp
+++ source/Expression/DWARFExpression.cpp
@@ -3029,7 +3029,9 @@
   if (!debug_loc_data.ValidOffset(*offset_ptr))
 return false;
 
-  switch (dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat()) {
+  DWARFExpression::LocationListFormat format =
+  dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat();
+  switch (format) {
   case NonLocationList:
 return false;
   case RegularLocationList:
@@ -3051,7 +3053,9 @@
 case DW_LLE_startx_length: {
   uint64_t index = debug_loc_data.GetULEB128(offset_ptr);
   low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
-  uint32_t length = debug_loc_data.GetU32(offset_ptr);
+  uint64_t length = (format == LocLists)
+? debug_loc_data.GetULEB128(offset_ptr)
+: debug_loc_data.GetU32(offset_ptr);
   high_pc = low_pc + length;
   return true;
 }
Index: include/lldb/Expression/DWARFExpression.h
===
--- include/lldb/Expression/DWARFExpression.h
+++ include/lldb/Expression/DWARFExpression.h
@@ -40,8 +40,10 @@
   enum LocationListFormat : uint8_t {
 NonLocationList, // Not a location list
 RegularLocationList, // Location list format used in non-split dwarf files
-SplitDwarfLocationList, // Location list format used in split dwarf files
-LocLists,   // Location list format used in DWARF v5 
(.debug_loclists).
+SplitDwarfLocationList, // Location list format used in pre-DWARF v5 split
+// dwarf files (.debug_loc.dwo)
+LocLists,   // Location list format used in DWARF v5
+// (.debug_loclists/.debug_loclists.dwo).
   };
 
   //--
@@ -153,7 +155,7 @@
   lldb::addr_t GetLocation_DW_OP_addr(uint32_t op_addr_idx, bool &error) const;
 
   bool Update_DW_OP_addr(lldb::addr_t file_addr);
-  
+
   void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; }
 
   bool ContainsThreadLocalStorage() const;


Index: source/Expression/DWARFExpression.cpp
===
--- source/Expression/DWARFExpression.cpp
+++ source/Expression/DWARFExpression.cpp
@@ -3029,7 +3029,9 @@
   if (!debug_loc_data.ValidOffset(*offset_ptr))
 return false;
 
-  switch (dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat()) {
+  DWARFExpression::LocationListFormat format =
+  dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat();
+  switch (format) {
   case NonLocationList:
 return false;
   case RegularLocationList:
@@ -3051,7 +3053,9 @@
 case DW_LLE_startx_length: {
   uint64_t index = debug_loc_data.GetULEB128(offset_ptr);
   low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
-  uint32_t length = debug_loc_data.GetU32(offset_ptr);
+  uint64_t length = (format == LocLists)
+? debug_loc_data.GetULEB128(offset_ptr)
+: debug_loc_data.GetU32(offset_ptr);
   high_pc = low_pc + length;
   return true;
 }
Index: include/lldb/Expression/DWARFExpression.h
===
--- include/lldb/Expression/DWARFExpression.h
+++ include/lldb/Expression/DWARFExpression.h
@@ -40,8 +40,10 @@
   enum LocationListFormat : uint8_t {
 NonLocationList, // Not a location list
 RegularLocationList, // Location list format used in non-split dwarf files
-SplitDwarfLocationList, // Location list format used in split dwarf files
-Loc

[Lldb-commits] [PATCH] D53646: [LLDB] - Parse the DW_LLE_startx_length correctly for DWARF v5 case.

2018-10-25 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB345249: [LLDB] - Parse the DW_LLE_startx_length correctly 
for DWARF v5 case. (authored by grimar, committed by ).
Herald added a subscriber: lldb-commits.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53646

Files:
  include/lldb/Expression/DWARFExpression.h
  source/Expression/DWARFExpression.cpp


Index: source/Expression/DWARFExpression.cpp
===
--- source/Expression/DWARFExpression.cpp
+++ source/Expression/DWARFExpression.cpp
@@ -3029,7 +3029,9 @@
   if (!debug_loc_data.ValidOffset(*offset_ptr))
 return false;
 
-  switch (dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat()) {
+  DWARFExpression::LocationListFormat format =
+  dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat();
+  switch (format) {
   case NonLocationList:
 return false;
   case RegularLocationList:
@@ -3051,7 +3053,9 @@
 case DW_LLE_startx_length: {
   uint64_t index = debug_loc_data.GetULEB128(offset_ptr);
   low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
-  uint32_t length = debug_loc_data.GetU32(offset_ptr);
+  uint64_t length = (format == LocLists)
+? debug_loc_data.GetULEB128(offset_ptr)
+: debug_loc_data.GetU32(offset_ptr);
   high_pc = low_pc + length;
   return true;
 }
Index: include/lldb/Expression/DWARFExpression.h
===
--- include/lldb/Expression/DWARFExpression.h
+++ include/lldb/Expression/DWARFExpression.h
@@ -40,8 +40,10 @@
   enum LocationListFormat : uint8_t {
 NonLocationList, // Not a location list
 RegularLocationList, // Location list format used in non-split dwarf files
-SplitDwarfLocationList, // Location list format used in split dwarf files
-LocLists,   // Location list format used in DWARF v5 
(.debug_loclists).
+SplitDwarfLocationList, // Location list format used in pre-DWARF v5 split
+// dwarf files (.debug_loc.dwo)
+LocLists,   // Location list format used in DWARF v5
+// (.debug_loclists/.debug_loclists.dwo).
   };
 
   //--
@@ -153,7 +155,7 @@
   lldb::addr_t GetLocation_DW_OP_addr(uint32_t op_addr_idx, bool &error) const;
 
   bool Update_DW_OP_addr(lldb::addr_t file_addr);
-  
+
   void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; }
 
   bool ContainsThreadLocalStorage() const;


Index: source/Expression/DWARFExpression.cpp
===
--- source/Expression/DWARFExpression.cpp
+++ source/Expression/DWARFExpression.cpp
@@ -3029,7 +3029,9 @@
   if (!debug_loc_data.ValidOffset(*offset_ptr))
 return false;
 
-  switch (dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat()) {
+  DWARFExpression::LocationListFormat format =
+  dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat();
+  switch (format) {
   case NonLocationList:
 return false;
   case RegularLocationList:
@@ -3051,7 +3053,9 @@
 case DW_LLE_startx_length: {
   uint64_t index = debug_loc_data.GetULEB128(offset_ptr);
   low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
-  uint32_t length = debug_loc_data.GetU32(offset_ptr);
+  uint64_t length = (format == LocLists)
+? debug_loc_data.GetULEB128(offset_ptr)
+: debug_loc_data.GetU32(offset_ptr);
   high_pc = low_pc + length;
   return true;
 }
Index: include/lldb/Expression/DWARFExpression.h
===
--- include/lldb/Expression/DWARFExpression.h
+++ include/lldb/Expression/DWARFExpression.h
@@ -40,8 +40,10 @@
   enum LocationListFormat : uint8_t {
 NonLocationList, // Not a location list
 RegularLocationList, // Location list format used in non-split dwarf files
-SplitDwarfLocationList, // Location list format used in split dwarf files
-LocLists,   // Location list format used in DWARF v5 (.debug_loclists).
+SplitDwarfLocationList, // Location list format used in pre-DWARF v5 split
+// dwarf files (.debug_loc.dwo)
+LocLists,   // Location list format used in DWARF v5
+// (.debug_loclists/.debug_loclists.dwo).
   };
 
   //--
@@ -153,7 +155,7 @@
   lldb::addr_t GetLocation_DW_OP_addr(uint32_t op_addr_idx, bool &error) const;
 
   bool Update_DW_OP_addr(lldb::addr_t file_addr);
-  
+
   void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; }
 
   bool ContainsThreadLocalStorage() const;
___
lldb-commits mailing list
l

[Lldb-commits] [PATCH] D53813: [LLDB] - Add support for DW_FORM_rnglistx, DW_FORM_addrx[1-4]? forms.

2018-10-29 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg.
Herald added a subscriber: JDevlieghere.

This adds the support for DW_FORM_rnglistx, DW_FORM_addrx, DW_FORM_addrx1, 
DW_FORM_addrx2, DW_FORM_addrx3, DW_FORM_addrx4 forms.


https://reviews.llvm.org/D53813

Files:
  lit/Breakpoint/Inputs/debug_rnglistx_addrx.yaml
  lit/Breakpoint/debug_rnglistx_addrx.test
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -111,8 +111,9 @@
   dw_addr_t GetBaseAddress() const { return m_base_addr; }
   dw_addr_t GetAddrBase() const { return m_addr_base; }
   dw_addr_t GetRangesBase() const { return m_ranges_base; }
-  void SetAddrBase(dw_addr_t addr_base, dw_addr_t ranges_base,
-   dw_offset_t base_obj_offset);
+  void SetAddrBase(dw_addr_t addr_base);
+  void SetRangesBase(dw_addr_t ranges_base);
+  void SetBaseObjOffset(dw_offset_t base_obj_offset);
   void BuildAddressRangeTable(SymbolFileDWARF *dwarf,
   DWARFDebugAranges *debug_aranges);
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -307,6 +307,9 @@
 
 // m_die_array_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
+  SetAddrBase(
+  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+
   uint64_t base_addr = cu_die.GetAttributeValueAsAddress(
   m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
   if (base_addr == LLDB_INVALID_ADDRESS)
@@ -339,9 +342,13 @@
 
   dw_addr_t addr_base =
   cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
+  dwo_cu->SetAddrBase(addr_base);
+
   dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
   m_dwarf, this, DW_AT_GNU_ranges_base, 0);
-  dwo_cu->SetAddrBase(addr_base, ranges_base, m_offset);
+  dwo_cu->SetRangesBase(ranges_base);
+
+  dwo_cu->SetBaseObjOffset(m_offset);
 }
 
 DWARFDIE DWARFUnit::LookupAddress(const dw_addr_t address) {
@@ -399,11 +406,13 @@
   return m_abbrevs ? m_abbrevs->GetOffset() : DW_INVALID_OFFSET;
 }
 
-void DWARFUnit::SetAddrBase(dw_addr_t addr_base,
-dw_addr_t ranges_base,
-dw_offset_t base_obj_offset) {
-  m_addr_base = addr_base;
+void DWARFUnit::SetAddrBase(dw_addr_t addr_base) { m_addr_base = addr_base; }
+
+void DWARFUnit::SetRangesBase(dw_addr_t ranges_base) {
   m_ranges_base = ranges_base;
+}
+
+void DWARFUnit::SetBaseObjOffset(dw_offset_t base_obj_offset) {
   m_base_obj_offset = base_obj_offset;
 }
 
Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -233,18 +233,23 @@
   m_value.value.uval =
   data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4);
   break;
+case DW_FORM_addrx:
 case DW_FORM_strx:
   m_value.value.uval = data.GetULEB128(offset_ptr);
   break;
+case DW_FORM_addrx1:
 case DW_FORM_strx1:
   m_value.value.uval = data.GetU8(offset_ptr);
   break;
+case DW_FORM_addrx2:
 case DW_FORM_strx2:
   m_value.value.uval = data.GetU16(offset_ptr);
   break;
+case DW_FORM_addrx3:
 case DW_FORM_strx3:
   m_value.value.uval = data.GetMaxU64(offset_ptr, 3);
   break;
+case DW_FORM_addrx4:
 case DW_FORM_strx4:
   m_value.value.uval = data.GetU32(offset_ptr);
   break;
@@ -376,21 +381,24 @@
 return true;
 
 // 1 byte values
+case DW_FORM_addrx1:
 case DW_FORM_data1:
 case DW_FORM_flag:
 case DW_FORM_ref1:
 case DW_FORM_strx1:
   *offset_ptr += 1;
   return true;
 
 // 2 byte values
+case DW_FORM_addrx2:
 case DW_FORM_data2:
 case DW_FORM_ref2:
 case DW_FORM_strx2:
   *offset_ptr += 2;
   return true;
 
 // 3 byte values
+case DW_FORM_addrx3:
 case DW_FORM_strx3:
   *offset_ptr += 3;
   return true;
@@ -403,6 +411,7 @@
   return true;
 
 // 4 byte values
+case DW_FORM_addrx4:
 case DW_FORM_data4:
 case DW_FORM_ref4:
 case DW_FORM_strx4:
@@ -417,6 +426,8 @@
   return true;
 
 // signed or unsigned LEB 128 values
+case DW_FORM_addrx:
+case DW_FORM_rnglistx:
 case DW_FORM_sdata:
 case DW_FORM_udata:
 case DW_FORM_ref_udata:
@@ -625,7 +636,9 @@
 return Unsigned();
 
   assert(m_cu);
-  assert(m_

[Lldb-commits] [PATCH] D53813: [LLDB] - Add support for DW_FORM_rnglistx, DW_FORM_addrx[1-4]? forms.

2018-10-29 Thread George Rimar via Phabricator via lldb-commits
grimar planned changes to this revision.
grimar added a comment.

Planning changes. Going to remove the DW_FORM_rnglistx support from this patch, 
found it is incomplete and has other issues.


https://reviews.llvm.org/D53813



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


[Lldb-commits] [PATCH] D53813: [LLDB] - Add support for DW_FORM_addrx[1-4]? forms.

2018-10-29 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 171517.
grimar retitled this revision from "[LLDB] - Add support for DW_FORM_rnglistx, 
DW_FORM_addrx[1-4]? forms." to "[LLDB] - Add support for DW_FORM_addrx[1-4]? 
forms.".
grimar edited the summary of this revision.
grimar added a comment.

- Removed DW_FORM_rnglistx from this patch.


https://reviews.llvm.org/D53813

Files:
  lit/Breakpoint/Inputs/debug_addrx.yaml
  lit/Breakpoint/debug_addrx.test
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -111,8 +111,9 @@
   dw_addr_t GetBaseAddress() const { return m_base_addr; }
   dw_addr_t GetAddrBase() const { return m_addr_base; }
   dw_addr_t GetRangesBase() const { return m_ranges_base; }
-  void SetAddrBase(dw_addr_t addr_base, dw_addr_t ranges_base,
-   dw_offset_t base_obj_offset);
+  void SetAddrBase(dw_addr_t addr_base);
+  void SetRangesBase(dw_addr_t ranges_base);
+  void SetBaseObjOffset(dw_offset_t base_obj_offset);
   void BuildAddressRangeTable(SymbolFileDWARF *dwarf,
   DWARFDebugAranges *debug_aranges);
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -307,6 +307,9 @@
 
 // m_die_array_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
+  SetAddrBase(
+  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+
   uint64_t base_addr = cu_die.GetAttributeValueAsAddress(
   m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
   if (base_addr == LLDB_INVALID_ADDRESS)
@@ -339,9 +342,13 @@
 
   dw_addr_t addr_base =
   cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
+  dwo_cu->SetAddrBase(addr_base);
+
   dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
   m_dwarf, this, DW_AT_GNU_ranges_base, 0);
-  dwo_cu->SetAddrBase(addr_base, ranges_base, m_offset);
+  dwo_cu->SetRangesBase(ranges_base);
+
+  dwo_cu->SetBaseObjOffset(m_offset);
 }
 
 DWARFDIE DWARFUnit::LookupAddress(const dw_addr_t address) {
@@ -399,11 +406,13 @@
   return m_abbrevs ? m_abbrevs->GetOffset() : DW_INVALID_OFFSET;
 }
 
-void DWARFUnit::SetAddrBase(dw_addr_t addr_base,
-dw_addr_t ranges_base,
-dw_offset_t base_obj_offset) {
-  m_addr_base = addr_base;
+void DWARFUnit::SetAddrBase(dw_addr_t addr_base) { m_addr_base = addr_base; }
+
+void DWARFUnit::SetRangesBase(dw_addr_t ranges_base) {
   m_ranges_base = ranges_base;
+}
+
+void DWARFUnit::SetBaseObjOffset(dw_offset_t base_obj_offset) {
   m_base_obj_offset = base_obj_offset;
 }
 
Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -233,18 +233,23 @@
   m_value.value.uval =
   data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4);
   break;
+case DW_FORM_addrx:
 case DW_FORM_strx:
   m_value.value.uval = data.GetULEB128(offset_ptr);
   break;
+case DW_FORM_addrx1:
 case DW_FORM_strx1:
   m_value.value.uval = data.GetU8(offset_ptr);
   break;
+case DW_FORM_addrx2:
 case DW_FORM_strx2:
   m_value.value.uval = data.GetU16(offset_ptr);
   break;
+case DW_FORM_addrx3:
 case DW_FORM_strx3:
   m_value.value.uval = data.GetMaxU64(offset_ptr, 3);
   break;
+case DW_FORM_addrx4:
 case DW_FORM_strx4:
   m_value.value.uval = data.GetU32(offset_ptr);
   break;
@@ -376,21 +381,24 @@
 return true;
 
 // 1 byte values
+case DW_FORM_addrx1:
 case DW_FORM_data1:
 case DW_FORM_flag:
 case DW_FORM_ref1:
 case DW_FORM_strx1:
   *offset_ptr += 1;
   return true;
 
 // 2 byte values
+case DW_FORM_addrx2:
 case DW_FORM_data2:
 case DW_FORM_ref2:
 case DW_FORM_strx2:
   *offset_ptr += 2;
   return true;
 
 // 3 byte values
+case DW_FORM_addrx3:
 case DW_FORM_strx3:
   *offset_ptr += 3;
   return true;
@@ -403,6 +411,7 @@
   return true;
 
 // 4 byte values
+case DW_FORM_addrx4:
 case DW_FORM_data4:
 case DW_FORM_ref4:
 case DW_FORM_strx4:
@@ -417,6 +426,7 @@
   return true;
 
 // signed or unsigned LEB 128 values
+case DW_FORM_addrx:
 case DW_FORM_sdata:
 case DW_FORM_udata:
 case DW_FORM_ref_udata:
@@ -625,7 +635,9 @@
 return Unsign

[Lldb-commits] [PATCH] D53813: [LLDB] - Add support for DW_FORM_addrx[1-4]? forms.

2018-10-30 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

I have a patch for `DW_FORM_rnglistx`. Will be happy to land this one first 
though, as they share a code in DWARFUnit.h/cpp a bit.


https://reviews.llvm.org/D53813



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


[Lldb-commits] [PATCH] D53813: [LLDB] - Add support for DW_FORM_addrx[1-4]? forms.

2018-10-31 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345706: [LLDB] - Add support for DW_FORM_addrx[1-4]? forms. 
(authored by grimar, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53813?vs=171517&id=171880#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53813

Files:
  lldb/trunk/lit/Breakpoint/Inputs/debug_addrx.yaml
  lldb/trunk/lit/Breakpoint/debug_addrx.test
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -233,18 +233,23 @@
   m_value.value.uval =
   data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4);
   break;
+case DW_FORM_addrx:
 case DW_FORM_strx:
   m_value.value.uval = data.GetULEB128(offset_ptr);
   break;
+case DW_FORM_addrx1:
 case DW_FORM_strx1:
   m_value.value.uval = data.GetU8(offset_ptr);
   break;
+case DW_FORM_addrx2:
 case DW_FORM_strx2:
   m_value.value.uval = data.GetU16(offset_ptr);
   break;
+case DW_FORM_addrx3:
 case DW_FORM_strx3:
   m_value.value.uval = data.GetMaxU64(offset_ptr, 3);
   break;
+case DW_FORM_addrx4:
 case DW_FORM_strx4:
   m_value.value.uval = data.GetU32(offset_ptr);
   break;
@@ -376,21 +381,24 @@
 return true;
 
 // 1 byte values
+case DW_FORM_addrx1:
 case DW_FORM_data1:
 case DW_FORM_flag:
 case DW_FORM_ref1:
 case DW_FORM_strx1:
   *offset_ptr += 1;
   return true;
 
 // 2 byte values
+case DW_FORM_addrx2:
 case DW_FORM_data2:
 case DW_FORM_ref2:
 case DW_FORM_strx2:
   *offset_ptr += 2;
   return true;
 
 // 3 byte values
+case DW_FORM_addrx3:
 case DW_FORM_strx3:
   *offset_ptr += 3;
   return true;
@@ -403,6 +411,7 @@
   return true;
 
 // 4 byte values
+case DW_FORM_addrx4:
 case DW_FORM_data4:
 case DW_FORM_ref4:
 case DW_FORM_strx4:
@@ -417,6 +426,7 @@
   return true;
 
 // signed or unsigned LEB 128 values
+case DW_FORM_addrx:
 case DW_FORM_sdata:
 case DW_FORM_udata:
 case DW_FORM_ref_udata:
@@ -625,7 +635,9 @@
 return Unsigned();
 
   assert(m_cu);
-  assert(m_form == DW_FORM_GNU_addr_index);
+  assert(m_form == DW_FORM_GNU_addr_index || m_form == DW_FORM_addrx ||
+ m_form == DW_FORM_addrx1 || m_form == DW_FORM_addrx2 ||
+ m_form == DW_FORM_addrx3 || m_form == DW_FORM_addrx4);
 
   if (!symbol_file)
 return 0;
@@ -798,6 +810,7 @@
 bool DWARFFormValue::FormIsSupported(dw_form_t form) {
   switch (form) {
 case DW_FORM_addr:
+case DW_FORM_addrx:
 case DW_FORM_block2:
 case DW_FORM_block4:
 case DW_FORM_data2:
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -307,6 +307,9 @@
 
 // m_die_array_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
+  SetAddrBase(
+  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+
   uint64_t base_addr = cu_die.GetAttributeValueAsAddress(
   m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
   if (base_addr == LLDB_INVALID_ADDRESS)
@@ -339,9 +342,13 @@
 
   dw_addr_t addr_base =
   cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
+  dwo_cu->SetAddrBase(addr_base);
+
   dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
   m_dwarf, this, DW_AT_GNU_ranges_base, 0);
-  dwo_cu->SetAddrBase(addr_base, ranges_base, m_offset);
+  dwo_cu->SetRangesBase(ranges_base);
+
+  dwo_cu->SetBaseObjOffset(m_offset);
 }
 
 DWARFDIE DWARFUnit::LookupAddress(const dw_addr_t address) {
@@ -399,11 +406,13 @@
   return m_abbrevs ? m_abbrevs->GetOffset() : DW_INVALID_OFFSET;
 }
 
-void DWARFUnit::SetAddrBase(dw_addr_t addr_base,
-dw_addr_t ranges_base,
-dw_offset_t base_obj_offset) {
-  m_addr_base = addr_base;
+void DWARFUnit::SetAddrBase(dw_addr_t addr_base) { m_addr_base = addr_base; }
+
+void DWARFUnit::SetRangesBase(dw_addr_t ranges_base) {
   m_ranges_base = ranges_base;
+}
+
+void DWARFUnit::SetBaseObjOffset(dw_offset_t base_obj_offset) {
   m_base_obj_offset = base_obj_offset;
 }
 
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
=

[Lldb-commits] [PATCH] D53929: [LLDB] - Add support for DW_FORM_rnglistx and relative DW_RLE_* entries.

2018-10-31 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg.
Herald added a subscriber: JDevlieghere.

This adds support for DW_RLE_base_addressx, DW_RLE_startx_endx,
DW_RLE_startx_length, DW_FORM_rnglistx.


https://reviews.llvm.org/D53929

Files:
  lit/Breakpoint/Inputs/debug_rnglistx_rlex.yaml
  lit/Breakpoint/debug_rnglistx_rlex.test
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -309,6 +309,8 @@
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
   SetAddrBase(
   cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+  SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
+   DW_AT_rnglists_base, 0));
 
   uint64_t base_addr = cu_die.GetAttributeValueAsAddress(
   m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -234,6 +234,7 @@
   data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4);
   break;
 case DW_FORM_addrx:
+case DW_FORM_rnglistx:
 case DW_FORM_strx:
   m_value.value.uval = data.GetULEB128(offset_ptr);
   break;
@@ -427,6 +428,7 @@
 
 // signed or unsigned LEB 128 values
 case DW_FORM_addrx:
+case DW_FORM_rnglistx:
 case DW_FORM_sdata:
 case DW_FORM_udata:
 case DW_FORM_ref_udata:
@@ -811,6 +813,7 @@
   switch (form) {
 case DW_FORM_addr:
 case DW_FORM_addrx:
+case DW_FORM_rnglistx:
 case DW_FORM_block2:
 case DW_FORM_block4:
 case DW_FORM_data2:
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -22,15 +22,17 @@
   virtual void Extract(SymbolFileDWARF *dwarf2Data) = 0;
   virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
   DWARFRangeList &range_list) const = 0;
+  virtual uint64_t GetOffset(size_t Index) = 0;
 };
 
 class DWARFDebugRanges final : public DWARFDebugRangesBase {
 public:
   DWARFDebugRanges();
 
-  virtual void Extract(SymbolFileDWARF *dwarf2Data) override;
-  virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
-  DWARFRangeList &range_list) const override;
+  void Extract(SymbolFileDWARF *dwarf2Data) override;
+  bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
+  DWARFRangeList &range_list) const override;
+  uint64_t GetOffset(size_t Index) override;
 
   static void Dump(lldb_private::Stream &s,
const lldb_private::DWARFDataExtractor &debug_ranges_data,
@@ -58,6 +60,7 @@
   void Extract(SymbolFileDWARF *dwarf2Data) override;
   bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
   DWARFRangeList &range_list) const override;
+  uint64_t GetOffset(size_t Index) override;
 
 protected:
   bool ExtractRangeList(const lldb_private::DWARFDataExtractor &data,
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
@@ -128,6 +128,11 @@
   return false;
 }
 
+uint64_t DWARFDebugRanges::GetOffset(size_t Index) {
+  lldbassert(false && "DW_FORM_rnglistx is not present before DWARF5");
+  return 0;
+}
+
 bool DWARFDebugRngLists::ExtractRangeList(
 const DWARFDataExtractor &data, uint8_t addrSize,
 lldb::offset_t *offset_ptr, std::vector &rangeList) {
@@ -166,17 +171,44 @@
   break;
 }
 
+case DW_RLE_base_addressx: {
+  dw_addr_t base = data.GetULEB128(offset_ptr);
+  rangeList.push_back({DW_RLE_base_addressx, base, 0});
+  break;
+}
+
+case DW_RLE_startx_endx: {
+  dw_addr_t start = data.GetULEB128(offset_ptr);
+  dw_addr_t end = data.GetULEB128(offset_ptr);
+  rangeList.push_back({DW_RLE_startx_endx, start, end});
+  break;
+}
+
+case DW_RLE_startx_length: {
+  dw_addr_t start = data.GetULEB128(offset_ptr);
+  dw_addr_t length = data.GetULEB128(offset_ptr);
+  rangeList.push_back({DW_RLE_startx_length, start, length});
+  break;
+}
+
 default:
-  // Next encodings are n

[Lldb-commits] [PATCH] D52981: [LLDB] - Add basic support for .debug_rnglists section (DWARF5)

2018-10-31 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp:163
+  uint64_t length = data.GetU32(&offset);
+  bool isDwarf64 = false;
+  if (length == 0x) {

xbolva00 wrote:
> variable is not used anywhere
Removed in r345720, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D52981



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


[Lldb-commits] [PATCH] D53929: [LLDB] - Add support for DW_FORM_rnglistx and relative DW_RLE_* entries.

2018-11-01 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 172121.
grimar added a comment.

- Addressed review comments.


https://reviews.llvm.org/D53929

Files:
  lit/Breakpoint/Inputs/debug_rnglistx_rlex.yaml
  lit/Breakpoint/debug_rnglistx_rlex.test
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -309,6 +309,8 @@
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
   SetAddrBase(
   cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+  SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
+   DW_AT_rnglists_base, 0));
 
   uint64_t base_addr = cu_die.GetAttributeValueAsAddress(
   m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -248,6 +248,7 @@
   m_value.value.uval = data.GetU64(offset_ptr);
   break;
 case DW_FORM_addrx:
+case DW_FORM_rnglistx:
 case DW_FORM_strx:
 case DW_FORM_udata:
 case DW_FORM_ref_udata:
@@ -393,6 +394,7 @@
 
 // signed or unsigned LEB 128 values
 case DW_FORM_addrx:
+case DW_FORM_rnglistx:
 case DW_FORM_sdata:
 case DW_FORM_udata:
 case DW_FORM_ref_udata:
@@ -777,6 +779,7 @@
   switch (form) {
 case DW_FORM_addr:
 case DW_FORM_addrx:
+case DW_FORM_rnglistx:
 case DW_FORM_block2:
 case DW_FORM_block4:
 case DW_FORM_data2:
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -22,15 +22,17 @@
   virtual void Extract(SymbolFileDWARF *dwarf2Data) = 0;
   virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
   DWARFRangeList &range_list) const = 0;
+  virtual uint64_t GetOffset(size_t Index) const = 0;
 };
 
 class DWARFDebugRanges final : public DWARFDebugRangesBase {
 public:
   DWARFDebugRanges();
 
-  virtual void Extract(SymbolFileDWARF *dwarf2Data) override;
-  virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
-  DWARFRangeList &range_list) const override;
+  void Extract(SymbolFileDWARF *dwarf2Data) override;
+  bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
+  DWARFRangeList &range_list) const override;
+  uint64_t GetOffset(size_t Index) const override;
 
   static void Dump(lldb_private::Stream &s,
const lldb_private::DWARFDataExtractor &debug_ranges_data,
@@ -58,6 +60,7 @@
   void Extract(SymbolFileDWARF *dwarf2Data) override;
   bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
   DWARFRangeList &range_list) const override;
+  uint64_t GetOffset(size_t Index) const override;
 
 protected:
   bool ExtractRangeList(const lldb_private::DWARFDataExtractor &data,
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
@@ -128,6 +128,11 @@
   return false;
 }
 
+uint64_t DWARFDebugRanges::GetOffset(size_t Index) const {
+  lldbassert(false && "DW_FORM_rnglistx is not present before DWARF5");
+  return 0;
+}
+
 bool DWARFDebugRngLists::ExtractRangeList(
 const DWARFDataExtractor &data, uint8_t addrSize,
 lldb::offset_t *offset_ptr, std::vector &rangeList) {
@@ -166,17 +171,44 @@
   break;
 }
 
+case DW_RLE_base_addressx: {
+  dw_addr_t base = data.GetULEB128(offset_ptr);
+  rangeList.push_back({DW_RLE_base_addressx, base, 0});
+  break;
+}
+
+case DW_RLE_startx_endx: {
+  dw_addr_t start = data.GetULEB128(offset_ptr);
+  dw_addr_t end = data.GetULEB128(offset_ptr);
+  rangeList.push_back({DW_RLE_startx_endx, start, end});
+  break;
+}
+
+case DW_RLE_startx_length: {
+  dw_addr_t start = data.GetULEB128(offset_ptr);
+  dw_addr_t length = data.GetULEB128(offset_ptr);
+  rangeList.push_back({DW_RLE_startx_length, start, length});
+  break;
+}
+
 default:
-  // Next encodings are not yet supported:
-  // DW_RLE_base_addressx, DW_RLE_startx_endx, DW_RLE_startx_length.
   lldbassert(0 && "unknown range li

[Lldb-commits] [PATCH] D53929: [LLDB] - Add support for DW_FORM_rnglistx and relative DW_RLE_* entries.

2018-11-01 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp:1072-1079
+  if (at_ranges_val != DW_INVALID_OFFSET) {
+if (DWARFDebugRangesBase *debug_ranges = dwarf2Data->DebugRanges()) {
+
+  dw_offset_t debug_ranges_offset;
+  if (form_value.Form() == DW_FORM_rnglistx)
+debug_ranges_offset = debug_ranges->GetOffset(at_ranges_val);
+  else

clayborg wrote:
> Can/should we do all this work when we extract the form value so that 
> "form_value.Unsigned()" just returns the right thing? If not, every place 
> that gets DW_AT_ranges attribute would need to do this.
Doing everything inside `DWARFFormValue::ExtractValue` would make the callers 
code simpler indeed,
but my concern is that it would mean that instead of the attribute value 
requested it would return the offset value read from `.debug_rnglists` section. 
I am not sure it is good idea to read any debug section content at that low 
level. 

I think 'ExtractValue` ideally should not know about the debug sections. And 
also that would not be consistent with the other forms it reads. I am not sure 
if we might want to know the raw value of the `DW_FORM_rnglistx` one day, but 
with such change, we will lose such possibility.

I would suggest making a helper function instead, so all the callers can use 
it. I did it in this patch, what do you think?


https://reviews.llvm.org/D53929



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


[Lldb-commits] [PATCH] D53929: [LLDB] - Add support for DW_FORM_rnglistx and relative DW_RLE_* entries.

2018-11-02 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345958: [LLDB] - Add support for DW_FORM_rnglistx and 
relative DW_RLE_* entries. (authored by grimar, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53929?vs=172121&id=172323#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53929

Files:
  lldb/trunk/lit/Breakpoint/Inputs/debug_rnglistx_rlex.yaml
  lldb/trunk/lit/Breakpoint/debug_rnglistx_rlex.test
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
@@ -128,6 +128,11 @@
   return false;
 }
 
+uint64_t DWARFDebugRanges::GetOffset(size_t Index) const {
+  lldbassert(false && "DW_FORM_rnglistx is not present before DWARF5");
+  return 0;
+}
+
 bool DWARFDebugRngLists::ExtractRangeList(
 const DWARFDataExtractor &data, uint8_t addrSize,
 lldb::offset_t *offset_ptr, std::vector &rangeList) {
@@ -166,17 +171,44 @@
   break;
 }
 
+case DW_RLE_base_addressx: {
+  dw_addr_t base = data.GetULEB128(offset_ptr);
+  rangeList.push_back({DW_RLE_base_addressx, base, 0});
+  break;
+}
+
+case DW_RLE_startx_endx: {
+  dw_addr_t start = data.GetULEB128(offset_ptr);
+  dw_addr_t end = data.GetULEB128(offset_ptr);
+  rangeList.push_back({DW_RLE_startx_endx, start, end});
+  break;
+}
+
+case DW_RLE_startx_length: {
+  dw_addr_t start = data.GetULEB128(offset_ptr);
+  dw_addr_t length = data.GetULEB128(offset_ptr);
+  rangeList.push_back({DW_RLE_startx_length, start, length});
+  break;
+}
+
 default:
-  // Next encodings are not yet supported:
-  // DW_RLE_base_addressx, DW_RLE_startx_endx, DW_RLE_startx_length.
   lldbassert(0 && "unknown range list entry encoding");
   error = true;
 }
   }
 
   return false;
 }
 
+static uint64_t ReadAddressFromDebugAddrSection(const DWARFUnit *cu,
+uint32_t index) {
+  uint32_t index_size = cu->GetAddressByteSize();
+  dw_offset_t addr_base = cu->GetAddrBase();
+  lldb::offset_t offset = addr_base + index * index_size;
+  return cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(&offset,
+   index_size);
+}
+
 bool DWARFDebugRngLists::FindRanges(const DWARFUnit *cu,
 dw_offset_t debug_ranges_offset,
 DWARFRangeList &range_list) const {
@@ -200,6 +232,21 @@
 range_list.Append(
 DWARFRangeList::Entry(BaseAddr + E.value0, E.value1 - E.value0));
 break;
+  case DW_RLE_base_addressx: {
+BaseAddr = ReadAddressFromDebugAddrSection(cu, E.value0);
+break;
+  }
+  case DW_RLE_startx_endx: {
+dw_addr_t start = ReadAddressFromDebugAddrSection(cu, E.value0);
+dw_addr_t end = ReadAddressFromDebugAddrSection(cu, E.value1);
+range_list.Append(DWARFRangeList::Entry(start, end - start));
+break;
+  }
+  case DW_RLE_startx_length: {
+dw_addr_t start = ReadAddressFromDebugAddrSection(cu, E.value0);
+range_list.Append(DWARFRangeList::Entry(start, E.value1));
+break;
+  }
   default:
 llvm_unreachable("unexpected encoding");
   }
@@ -214,7 +261,8 @@
   lldb::offset_t offset = 0;
 
   uint64_t length = data.GetU32(&offset);
-  if (length == 0x)
+  bool isDwarf64 = (length == 0x);
+  if (isDwarf64)
 length = data.GetU64(&offset);
   lldb::offset_t end = offset + length;
 
@@ -232,12 +280,16 @@
 
   uint32_t offsetsAmount = data.GetU32(&offset);
   for (uint32_t i = 0; i < offsetsAmount; ++i)
-Offsets.push_back(data.GetPointer(&offset));
+Offsets.push_back(data.GetMaxU64(&offset, isDwarf64 ? 8 : 4));
 
   lldb::offset_t listOffset = offset;
   std::vector rangeList;
   while (offset < end && ExtractRangeList(data, addrSize, &offset, rangeList)) {
 m_range_map[listOffset] = rangeList;
 listOffset = offset;
   }
 }
+
+uint64_t DWARFDebugRngLists::GetOffset(size_t Index) const {
+  return Offsets[Index];
+}
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -157,6 +157,7 @@
 
   // signed or unsigned LEB 1

[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.

2018-11-14 Thread George Rimar via Phabricator via lldb-commits
grimar closed this revision.
grimar added a comment.

Committed as https://reviews.llvm.org/rLLDB346848.
The commit message has a wrong review link by mistake.


https://reviews.llvm.org/D52403



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


[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 owere used for executable.

2018-11-20 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg.
Herald added subscribers: JDevlieghere, aprantl.

Imagine the following code:

  void baz() {
  }
  
  int main() {
baz();
return 0;
  }

When compiling with with `-gdwarf-4 -gsplit-dwarf` LLDB is able to set the 
breakpoint correctly:

  clang test.cc -g -fno-rtti -c -gdwarf-4 -gsplit-dwarf
  clang test.o -g -fno-rtti -gdwarf-4 -o test -gsplit-dwarf
  lldb test
  (lldb) target create "test"
  Current executable set to 'test' (x86_64).
  (lldb) b baz
  Breakpoint 1: where = test`baz() + 4 at test.cc:4:1, address = 
0x00400524

But not when -dwarf-5 is used. It thinks there are 2 locations:

  clang test.cc -g -fno-rtti -c -gdwarf-5 -gsplit-dwarf
  clang test.o -g -fno-rtti -gdwarf-5 -o test -gsplit-dwarf
  lldb test
  (lldb) target create "test"
  Current executable set to 'test' (x86_64).
  (lldb) b baz
  Breakpoint 1: 2 locations.

The issue happens because starting from DWARF v5 `DW_AT_addr_base` attribute 
should be used
instead of `DW_AT_GNU_addr_base`. LLDB does not do that and we end up reading 
the
`.debug_addr` header as section content (as addresses) instead of skipping it 
and reading the real addresses.
Then LLDB is unable to match 2 similar locations and thinks they are different.


https://reviews.llvm.org/D54751

Files:
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp


Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -306,9 +306,11 @@
 }
 
 // m_die_array_mutex must be already held as read/write.
-void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
-  SetAddrBase(
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {  
+  dw_addr_t addr_base =
+  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 
0);
+  SetAddrBase(addr_base);
+
   SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
DW_AT_rnglists_base, 0));
 
@@ -342,8 +344,12 @@
 
   m_dwo_symbol_file = std::move(dwo_symbol_file);
 
-  dw_addr_t addr_base =
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 
0);
+  // Here we make DWO CU use address base set in the skeleton unit.
+  // DWO files in pre-DWARF v5 could use DW_AT_GNU_addr_base.
+  // Starting from DWARF v5, the DW_AT_addr_base is used instead.
+  if (!addr_base)
+addr_base =
+   cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 
0);
   dwo_cu->SetAddrBase(addr_base);
 
   dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(


Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -306,9 +306,11 @@
 }
 
 // m_die_array_mutex must be already held as read/write.
-void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
-  SetAddrBase(
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {  
+  dw_addr_t addr_base =
+  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0);
+  SetAddrBase(addr_base);
+
   SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
DW_AT_rnglists_base, 0));
 
@@ -342,8 +344,12 @@
 
   m_dwo_symbol_file = std::move(dwo_symbol_file);
 
-  dw_addr_t addr_base =
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
+  // Here we make DWO CU use address base set in the skeleton unit.
+  // DWO files in pre-DWARF v5 could use DW_AT_GNU_addr_base.
+  // Starting from DWARF v5, the DW_AT_addr_base is used instead.
+  if (!addr_base)
+addr_base =
+   cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
   dwo_cu->SetAddrBase(addr_base);
 
   dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 owere used for executable.

2018-11-20 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 174755.
grimar added a comment.

- Added the test case forgotten.


https://reviews.llvm.org/D54751

Files:
  lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
  lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
  lit/Breakpoint/split-dwarf-5-addrbase.test
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -307,8 +307,10 @@
 
 // m_die_array_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
-  SetAddrBase(
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+  dw_addr_t addr_base =
+  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0);
+  SetAddrBase(addr_base);
+
   SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
DW_AT_rnglists_base, 0));
 
@@ -342,8 +344,12 @@
 
   m_dwo_symbol_file = std::move(dwo_symbol_file);
 
-  dw_addr_t addr_base =
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
+  // Here we make DWO CU use address base set in the skeleton unit.
+  // DWO files in pre-DWARF v5 could use DW_AT_GNU_addr_base.
+  // Starting from DWARF v5, the DW_AT_addr_base is used instead.
+  if (!addr_base)
+addr_base =
+   cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
   dwo_cu->SetAddrBase(addr_base);
 
   dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
Index: lit/Breakpoint/split-dwarf-5-addrbase.test
===
--- lit/Breakpoint/split-dwarf-5-addrbase.test
+++ lit/Breakpoint/split-dwarf-5-addrbase.test
@@ -0,0 +1,30 @@
+# RUN: rm -rf %t.dir
+# RUN: mkdir %t.dir
+# RUN: cd %t.dir
+# RUN: yaml2obj %p/Inputs/split-dwarf-5-addrbase.dwo.yaml > %t.dir/test.dwo
+# RUN: yaml2obj %p/Inputs/split-dwarf-5-addrbase.yaml > %t.dir/test
+# RUN: lldb-test breakpoints %t.dir/test %s | FileCheck %s
+
+# This test checks that source code location is shown correctly
+# when -gsplit-dwarf and DWARF 5 are used.
+#
+# split-dwarf-5-addrbase.dwo.yaml and split-dwarf-5-addrbase.yamlare
+# reduced yaml files produces from the dwo file and the corresponding executable.
+#
+# The following code was used initially:
+# void baz() {
+# }
+# 
+# int main() {
+#   baz();
+#   return 0;
+# }
+#
+# Invocation used to produce outputs was:
+# clang test.cc -g -fno-rtti -c -gdwarf-5 -gsplit-dwarf
+# clang test.o -g -fno-rtti -gdwarf-5 -o test -gsplit-dwarf
+# clang version 8.0.0 (trunk 347299)
+
+b baz
+# CHECK-LABEL: b baz
+# CHECK: Address: {{.*}}baz() + 4 at test.cc:2:1
Index: lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
===
--- lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
+++ lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
@@ -0,0 +1,61 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x00400440
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00400440
+AddressAlign:0x0010
+Content: 31ED4989D15E4889E24883E4F0505449C7C0C005400048C7C15005400048C7C730054000E8B7FFF4660F1F4455B820204000483D202040004889E57417B84885C0740D5DBF20204000FFE00F1F445DC3660F1F44BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B84885C0740B5DBF20204000FFE00F1F005DC3660F1F44803D391B007517554889E5E87EFFC605271B015DC30F1F44F3C30F1F4000662E0F1F8400554889E55DEB89660F1F8400554889E55DC3662E0F1F8400554889E54883EC10C745FCE8DCFF31C04883C4105DC30F1F4000415741564189FF415541544C8D25A61855488D2DA618534989F64989D54C29E54883EC0848C1FD03E86FFE4885ED742031DB0F1F84004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F8400F3C3
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 0C0005000900
+  - Name:.debug_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 746573742E64776F002F686F6D652F756D622F74657374735F323031382F3132322F69737375652F6477617266355F73706C69740062617A005F5A3362617A76006D61696E00696E7400
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 01110010177217B042251B25B442197317111B120600
+  - Name:   

[Lldb-commits] [PATCH] D54844: [LLDB] - Improve the support of .debug_str_offsets/.debug_str_offsets.dwo

2018-11-23 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg.
Herald added subscribers: JDevlieghere, aprantl.

A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute
that points to the first string offset of the CU contribution to the
.debug_str_offsets. At the same time, when we use split dwarf,
the corresponding split debug unit also
may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo.
In that case, DWO does not contain DW_AT_str_offsets_base, but LLDB
still need to know and skip the .debug_str_offsets.dwo section header to
access the offsets.

The patch implements the support of DW_AT_str_offsets_base.
A test case showing the use case is provided.

This patch uses a bit of code from https://reviews.llvm.org/D54751, so I assume 
the
latter should be landed first.


https://reviews.llvm.org/D54844

Files:
  lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file1.dwo.yaml
  lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file2.dwo.yaml
  lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-main.yaml
  lit/Breakpoint/split-dwarf5-debug-stroffsets.test
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -111,9 +111,11 @@
   dw_addr_t GetBaseAddress() const { return m_base_addr; }
   dw_addr_t GetAddrBase() const { return m_addr_base; }
   dw_addr_t GetRangesBase() const { return m_ranges_base; }
+  dw_addr_t GetStrOffsetsBase() const { return m_str_offsets_base; }
   void SetAddrBase(dw_addr_t addr_base);
   void SetRangesBase(dw_addr_t ranges_base);
   void SetBaseObjOffset(dw_offset_t base_obj_offset);
+  void SetStrOffsetsBase(dw_offset_t str_offsets_base);
   void BuildAddressRangeTable(SymbolFileDWARF *dwarf,
   DWARFDebugAranges *debug_aranges);
 
@@ -217,7 +219,7 @@
   // If this is a dwo compile unit this is the offset of the base compile unit
   // in the main object file
   dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET;
-
+  dw_offset_t m_str_offsets_base = 0; // Value of DW_AT_str_offsets_base.
   // Offset of the initial length field.
   dw_offset_t m_offset;
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -305,18 +305,50 @@
   }
 }
 
+// This is used when a split dwarf is enabled.
+// A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute
+// that points to the first string offset of the CU contribution to the
+// .debug_str_offsets. At the same time, the corresponding split debug unit also
+// may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo and
+// for that case, we should find the offset (skip the section header).
+static void SetDwoStrOffsetsBase(DWARFUnit *dwo_cu) {
+  lldb::offset_t baseOffset = 0;
+
+  const DWARFDataExtractor &strOffsets =
+  dwo_cu->GetSymbolFileDWARF()->get_debug_str_offsets_data();
+  uint64_t length = strOffsets.GetU32(&baseOffset);
+  if (length == 0x)
+length = strOffsets.GetU64(&baseOffset);
+
+  // Check version.
+  if (strOffsets.GetU16(&baseOffset) < 5)
+return;
+
+  // Skip padding.
+  baseOffset += 2;
+
+  dwo_cu->SetStrOffsetsBase(baseOffset);
+}
+
 // m_die_array_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
-  SetAddrBase(
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
-  SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
-   DW_AT_rnglists_base, 0));
+  dw_addr_t addr_base =
+  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0);
+  SetAddrBase(addr_base);
+
+  dw_addr_t ranges_base =
+  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_rnglists_base, 0);
+  SetRangesBase(ranges_base);
+
+  dw_addr_t str_offsets_base = cu_die.GetAttributeValueAsUnsigned(
+  m_dwarf, this, DW_AT_str_offsets_base, 0);
+  SetStrOffsetsBase(str_offsets_base);
 
   uint64_t base_addr = cu_die.GetAttributeValueAsAddress(
   m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
   if (base_addr == LLDB_INVALID_ADDRESS)
-base_addr = cu_die.GetAttributeValueAsAddress(
-m_dwarf, this, DW_AT_entry_pc, 0);
+base_addr =
+cu_die.GetAttributeValueAsAddress(m_dwarf, this, DW_AT_entry_pc, 0);
   SetBaseAddress(base_addr);
 
   std::unique_ptr dwo_symbol_file =
@@ -342,15 +374,19 @@
 
   m_dwo_symbol_file = std::move(dwo_symbol_file);
 
-  dw_addr_t addr_base =
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
+  if

[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.

2018-11-26 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 175222.
grimar marked an inline comment as done.
grimar added a comment.

Thanks for looking at this, Jan!

- Rewrote the comment.


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

https://reviews.llvm.org/D54751

Files:
  lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
  lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
  lit/Breakpoint/split-dwarf-5-addrbase.test
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -307,8 +307,10 @@
 
 // m_die_array_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
-  SetAddrBase(
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+  dw_addr_t addr_base =
+  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0);
+  SetAddrBase(addr_base);
+
   SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
DW_AT_rnglists_base, 0));
 
@@ -342,8 +344,15 @@
 
   m_dwo_symbol_file = std::move(dwo_symbol_file);
 
-  dw_addr_t addr_base =
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
+  // Here for DWO CU we want to use the address base set in the skeleton unit
+  // (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base
+  // otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_*
+  // attributes which were applicable to the DWO units. The corresponding
+  // DW_AT_* attributes standardized in DWARF v5 are also applicable to the main
+  // unit in contrast.
+  if (!addr_base)
+addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
+   DW_AT_GNU_addr_base, 0);
   dwo_cu->SetAddrBase(addr_base);
 
   dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
Index: lit/Breakpoint/split-dwarf-5-addrbase.test
===
--- lit/Breakpoint/split-dwarf-5-addrbase.test
+++ lit/Breakpoint/split-dwarf-5-addrbase.test
@@ -0,0 +1,30 @@
+# RUN: rm -rf %t.dir
+# RUN: mkdir %t.dir
+# RUN: cd %t.dir
+# RUN: yaml2obj %p/Inputs/split-dwarf-5-addrbase.dwo.yaml > %t.dir/test.dwo
+# RUN: yaml2obj %p/Inputs/split-dwarf-5-addrbase.yaml > %t.dir/test
+# RUN: lldb-test breakpoints %t.dir/test %s | FileCheck %s
+
+# This test checks that source code location is shown correctly
+# when -gsplit-dwarf and DWARF 5 are used.
+#
+# split-dwarf-5-addrbase.dwo.yaml and split-dwarf-5-addrbase.yamlare
+# reduced yaml files produces from the dwo file and the corresponding executable.
+#
+# The following code was used initially:
+# void baz() {
+# }
+# 
+# int main() {
+#   baz();
+#   return 0;
+# }
+#
+# Invocation used to produce outputs was:
+# clang test.cc -g -fno-rtti -c -gdwarf-5 -gsplit-dwarf
+# clang test.o -g -fno-rtti -gdwarf-5 -o test -gsplit-dwarf
+# clang version 8.0.0 (trunk 347299)
+
+b baz
+# CHECK-LABEL: b baz
+# CHECK: Address: {{.*}}baz() + 4 at test.cc:2:1
Index: lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
===
--- lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
+++ lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
@@ -0,0 +1,61 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x00400440
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00400440
+AddressAlign:0x0010
+Content: 31ED4989D15E4889E24883E4F0505449C7C0C005400048C7C15005400048C7C730054000E8B7FFF4660F1F4455B820204000483D202040004889E57417B84885C0740D5DBF20204000FFE00F1F445DC3660F1F44BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B84885C0740B5DBF20204000FFE00F1F005DC3660F1F44803D391B007517554889E5E87EFFC605271B015DC30F1F44F3C30F1F4000662E0F1F8400554889E55DEB89660F1F8400554889E55DC3662E0F1F8400554889E54883EC10C745FCE8DCFF31C04883C4105DC30F1F4000415741564189FF415541544C8D25A61855488D2DA618534989F64989D54C29E54883EC0848C1FD03E86FFE4885ED742031DB0F1F84004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F8400F3C3
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 0C0005000900
+  - Name:.debug_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x00

[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.

2018-11-26 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:351
+  if (!addr_base)
+addr_base =
+   cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 
0);

jankratochvil wrote:
> Here I would find good also a comment:
> ``` // pre-DWARF v5 attributes DW_AT_GNU_* applied only to the DWO unit while 
> DWARF v5 attributes DW_AT_* apply also to the main unit
> ```
> Based on a [[ https://gcc.gnu.org/wiki/DebugFission | DebugFission ]] comment:
> ```Note the following difference between the current GCC implementation and 
> the DWARF v5 specification: In the current GCC implementation (based on DWARF 
> v4), if DW_AT_ranges is present, the offset into the ranges table is not 
> relative to the value given by DW_AT_ranges_base (i.e., DW_AT_ranges_base is 
> used only for references to the range table from the dwo sections). In DWARF 
> v5, the DW_AT_ranges_base attribute is used for all references to the range 
> table -- both from dwo sections and from skeleton compile units.
> ```
> 
> I was also thinking to fetch the attributes just once by some `(m_version >= 
> 5 ? DW_AT_addr_base : DW_AT_GNU_addr_base)` but clang-7.0 does produce 
> DWARF-5 still using `DW_AT_GNU_addr_base`.
> 
I rewrote the comment.

> I was also thinking to fetch the attributes just once by some (m_version >= 5 
> ? DW_AT_addr_base : DW_AT_GNU_addr_base) but clang-7.0 does produce DWARF-5 
> still using DW_AT_GNU_addr_base.

Yeah, it would not be safe to do such check I think. But it should not be an 
issue, in practice, I believe it should be fine to check both the attributes in 
order.


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

https://reviews.llvm.org/D54751



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


[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.

2018-11-27 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 175456.
grimar added a comment.

- Addressed review comments.


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

https://reviews.llvm.org/D54751

Files:
  lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
  lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
  lit/Breakpoint/split-dwarf-5-addrbase.test
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -307,8 +307,11 @@
 
 // m_die_array_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
-  SetAddrBase(
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+  dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(
+  m_dwarf, this, DW_AT_addr_base, LLDB_INVALID_ADDRESS);
+  if (addr_base != LLDB_INVALID_ADDRESS)
+SetAddrBase(addr_base);
+
   SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
DW_AT_rnglists_base, 0));
 
@@ -342,8 +345,15 @@
 
   m_dwo_symbol_file = std::move(dwo_symbol_file);
 
-  dw_addr_t addr_base =
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
+  // Here for DWO CU we want to use the address base set in the skeleton unit
+  // (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base
+  // otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_*
+  // attributes which were applicable to the DWO units. The corresponding
+  // DW_AT_* attributes standardized in DWARF v5 are also applicable to the main
+  // unit in contrast.
+  if (addr_base == LLDB_INVALID_ADDRESS)
+addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
+   DW_AT_GNU_addr_base, 0);
   dwo_cu->SetAddrBase(addr_base);
 
   dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
Index: lit/Breakpoint/split-dwarf-5-addrbase.test
===
--- lit/Breakpoint/split-dwarf-5-addrbase.test
+++ lit/Breakpoint/split-dwarf-5-addrbase.test
@@ -0,0 +1,30 @@
+# RUN: rm -rf %t.dir
+# RUN: mkdir %t.dir
+# RUN: cd %t.dir
+# RUN: yaml2obj %p/Inputs/split-dwarf-5-addrbase.dwo.yaml > %t.dir/test.dwo
+# RUN: yaml2obj %p/Inputs/split-dwarf-5-addrbase.yaml > %t.dir/test
+# RUN: lldb-test breakpoints %t.dir/test %s | FileCheck %s
+
+# This test checks that source code location is shown correctly
+# when -gsplit-dwarf and DWARF 5 are used.
+#
+# split-dwarf-5-addrbase.dwo.yaml and split-dwarf-5-addrbase.yamlare
+# reduced yaml files produces from the dwo file and the corresponding executable.
+#
+# The following code was used initially:
+# void baz() {
+# }
+# 
+# int main() {
+#   baz();
+#   return 0;
+# }
+#
+# Invocation used to produce outputs was:
+# clang test.cc -g -fno-rtti -c -gdwarf-5 -gsplit-dwarf
+# clang test.o -g -fno-rtti -gdwarf-5 -o test -gsplit-dwarf
+# clang version 8.0.0 (trunk 347299)
+
+b baz
+# CHECK-LABEL: b baz
+# CHECK: Address: {{.*}}baz() + 4 at test.cc:2:1
Index: lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
===
--- lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
+++ lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
@@ -0,0 +1,61 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x00400440
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00400440
+AddressAlign:0x0010
+Content: 31ED4989D15E4889E24883E4F0505449C7C0C005400048C7C15005400048C7C730054000E8B7FFF4660F1F4455B820204000483D202040004889E57417B84885C0740D5DBF20204000FFE00F1F445DC3660F1F44BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B84885C0740B5DBF20204000FFE00F1F005DC3660F1F44803D391B007517554889E5E87EFFC605271B015DC30F1F44F3C30F1F4000662E0F1F8400554889E55DEB89660F1F8400554889E55DC3662E0F1F8400554889E54883EC10C745FCE8DCFF31C04883C4105DC30F1F4000415741564189FF415541544C8D25A61855488D2DA618534989F64989D54C29E54883EC0848C1FD03E86FFE4885ED742031DB0F1F84004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F8400F3C3
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 0C0005000900
+  - Name:.debug_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+Address

[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.

2018-11-28 Thread George Rimar via Phabricator via lldb-commits
grimar marked an inline comment as done.
grimar added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:355-356
+  if (addr_base == LLDB_INVALID_ADDRESS)
+addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
+   DW_AT_GNU_addr_base, 0);
   dwo_cu->SetAddrBase(addr_base);

clayborg wrote:
> Do we still want the addr_base to default to zero instead of 
> LLDB_INVALID_ADDRESS here?
I believe so. Setting the addr_base to default zero looks fine to me. That way 
the existent code does not
need to check for LLDB_INVALID_ADDRESS and can just call the `GetAddrBase` and 
add the result
to the offset calculation.
That is how things already work and I do not see any benefits from changing 
this behavior probably?


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

https://reviews.llvm.org/D54751



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


[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.

2018-11-29 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB347842: [LLDB] - Fix setting the breakpoints when 
-gsplit-dwarf and DWARF 5 were used… (authored by grimar, committed by ).
Herald added subscribers: lldb-commits, teemperor, abidh.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D54751

Files:
  lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
  lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
  lit/Breakpoint/split-dwarf-5-addrbase.test
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -307,8 +307,11 @@
 
 // m_die_array_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
-  SetAddrBase(
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_addr_base, 0));
+  dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(
+  m_dwarf, this, DW_AT_addr_base, LLDB_INVALID_ADDRESS);
+  if (addr_base != LLDB_INVALID_ADDRESS)
+SetAddrBase(addr_base);
+
   SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
DW_AT_rnglists_base, 0));
 
@@ -342,8 +345,15 @@
 
   m_dwo_symbol_file = std::move(dwo_symbol_file);
 
-  dw_addr_t addr_base =
-  cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0);
+  // Here for DWO CU we want to use the address base set in the skeleton unit
+  // (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base
+  // otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_*
+  // attributes which were applicable to the DWO units. The corresponding
+  // DW_AT_* attributes standardized in DWARF v5 are also applicable to the main
+  // unit in contrast.
+  if (addr_base == LLDB_INVALID_ADDRESS)
+addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
+   DW_AT_GNU_addr_base, 0);
   dwo_cu->SetAddrBase(addr_base);
 
   dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
Index: lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
===
--- lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
+++ lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
@@ -0,0 +1,35 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name:.debug_loc.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x0001
+Content: ''
+  - Name:.debug_str_offsets.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x0001
+Content: 250009002C0034003C0040004500
+  - Name:.debug_str.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 746573742E64776F00636C616E672076657273696F6E20382E302E3020287472756E6B203334373239392900746573742E6363005F5A3362617A760062617A006D61696E00696E7400
+  - Name:.debug_info.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x0001
+Content: 360005000508E93484C441B7E84A0100010400020200060001560304010103011C00015605010435000406050400
+  - Name:.debug_abbrev.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x0001
+Content: 011101B04225252513050325022E00111B120640186E2503253A0B3B0B3F19032E00111B1206401803253A0B3B0B49133F1904240003253E0B0B0B00
+Symbols: {}
+DynamicSymbols:  {}
+...
Index: lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
===
--- lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
+++ lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
@@ -0,0 +1,61 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x00400440
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00400440
+AddressAlign:0x0010
+Content: 31ED4989D15E4889E24883E4F0505449C7C0C005400048C7C15005400048C7C730054000E8B7FFF4660F1F4455B820204000483D202040004889E57417B84885C0740D5DBF20204000FFE00F1F445D

[Lldb-commits] [PATCH] D54844: [LLDB] - Improve the support of .debug_str_offsets/.debug_str_offsets.dwo

2018-11-29 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347859: [LLDB] - Improve the support of 
.debug_str_offsets/.debug_str_offsets.dwo (authored by grimar, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54844?vs=175092&id=175853#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54844

Files:
  lldb/trunk/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file1.dwo.yaml
  lldb/trunk/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file2.dwo.yaml
  lldb/trunk/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-main.yaml
  lldb/trunk/lit/Breakpoint/split-dwarf5-debug-stroffsets.test
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -111,9 +111,11 @@
   dw_addr_t GetBaseAddress() const { return m_base_addr; }
   dw_addr_t GetAddrBase() const { return m_addr_base; }
   dw_addr_t GetRangesBase() const { return m_ranges_base; }
+  dw_addr_t GetStrOffsetsBase() const { return m_str_offsets_base; }
   void SetAddrBase(dw_addr_t addr_base);
   void SetRangesBase(dw_addr_t ranges_base);
   void SetBaseObjOffset(dw_offset_t base_obj_offset);
+  void SetStrOffsetsBase(dw_offset_t str_offsets_base);
   void BuildAddressRangeTable(SymbolFileDWARF *dwarf,
   DWARFDebugAranges *debug_aranges);
 
@@ -217,7 +219,7 @@
   // If this is a dwo compile unit this is the offset of the base compile unit
   // in the main object file
   dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET;
-
+  dw_offset_t m_str_offsets_base = 0; // Value of DW_AT_str_offsets_base.
   // Offset of the initial length field.
   dw_offset_t m_offset;
 
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -569,22 +569,9 @@
 if (!symbol_file)
   return nullptr;
 
-lldb::offset_t baseOffset = 0;
-const DWARFDataExtractor &strOffsets =
-symbol_file->get_debug_str_offsets_data();
-uint64_t length = strOffsets.GetU32(&baseOffset);
-if (length == 0x)
-  length = strOffsets.GetU64(&baseOffset);
-
-// Check version.
-if (strOffsets.GetU16(&baseOffset) < 5)
-  return nullptr;
-
-// Skip padding.
-baseOffset += 2;
-
 uint32_t indexSize = m_cu->IsDWARF64() ? 8 : 4;
-lldb::offset_t offset = baseOffset + m_value.value.uval * indexSize;
+lldb::offset_t offset =
+m_cu->GetStrOffsetsBase() + m_value.value.uval * indexSize;
 dw_offset_t strOffset =
 symbol_file->get_debug_str_offsets_data().GetMaxU64(&offset, indexSize);
 return symbol_file->get_debug_str_data().PeekCStr(strOffset);
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -305,6 +305,31 @@
   }
 }
 
+// This is used when a split dwarf is enabled.
+// A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute
+// that points to the first string offset of the CU contribution to the
+// .debug_str_offsets. At the same time, the corresponding split debug unit also
+// may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo and
+// for that case, we should find the offset (skip the section header).
+static void SetDwoStrOffsetsBase(DWARFUnit *dwo_cu) {
+  lldb::offset_t baseOffset = 0;
+
+  const DWARFDataExtractor &strOffsets =
+  dwo_cu->GetSymbolFileDWARF()->get_debug_str_offsets_data();
+  uint64_t length = strOffsets.GetU32(&baseOffset);
+  if (length == 0x)
+length = strOffsets.GetU64(&baseOffset);
+
+  // Check version.
+  if (strOffsets.GetU16(&baseOffset) < 5)
+return;
+
+  // Skip padding.
+  baseOffset += 2;
+
+  dwo_cu->SetStrOffsetsBase(baseOffset);
+}
+
 // m_die_array_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
   dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(
@@ -312,8 +337,13 @@
   if (addr_base != LLDB_INVALID_ADDRESS)
 SetAddrBase(addr_base);
 
-  SetRangesBase(cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
-   DW_AT_rnglists_base, 0));
+  dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
+  m_dwarf, this, DW_AT_rn

[Lldb-commits] [PATCH] D55995: [lldb] - Fix compilation with MSVS 2015 update 3

2018-12-21 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: clayborg, LLDB.

Currently, lldb fails to build with the following errors when MSVS update 3 is 
used:

> fatal error C1001: An internal error has occurred in the compiler.
>  (compiler file 'msc1.cpp', line 1468)
>  To work around this problem, try simplifying or changing the program near 
> the locations listed above.

Seems it is relative with the `constexpr`. This patch simplifies the code a bit 
and allows it to compile and run.


https://reviews.llvm.org/D55995

Files:
  include/lldb/Target/Target.h
  source/Commands/CommandObjectBreakpointCommand.cpp
  source/Commands/CommandObjectCommands.cpp
  source/Commands/CommandObjectExpression.cpp
  source/Commands/CommandObjectTarget.cpp
  source/Commands/CommandObjectThread.cpp
  source/Commands/CommandObjectWatchpointCommand.cpp
  source/Core/Debugger.cpp
  source/Interpreter/OptionGroupWatchpoint.cpp
  source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  source/Target/Target.cpp

Index: source/Target/Target.cpp
===
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -63,8 +63,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-constexpr std::chrono::milliseconds EvaluateExpressionOptions::default_timeout;
-
 Target::Arch::Arch(const ArchSpec &spec)
 : m_spec(spec),
   m_plugin_up(PluginManager::CreateArchitectureInstance(spec)) {}
@@ -3130,7 +3128,7 @@
 //--
 
 // clang-format off
-static constexpr OptionEnumValueElement g_dynamic_value_types[] = {
+static const OptionEnumValueElement g_dynamic_value_types[] = {
 {eNoDynamicValues, "no-dynamic-values",
  "Don't calculate the dynamic type of values"},
 {eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values "
@@ -3142,7 +3140,7 @@
   return OptionEnumValues(g_dynamic_value_types);
 }
 
-static constexpr OptionEnumValueElement g_inline_breakpoint_enums[] = {
+static const OptionEnumValueElement g_inline_breakpoint_enums[] = {
 {eInlineBreakpointsNever, "never", "Never look for inline breakpoint "
"locations (fastest). This setting "
"should only be used if you know that "
@@ -3161,16 +3159,16 @@
   eX86DisFlavorATT
 } x86DisassemblyFlavor;
 
-static constexpr OptionEnumValueElement g_x86_dis_flavor_value_types[] = {
+static const OptionEnumValueElement g_x86_dis_flavor_value_types[] = {
 {eX86DisFlavorDefault, "default", "Disassembler default (currently att)."},
 {eX86DisFlavorIntel, "intel", "Intel disassembler flavor."},
 {eX86DisFlavorATT, "att", "AT&T disassembler flavor."} };
 
-static constexpr OptionEnumValueElement g_hex_immediate_style_values[] = {
+static const OptionEnumValueElement g_hex_immediate_style_values[] = {
 {Disassembler::eHexStyleC, "c", "C-style (0x)."},
 {Disassembler::eHexStyleAsm, "asm", "Asm-style (0h)."} };
 
-static constexpr OptionEnumValueElement g_load_script_from_sym_file_values[] = {
+static const OptionEnumValueElement g_load_script_from_sym_file_values[] = {
 {eLoadScriptFromSymFileTrue, "true",
  "Load debug scripts inside symbol files"},
 {eLoadScriptFromSymFileFalse, "false",
@@ -3178,7 +3176,7 @@
 {eLoadScriptFromSymFileWarn, "warn",
  "Warn about debug scripts inside symbol files but do not load them."} };
 
-static constexpr
+static const
 OptionEnumValueElement g_load_current_working_dir_lldbinit_values[] = {
 {eLoadCWDlldbinitTrue, "true",
  "Load .lldbinit files from current directory"},
@@ -3187,7 +3185,7 @@
 {eLoadCWDlldbinitWarn, "warn",
  "Warn about loading .lldbinit files from current directory"} };
 
-static constexpr OptionEnumValueElement g_memory_module_load_level_values[] = {
+static const OptionEnumValueElement g_memory_module_load_level_values[] = {
 {eMemoryModuleLoadLevelMinimal, "minimal",
  "Load minimal information when loading modules from memory. Currently "
  "this setting loads sections only."},
@@ -3198,7 +3196,7 @@
  "Load complete information when loading modules from memory. Currently "
  "this setting loads sections and all symbols."} };
 
-static constexpr PropertyDefinition g_properties[] = {
+static const PropertyDefinition g_properties[] = {
 {"default-arch", OptionValue::eTypeArch, true, 0, nullptr, {},
  "Default architecture to choose, when there's a choice."},
 {"move-to-nearest-code", OptionValue::eTypeBoolean, false, true, nullptr,
@@ -3486,7 +3484,7 @@
 //--
 // TargetProperties
 //--
-static constexpr PropertyDefinition g_experimental_properties[]{
+static const PropertyDefinition g_experimental_properties[]{
 {"inject-local-vars", OptionValue::eTypeBoolea

[Lldb-commits] [PATCH] D56014: [lldb] - Fix crash when listing the history with the key up.

2018-12-21 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added reviewers: LLDB, clayborg.

This is https://bugs.llvm.org/show_bug.cgi?id=40112,

Currently, lldb crashes after pressing the up arrow key when listing the 
history for expressions.

The patch fixes the mistype that was a reason.


https://reviews.llvm.org/D56014

Files:
  source/Host/common/Editline.cpp


Index: source/Host/common/Editline.cpp
===
--- source/Host/common/Editline.cpp
+++ source/Host/common/Editline.cpp
@@ -443,7 +443,7 @@
 m_live_history_lines = m_input_lines;
 m_in_history = true;
   } else {
-if (history_w(pHistory, &history_event, earlier ? H_NEXT : H_PREV) == -1) {
+if (history_w(pHistory, &history_event, earlier ? H_PREV : H_NEXT) == -1) {
   // Can't move earlier than the earliest entry
   if (earlier)
 return CC_ERROR;


Index: source/Host/common/Editline.cpp
===
--- source/Host/common/Editline.cpp
+++ source/Host/common/Editline.cpp
@@ -443,7 +443,7 @@
 m_live_history_lines = m_input_lines;
 m_in_history = true;
   } else {
-if (history_w(pHistory, &history_event, earlier ? H_NEXT : H_PREV) == -1) {
+if (history_w(pHistory, &history_event, earlier ? H_PREV : H_NEXT) == -1) {
   // Can't move earlier than the earliest entry
   if (earlier)
 return CC_ERROR;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D56014: [lldb] - Fix crash when listing the history with the key up.

2018-12-23 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

In D56014#1339419 , @davide wrote:

> testcase?


I investigated how to add it and I do not see a good way write a test :(

Seems the proper place to test it would be `unittest/Editline`:
https://github.com/llvm-mirror/lldb/blob/master/unittests/Editline/EditlineTest.cpp

It allows to send the text using the virtual terminal:
https://github.com/llvm-mirror/lldb/blob/master/unittests/Editline/EditlineTest.cpp#L294

And I was able to simulate the key up press ("lldb-previous-line" command) 
sending the "\x1b[A" line
and to trigger the call of the private `RecallHistory` method of `Editline`, 
where this patch did the fix.
(Since we do not want to make methods public just for the test I believe)

But this is not enough. Case fixed by this patch assumes that some expression 
history exists.
Class responsible for work with the history is `EditlineHistory`:
https://github.com/llvm-mirror/lldb/blob/master/source/Host/common/Editline.cpp#L162
It contains logic to find the path for history file and logic to load/save it 
with the editline library API.
This class is a privately implemented in Editline.cpp and used internally by 
`Editline`.

I am not sure it is a good idea to export it for the unit test. I do not think 
it is correct
to duplicate its logic either or to create a history file manually, given that 
it seems
to contain a mini header, probably specific to the editline library version.
And also (perhaps that would not be needed, but FTR) it does not seem to be a 
good idea to use
the editline API in EditlineTest.cpp, I think it should remain encapsulated in 
Editline.cpp, like now.

Given all above it seems it is really problematic to write a test for this now.
My suggestion probably is to go without it (given that patch fixes an obvious 
mistype).


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

https://reviews.llvm.org/D56014



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


[Lldb-commits] [PATCH] D55995: [lldb] - Fix compilation with MSVS 2015 update 3

2018-12-26 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

In D55995#1339099 , @clayborg wrote:

> The changes from "constexpr" to "const" might introduce global constructors 
> in the shared library which is what we were trying to avoid. The less work 
> that the LLDB shared library does on load the better. We might need to use a 
> macro that expands to "constexpr" for non windows and to "const" for windows 
> in a private LLDB header (PropertyDefinition.h?)


Thanks for looking, Greg. Initially, I thought only MSVS 2015 is affected, but 
looking at the comments in the wild 
(https://developercommunity.visualstudio.com/content/problem/18155/msvc-2017-c-fatal-error-c1001-constexpr-initializa.html),
seems it might be an issue for MSVS 2017 too. So I am going to implement your 
suggestion. Seems lldb.lldb-defines.h file we already have is a good place for 
a new macro definition.


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

https://reviews.llvm.org/D55995



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


[Lldb-commits] [PATCH] D55995: [lldb] - Fix compilation with MSVS 2015 update 3

2018-12-27 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 179535.
grimar edited the summary of this revision.
grimar added a comment.

- Addressed review comment.


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

https://reviews.llvm.org/D55995

Files:
  include/lldb/lldb-defines.h
  source/Commands/CommandObjectBreakpointCommand.cpp
  source/Commands/CommandObjectCommands.cpp
  source/Commands/CommandObjectExpression.cpp
  source/Commands/CommandObjectTarget.cpp
  source/Commands/CommandObjectThread.cpp
  source/Commands/CommandObjectWatchpointCommand.cpp
  source/Core/Debugger.cpp
  source/Interpreter/OptionGroupWatchpoint.cpp
  source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  source/Target/Target.cpp

Index: source/Target/Target.cpp
===
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -3130,7 +3130,7 @@
 //--
 
 // clang-format off
-static constexpr OptionEnumValueElement g_dynamic_value_types[] = {
+static CONSTEXPR OptionEnumValueElement g_dynamic_value_types[] = {
 {eNoDynamicValues, "no-dynamic-values",
  "Don't calculate the dynamic type of values"},
 {eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values "
@@ -3142,7 +3142,7 @@
   return OptionEnumValues(g_dynamic_value_types);
 }
 
-static constexpr OptionEnumValueElement g_inline_breakpoint_enums[] = {
+static CONSTEXPR OptionEnumValueElement g_inline_breakpoint_enums[] = {
 {eInlineBreakpointsNever, "never", "Never look for inline breakpoint "
"locations (fastest). This setting "
"should only be used if you know that "
@@ -3161,16 +3161,16 @@
   eX86DisFlavorATT
 } x86DisassemblyFlavor;
 
-static constexpr OptionEnumValueElement g_x86_dis_flavor_value_types[] = {
+static CONSTEXPR OptionEnumValueElement g_x86_dis_flavor_value_types[] = {
 {eX86DisFlavorDefault, "default", "Disassembler default (currently att)."},
 {eX86DisFlavorIntel, "intel", "Intel disassembler flavor."},
 {eX86DisFlavorATT, "att", "AT&T disassembler flavor."} };
 
-static constexpr OptionEnumValueElement g_hex_immediate_style_values[] = {
+static CONSTEXPR OptionEnumValueElement g_hex_immediate_style_values[] = {
 {Disassembler::eHexStyleC, "c", "C-style (0x)."},
 {Disassembler::eHexStyleAsm, "asm", "Asm-style (0h)."} };
 
-static constexpr OptionEnumValueElement g_load_script_from_sym_file_values[] = {
+static CONSTEXPR OptionEnumValueElement g_load_script_from_sym_file_values[] = {
 {eLoadScriptFromSymFileTrue, "true",
  "Load debug scripts inside symbol files"},
 {eLoadScriptFromSymFileFalse, "false",
@@ -3178,7 +3178,7 @@
 {eLoadScriptFromSymFileWarn, "warn",
  "Warn about debug scripts inside symbol files but do not load them."} };
 
-static constexpr
+static CONSTEXPR
 OptionEnumValueElement g_load_current_working_dir_lldbinit_values[] = {
 {eLoadCWDlldbinitTrue, "true",
  "Load .lldbinit files from current directory"},
@@ -3187,7 +3187,7 @@
 {eLoadCWDlldbinitWarn, "warn",
  "Warn about loading .lldbinit files from current directory"} };
 
-static constexpr OptionEnumValueElement g_memory_module_load_level_values[] = {
+static CONSTEXPR OptionEnumValueElement g_memory_module_load_level_values[] = {
 {eMemoryModuleLoadLevelMinimal, "minimal",
  "Load minimal information when loading modules from memory. Currently "
  "this setting loads sections only."},
@@ -3198,7 +3198,7 @@
  "Load complete information when loading modules from memory. Currently "
  "this setting loads sections and all symbols."} };
 
-static constexpr PropertyDefinition g_properties[] = {
+static CONSTEXPR PropertyDefinition g_properties[] = {
 {"default-arch", OptionValue::eTypeArch, true, 0, nullptr, {},
  "Default architecture to choose, when there's a choice."},
 {"move-to-nearest-code", OptionValue::eTypeBoolean, false, true, nullptr,
Index: source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
===
--- source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -58,7 +58,7 @@
// range looking for a kernel
 };
 
-static constexpr OptionEnumValueElement g_kaslr_kernel_scan_enum_values[] = {
+static CONSTEXPR OptionEnumValueElement g_kaslr_kernel_scan_enum_values[] = {
 {eKASLRScanNone, "none",
  "Do not read memory looking for a Darwin kernel when attaching."},
 {eKASLRScanLowgloAddresses, "basic", "Check for the Darwin kernel's load "
@@ -70,7 +70,7 @@
  "Scan through the entire potential address range of Darwin kernel (only "
  "on 32-bit targets)."}};
 
-static constexpr PropertyDefinition g_properties[] = {
+s

[Lldb-commits] [PATCH] D51935: [LLDB] - Improve reporting source lines and variables (improved DWARF5 support).

2018-09-11 Thread George Rimar via Phabricator via lldb-commits
grimar created this revision.
grimar added a reviewer: LLDB.
Herald added subscribers: JDevlieghere, arichardson, aprantl, emaste.
Herald added a reviewer: espindola.
grimar edited the summary of this revision.

This patch improves the support of DWARF5 by lldb.

Imagine we have the following code,
(compiled with `clang++ test.cpp -g -o test -gdwarf-5`):

  struct XXX {
int A;
  };
  
  int main() {
XXX Obj;
Obj.A = 1;
return Obj.A;
  }

Without this patch when lldb stops on a breakpoint or dump variables
the output is:

  (lldb) b main
  warning: (x86_64) /home/umb/tests_2018/95_lldb/repro/dwarf5_nosplit/test 
unsupported DW_FORM value: 0x25
  Breakpoint 1: where = test`main, address = 0x00400550
  (lldb) run
  Process 5589 launched: 
'/home/umb/tests_2018/95_lldb/repro/dwarf5_nosplit/test' (x86_64)
  Process 5589 stopped
  * thread #1, name = 'test', stop reason = breakpoint 1.1
  frame #0: 0x00400550 test`main
  test`main:
  ->  0x400550 <+0>:  pushq  %rbp
  0x400551 <+1>:  movq   %rsp, %rbp
  0x400554 <+4>:  movl   $0x0, -0x4(%rbp)
  0x40055b <+11>: movl   $0x1, -0x8(%rbp)
  (lldb) script
  Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
  >>> print lldb.frame.GetVariables(True, True, True, True)
   lldb.SBValueList()

Note that it complains about unknown forms,
there is no code source lines and output from the `print`
call is empty.

With the patch applied output becomes:

  umb@umb-virtual-machine:~/LLVM/build_lldb/bin$ ./lldb 
~/tests_2018/95_lldb/repro/dwarf5_nosplit/test
  (lldb) target create "/home/umb/tests_2018/95_lldb/repro/dwarf5_nosplit/test"
  Current executable set to 
'/home/umb/tests_2018/95_lldb/repro/dwarf5_nosplit/test' (x86_64).
  (lldb) b main
  Breakpoint 1: where = test`main + 11 at test.cpp:7, address = 
0x0040055b
  (lldb) run
  Process 63624 launched: 
'/home/umb/tests_2018/95_lldb/repro/dwarf5_nosplit/test' (x86_64)
  Process 63624 stopped
  * thread #1, name = 'test', stop reason = breakpoint 1.1
  frame #0: 0x0040055b test`main at test.cpp:7
 4  
 5  int main() {
 6XXX Obj;
  -> 7Obj.A = 1;
 8  
 9return Obj.A;
 10 }
  (lldb) script
  Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
  >>> print lldb.frame.GetVariables(True, True, True, True)
  (XXX) Obj = (A = 0)

Note there is no test case yet, I am going to add it to this revision soon.
This is my first patch for lldb and I did not yet learn how to write the
test for the code written.
I would be happy to see any comments/suggestions.


https://reviews.llvm.org/D51935

Files:
  include/lldb/lldb-enumerations.h
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -350,6 +350,7 @@
   case eSectionTypeDWARFDebugFrame:
   case eSectionTypeDWARFDebugInfo:
   case eSectionTypeDWARFDebugLine:
+  case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
   case eSectionTypeDWARFDebugMacInfo:
   case eSectionTypeDWARFDebugMacro:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -240,6 +240,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
   const lldb_private::DWARFDataExtractor &get_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
+  const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
   const lldb_private::DWARFDataExtractor &get_debug_loc_data();
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
@@ -466,6 +467,7 @@
   DWARFDataSegment m_data_debug_frame;
   DWARFDataSegment m_data_debug_info;
   DWARFDataSegment m_data_debug_line;
+  DWARFDataSegment m_data_debug_line_str;
   DWARFDataSegment m_data_debug_macro;
   DWARFDataSegment m_data_debug_loc;
   DWARFDataSegment m_data_debug_ranges;
Index: source/Plugins/Sym

[Lldb-commits] [PATCH] D51935: [LLDB] - Improve reporting source lines and variables (improved DWARF5 support).

2018-09-11 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 164911.
grimar added a comment.

- Minor cosmetic cleanup.


https://reviews.llvm.org/D51935

Files:
  include/lldb/lldb-enumerations.h
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -350,6 +350,7 @@
   case eSectionTypeDWARFDebugFrame:
   case eSectionTypeDWARFDebugInfo:
   case eSectionTypeDWARFDebugLine:
+  case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
   case eSectionTypeDWARFDebugMacInfo:
   case eSectionTypeDWARFDebugMacro:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -240,6 +240,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
   const lldb_private::DWARFDataExtractor &get_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
+  const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
   const lldb_private::DWARFDataExtractor &get_debug_loc_data();
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
@@ -466,6 +467,7 @@
   DWARFDataSegment m_data_debug_frame;
   DWARFDataSegment m_data_debug_info;
   DWARFDataSegment m_data_debug_line;
+  DWARFDataSegment m_data_debug_line_str;
   DWARFDataSegment m_data_debug_macro;
   DWARFDataSegment m_data_debug_loc;
   DWARFDataSegment m_data_debug_ranges;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -494,7 +494,7 @@
 }
 
 bool SymbolFileDWARF::SupportedVersion(uint16_t version) {
-  return version == 2 || version == 3 || version == 4;
+  return version >= 2 && version <= 5;
 }
 
 uint32_t SymbolFileDWARF::CalculateAbilities() {
@@ -645,6 +645,10 @@
   return GetCachedSectionData(eSectionTypeDWARFDebugLine, m_data_debug_line);
 }
 
+const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_str_data() {
+ return GetCachedSectionData(eSectionTypeDWARFDebugLineStr, m_data_debug_line_str);
+}
+
 const DWARFDataExtractor &SymbolFileDWARF::get_debug_macro_data() {
   return GetCachedSectionData(eSectionTypeDWARFDebugMacro, m_data_debug_macro);
 }
@@ -933,7 +937,7 @@
 support_files.Append(*sc.comp_unit);
 return DWARFDebugLine::ParseSupportFiles(
 sc.comp_unit->GetModule(), get_debug_line_data(), cu_comp_dir,
-stmt_list, support_files);
+stmt_list, support_files, dwarf_cu);
   }
 }
   }
@@ -1070,7 +1074,7 @@
   lldb::offset_t offset = cu_line_offset;
   DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset,
   ParseDWARFLineTableCallback,
-  &info);
+  &info, dwarf_cu);
   SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
   if (debug_map_symfile) {
 // We have an object file that has a line table with addresses that
Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -225,7 +225,8 @@
 const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
 std::vector &dies) {
 
-  m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, dies);
+  std::vector V;
+  m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, V);
 
   for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name.GetStringRef())) {
@@ -235,8 +236,13 @@
 
 if (DIERef ref = ToDIERef(entry))
   ProcessFunctionDIE(name.GetStringRef(), ref, info, parent_decl_ctx,
- name_type_mask, dies);
+   

[Lldb-commits] [PATCH] D51935: [LLDB] - Improve reporting source lines and variables (improved DWARF5 support).

2018-09-12 Thread George Rimar via Phabricator via lldb-commits
grimar marked 5 inline comments as done.
grimar added a comment.

Thanks for the review, Greg! I'll address your comments and add the test case 
when it will be ready. Hope soon.


https://reviews.llvm.org/D51935



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


[Lldb-commits] [PATCH] D51935: [LLDB] - Improve reporting source lines and variables (improved DWARF5 support).

2018-09-12 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 165112.
grimar added a comment.

- Addressed review comments.
- Added test case.
- Minor cosmetic changes.


https://reviews.llvm.org/D51935

Files:
  include/lldb/lldb-enumerations.h
  packages/Python/lldbsuite/test/functionalities/show_location/Makefile
  
packages/Python/lldbsuite/test/functionalities/show_location/TestShowLocationDwarf5.py
  packages/Python/lldbsuite/test/functionalities/show_location/main.c
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -350,6 +350,7 @@
   case eSectionTypeDWARFDebugFrame:
   case eSectionTypeDWARFDebugInfo:
   case eSectionTypeDWARFDebugLine:
+  case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
   case eSectionTypeDWARFDebugMacInfo:
   case eSectionTypeDWARFDebugMacro:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -240,6 +240,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
   const lldb_private::DWARFDataExtractor &get_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
+  const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
   const lldb_private::DWARFDataExtractor &get_debug_loc_data();
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
@@ -466,6 +467,7 @@
   DWARFDataSegment m_data_debug_frame;
   DWARFDataSegment m_data_debug_info;
   DWARFDataSegment m_data_debug_line;
+  DWARFDataSegment m_data_debug_line_str;
   DWARFDataSegment m_data_debug_macro;
   DWARFDataSegment m_data_debug_loc;
   DWARFDataSegment m_data_debug_ranges;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -494,7 +494,7 @@
 }
 
 bool SymbolFileDWARF::SupportedVersion(uint16_t version) {
-  return version == 2 || version == 3 || version == 4;
+  return version >= 2 && version <= 5;
 }
 
 uint32_t SymbolFileDWARF::CalculateAbilities() {
@@ -645,6 +645,10 @@
   return GetCachedSectionData(eSectionTypeDWARFDebugLine, m_data_debug_line);
 }
 
+const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_str_data() {
+ return GetCachedSectionData(eSectionTypeDWARFDebugLineStr, m_data_debug_line_str);
+}
+
 const DWARFDataExtractor &SymbolFileDWARF::get_debug_macro_data() {
   return GetCachedSectionData(eSectionTypeDWARFDebugMacro, m_data_debug_macro);
 }
@@ -933,7 +937,7 @@
 support_files.Append(*sc.comp_unit);
 return DWARFDebugLine::ParseSupportFiles(
 sc.comp_unit->GetModule(), get_debug_line_data(), cu_comp_dir,
-stmt_list, support_files);
+stmt_list, support_files, dwarf_cu);
   }
 }
   }
@@ -1070,7 +1074,7 @@
   lldb::offset_t offset = cu_line_offset;
   DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset,
   ParseDWARFLineTableCallback,
-  &info);
+  &info, dwarf_cu);
   SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
   if (debug_map_symfile) {
 // We have an object file that has a line table with addresses that
Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -225,7 +225,8 @@
 const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
 std::vector &dies) {
 
-  m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, dies);
+  std::vector v;
+  m_fallback.GetFunctions(name, info, parent_decl_ctx, 

[Lldb-commits] [PATCH] D51935: [LLDB] - Improve reporting source lines and variables (improved DWARF5 support).

2018-09-12 Thread George Rimar via Phabricator via lldb-commits
grimar planned changes to this revision.
grimar added a comment.

Will reupload.


https://reviews.llvm.org/D51935



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


[Lldb-commits] [PATCH] D51935: [LLDB] - Improve reporting source lines and variables (improved DWARF5 support).

2018-09-12 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

In https://reviews.llvm.org/D51935#1232195, @clayborg wrote:

> Patch looks good. A few fixes mentioned in inlined comments. And I am unsure 
> how the test suite will run with various compilers if they don't support the 
> -gdwarf-5 flag. We might need to run obj2yaml on a binary and then yaml2obj 
> it for the test to ensure we can run the test. We might be able to just 
> symbolicate a few addresses in the test instead of requiring us to run 
> something.


What about using the llvm-mc? I can convert c++ code to the assembler I think.


https://reviews.llvm.org/D51935



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


[Lldb-commits] [PATCH] D51935: [LLDB] - Improve reporting source lines and variables (improved DWARF5 support).

2018-09-13 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp:442
+ReadDescriptors(debug_line_data, offset_ptr);
+uint8_t dirCount = debug_line_data.GetU8(offset_ptr);
+for (int i = 0; i < dirCount; ++i) {

probinson wrote:
> clayborg wrote:
> > We might verify that this is indeed correct by looking at compiler sources. 
> > Seems weird to limit dirs to 255
> The directory count is a ULEB not a ubyte.
Oops. My mistake here, my initial version which used uleb128 was correct, but I 
looked at the wrong place too in the dwarf5 spec after that.


https://reviews.llvm.org/D51935



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


[Lldb-commits] [PATCH] D51935: [LLDB] - Improve reporting source lines and variables (improved DWARF5 support).

2018-09-13 Thread George Rimar via Phabricator via lldb-commits
grimar updated this revision to Diff 165289.
grimar marked 2 inline comments as done.
grimar added a comment.

- Addressed comments.
- Changed test case to use yaml2obj.


https://reviews.llvm.org/D51935

Files:
  include/lldb/lldb-enumerations.h
  
packages/Python/lldbsuite/test/functionalities/show_location/TestShowLocationDwarf5.py
  packages/Python/lldbsuite/test/functionalities/show_location/a.yaml
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -350,6 +350,7 @@
   case eSectionTypeDWARFDebugFrame:
   case eSectionTypeDWARFDebugInfo:
   case eSectionTypeDWARFDebugLine:
+  case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
   case eSectionTypeDWARFDebugMacInfo:
   case eSectionTypeDWARFDebugMacro:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -240,6 +240,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
   const lldb_private::DWARFDataExtractor &get_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
+  const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
   const lldb_private::DWARFDataExtractor &get_debug_loc_data();
   const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
@@ -466,6 +467,7 @@
   DWARFDataSegment m_data_debug_frame;
   DWARFDataSegment m_data_debug_info;
   DWARFDataSegment m_data_debug_line;
+  DWARFDataSegment m_data_debug_line_str;
   DWARFDataSegment m_data_debug_macro;
   DWARFDataSegment m_data_debug_loc;
   DWARFDataSegment m_data_debug_ranges;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -494,7 +494,7 @@
 }
 
 bool SymbolFileDWARF::SupportedVersion(uint16_t version) {
-  return version == 2 || version == 3 || version == 4;
+  return version >= 2 && version <= 5;
 }
 
 uint32_t SymbolFileDWARF::CalculateAbilities() {
@@ -645,6 +645,10 @@
   return GetCachedSectionData(eSectionTypeDWARFDebugLine, m_data_debug_line);
 }
 
+const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_str_data() {
+ return GetCachedSectionData(eSectionTypeDWARFDebugLineStr, m_data_debug_line_str);
+}
+
 const DWARFDataExtractor &SymbolFileDWARF::get_debug_macro_data() {
   return GetCachedSectionData(eSectionTypeDWARFDebugMacro, m_data_debug_macro);
 }
@@ -933,7 +937,7 @@
 support_files.Append(*sc.comp_unit);
 return DWARFDebugLine::ParseSupportFiles(
 sc.comp_unit->GetModule(), get_debug_line_data(), cu_comp_dir,
-stmt_list, support_files);
+stmt_list, support_files, dwarf_cu);
   }
 }
   }
@@ -1070,7 +1074,7 @@
   lldb::offset_t offset = cu_line_offset;
   DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset,
   ParseDWARFLineTableCallback,
-  &info);
+  &info, dwarf_cu);
   SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
   if (debug_map_symfile) {
 // We have an object file that has a line table with addresses that
Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -225,7 +225,8 @@
 const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
 std::vector &dies) {
 
-  m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, dies);
+  std::vector v;
+  m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, v);
 
   for (const DebugNames

[Lldb-commits] [PATCH] D51935: [LLDB] - Improved DWARF5 support.

2018-09-13 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342153: [LLDB] - Improved DWARF5 support. (authored by 
grimar, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51935?vs=165289&id=165322#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51935

Files:
  lldb/trunk/include/lldb/lldb-enumerations.h
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/show_location/TestShowLocationDwarf5.py
  lldb/trunk/packages/Python/lldbsuite/test/functionalities/show_location/a.yaml
  lldb/trunk/source/Core/Section.cpp
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/trunk/source/Symbol/ObjectFile.cpp

Index: lldb/trunk/source/Core/Section.cpp
===
--- lldb/trunk/source/Core/Section.cpp
+++ lldb/trunk/source/Core/Section.cpp
@@ -73,6 +73,8 @@
 return "dwarf-info";
   case eSectionTypeDWARFDebugLine:
 return "dwarf-line";
+  case eSectionTypeDWARFDebugLineStr:
+return "dwarf-line-str";
   case eSectionTypeDWARFDebugLoc:
 return "dwarf-loc";
   case eSectionTypeDWARFDebugMacInfo:
Index: lldb/trunk/source/Symbol/ObjectFile.cpp
===
--- lldb/trunk/source/Symbol/ObjectFile.cpp
+++ lldb/trunk/source/Symbol/ObjectFile.cpp
@@ -350,6 +350,7 @@
   case eSectionTypeDWARFDebugFrame:
   case eSectionTypeDWARFDebugInfo:
   case eSectionTypeDWARFDebugLine:
+  case eSectionTypeDWARFDebugLineStr:
   case eSectionTypeDWARFDebugLoc:
   case eSectionTypeDWARFDebugMacInfo:
   case eSectionTypeDWARFDebugMacro:
Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1788,6 +1788,7 @@
   static ConstString g_sect_name_dwarf_debug_frame(".debug_frame");
   static ConstString g_sect_name_dwarf_debug_info(".debug_info");
   static ConstString g_sect_name_dwarf_debug_line(".debug_line");
+  static ConstString g_sect_name_dwarf_debug_line_str(".debug_line_str");
   static ConstString g_sect_name_dwarf_debug_loc(".debug_loc");
   static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo");
   static ConstString g_sect_name_dwarf_debug_macro(".debug_macro");
@@ -1802,6 +1803,7 @@
   ".debug_abbrev.dwo");
   static ConstString g_sect_name_dwarf_debug_info_dwo(".debug_info.dwo");
   static ConstString g_sect_name_dwarf_debug_line_dwo(".debug_line.dwo");
+  static ConstString g_sect_name_dwarf_debug_line_str_dwo(".debug_line_str.dwo");
   static ConstString g_sect_name_dwarf_debug_macro_dwo(".debug_macro.dwo");
   static ConstString g_sect_name_dwarf_debug_loc_dwo(".debug_loc.dwo");
   static ConstString g_sect_name_dwarf_debug_str_dwo(".debug_str.dwo");
@@ -1861,6 +1863,8 @@
 sect_type = eSectionTypeDWARFDebugInfo;
   else if (name == g_sect_name_dwarf_debug_line)
 sect_type = eSectionTypeDWARFDebugLine;
+  else if (name == g_sect_name_dwarf_debug_line_str)
+sect_type = eSectionTypeDWARFDebugLineStr;
   else if (name == g_sect_name_dwarf_debug_loc)
 sect_type = eSectionTypeDWARFDebugLoc;
   else if (name == g_sect_name_dwarf_debug_macinfo)
@@ -1887,6 +1891,8 @@
 sect_type = eSectionTypeDWARFDebugInfo;
   else if (name == g_sect_name_dwarf_debug_line_dwo)
 sect_type = eSectionTypeDWARFDebugLine;
+  else if (name == g_sect_name_dwarf_debug_line_str_dwo)
+sect_type = eSectionTypeDWARFDebugLineStr;
   else if (name == g_sect_name_dwarf_debug_macro_dwo)
 sect_type = eSectionTypeDWARFDebugMacro;
   else if (name == g_sect_name_dwarf_debug_loc_dwo)
Index: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileM

[Lldb-commits] [PATCH] D55995: [lldb] - Fix compilation with MSVS 2015 update 3

2019-01-10 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

Ping.


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

https://reviews.llvm.org/D55995



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


[Lldb-commits] [PATCH] D55995: [lldb] - Fix compilation with MSVS 2015 update 3

2019-01-10 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

In D55995#1352772 , @labath wrote:

> BTW, I've been compiling lldb with VS2017 and haven't run into this issue. 
> Also, with the imminent release of VS2019, I expect someone will soon start a 
> thread proposing to drop VS2015, so you might be better of switching to a 
> newer compiler. (But I don't have a problem with checking this in while we 
> still officially support this compiler.)


I am OK with switching to VS2017 I think.


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

https://reviews.llvm.org/D55995



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


[Lldb-commits] [PATCH] D55995: [lldb] - Fix compilation with MSVS 2015 update 3

2019-01-10 Thread George Rimar via Phabricator via lldb-commits
grimar planned changes to this revision.
grimar added a comment.

I'll try to switch to MSVS 2017 and recheck this.


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

https://reviews.llvm.org/D55995



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


[Lldb-commits] [PATCH] D56014: [lldb] - Fix crash when listing the history with the key up.

2019-01-11 Thread George Rimar via Phabricator via lldb-commits
grimar planned changes to this revision.
grimar added a comment.

In D56014#1341129 , @labath wrote:

> I guess it should be possible to trigger this from dotest tests via pexpect. 
> I know we try to avoid it, but given that this is specifically testing 
> terminal interaction, using it here seems appropriate.


Thanks for the suggestion. I'll try to investigate it and return with the 
results during the next week I guess.


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

https://reviews.llvm.org/D56014



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


[Lldb-commits] [PATCH] D56014: [lldb] - Fix crash when listing the history with the key up.

2019-01-14 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

I ended up with the following test case:

**TestHistoryCrash.py:**

  """We crashed when navigated through the history. Check we do not now."""
  
  from __future__ import print_function
  
  import os
  import sys
  import lldb
  from lldbsuite.test.decorators import *
  from lldbsuite.test.lldbtest import *
  from lldbsuite.test import configuration
  from lldbsuite.test import lldbutil
  
  class TestNoCrashForHistoryRecall(TestBase):
  
  mydir = TestBase.compute_mydir(__file__)
  
  # If your test case doesn't stress debug info, the
  # set this to true.  That way it won't be run once for
  # each debug info format.
  NO_DEBUG_INFO_TESTCASE = True
  
  def setUp(self):
  TestBase.setUp(self)
  
  @expectedFailureAll(
  oslist=["windows"],
  bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
  
  def test_history_recall(self):
  self.child_prompt = '(lldb) '
  self.sample_test()
  
  def sample_test(self):
  import pexpect
  
  self.child = pexpect.spawn(
  '%s %s' %
  (lldbtest_config.lldbExec, self.lldbOption))
  child = self.child
  child.sendline('print')
  child.expect_exact('Enter expressions')
  child.sendline('\x1b[A')
  child.close()
  
  self.assertEqual(child.exitstatus, 0)

It works, but not in all cases. Problem is that history patch is hardcoded and 
history is stored in the home directory (`~/.lldb/lldb-expr-history`):
https://github.com/llvm-mirror/lldb/blob/master/source/Host/common/Editline.cpp#L180

When the history file exists and is empty (has a header, but no history lines), 
the test case can trigger the crash successfully.
But if the history file does not yet exist, or if it is not empty, it does not 
work (always pass), because does not trigger a line changed.
And in the ideal world on a build bot, I believe for a clean build it should 
never exist (though I guess bots are not cleaning the `~/.lldb` folder perhaps).

It is not a good idea to touch or modify files outside the build folder from 
the test, so that does not seem what I can change.
And so I am not sure it is worth to add such test, it can help only in some 
cases, for a local test runs, for example.
Also, It does not work on windows because all pexpect tests seem ban windows.

Given above I suggest going without a test, perhaps.


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

https://reviews.llvm.org/D56014



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


[Lldb-commits] [PATCH] D55995: [lldb] - Fix compilation with MSVS 2015 update 3

2019-01-14 Thread George Rimar via Phabricator via lldb-commits
grimar abandoned this revision.
grimar added a comment.

Yep, MSVS2017 works fine here for me too. Thanks, Pavel! I am abandoning it.


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

https://reviews.llvm.org/D55995



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


[Lldb-commits] [PATCH] D56014: [lldb] - Fix crash when listing the history with the key up.

2019-01-16 Thread George Rimar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351313: [lldb] - Fix crash when listing the history with the 
key up. (authored by grimar, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56014?vs=179313&id=181993#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56014

Files:
  lldb/trunk/source/Host/common/Editline.cpp


Index: lldb/trunk/source/Host/common/Editline.cpp
===
--- lldb/trunk/source/Host/common/Editline.cpp
+++ lldb/trunk/source/Host/common/Editline.cpp
@@ -443,7 +443,7 @@
 m_live_history_lines = m_input_lines;
 m_in_history = true;
   } else {
-if (history_w(pHistory, &history_event, earlier ? H_NEXT : H_PREV) == -1) {
+if (history_w(pHistory, &history_event, earlier ? H_PREV : H_NEXT) == -1) {
   // Can't move earlier than the earliest entry
   if (earlier)
 return CC_ERROR;


Index: lldb/trunk/source/Host/common/Editline.cpp
===
--- lldb/trunk/source/Host/common/Editline.cpp
+++ lldb/trunk/source/Host/common/Editline.cpp
@@ -443,7 +443,7 @@
 m_live_history_lines = m_input_lines;
 m_in_history = true;
   } else {
-if (history_w(pHistory, &history_event, earlier ? H_NEXT : H_PREV) == -1) {
+if (history_w(pHistory, &history_event, earlier ? H_PREV : H_NEXT) == -1) {
   // Can't move earlier than the earliest entry
   if (earlier)
 return CC_ERROR;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D56014: [lldb] - Fix crash when listing the history with the key up.

2019-01-16 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

In D56014#1358769 , @JDevlieghere 
wrote:

> Although I don't want to condone checking things in without a test case, 
> given that the fix is obvious and that testing it is non-trivial, I think 
> it's fine to check this in as is.


Thanks, Jonas!


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

https://reviews.llvm.org/D56014



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


[Lldb-commits] [PATCH] D68645: MinidumpYAML: Add support for the memory info list stream

2019-10-09 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: include/llvm/ObjectYAML/MinidumpYAML.h:111
+
+  explicit MemoryInfoListStream(std::vector Infos)
+  : Stream(StreamKind::MemoryInfoList,

Maybe be more explicit here, i.e.

```
std::vector &&Infos
```
?



Comment at: lib/ObjectYAML/MinidumpEmitter.cpp:166
+Header.SizeOfEntry = sizeof(minidump::MemoryInfo);
+Header.NumberOfEntries = InfoList.Infos.size();
+File.allocateNewObject(Header);

Probably just

```
minidump::MemoryInfoListHeader Header = {
(support::ulittle32_t)sizeof(minidump::MemoryInfoListHeader),
(support::ulittle32_t)sizeof(minidump::MemoryInfo),
(support::ulittle64_t)InfoList.Infos.size()};
```

?

Or perhaps it could have a constructor.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68645



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


[Lldb-commits] [PATCH] D68645: MinidumpYAML: Add support for the memory info list stream

2019-10-09 Thread George Rimar via Phabricator via lldb-commits
grimar accepted this revision.
grimar added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68645



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


[Lldb-commits] [PATCH] D68657: Update MinidumpYAML to use minidump::Exception for exception stream

2019-10-12 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: llvm/include/llvm/ObjectYAML/MinidumpYAML.h:113-114
+  ExceptionStream()
+  : Stream(StreamKind::Exception, minidump::StreamType::Exception) {
+memset(&MDExceptionStream, 0, sizeof(minidump::ExceptionStream));
+  }

I'd avoid memset: 
```
  ExceptionStream()
  : Stream(StreamKind::Exception, minidump::StreamType::Exception),
MDExceptionStream({}) {
```



Comment at: llvm/lib/ObjectYAML/MinidumpYAML.cpp:525
+  case StreamKind::Exception: {
+auto ExpectedExceptionStream = File.getExceptionStream();
+if (!ExpectedExceptionStream)

We often avoid using `auto` when return type is not obvious.



Comment at: llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp:143
+
+TEST(MinidumpYAML, ExceptionStream) {
+  SmallString<0> Storage;

I'd add a comment for each test to describe what they do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68657



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


[Lldb-commits] [PATCH] D68657: Update MinidumpYAML to use minidump::Exception for exception stream

2019-10-15 Thread George Rimar via Phabricator via lldb-commits
grimar accepted this revision.
grimar added a comment.
This revision is now accepted and ready to land.

LGTM with 2 nits.




Comment at: llvm/test/tools/yaml2obj/minidump-exception-missing-parameter.yaml:3
+
+# Test that we report an error for an ExceptionStream where the specified
+# number of parameters is greater than the number of ExceptionInformation

nit: It is became common to use ## for comments in yaml2obj and actually many 
other LLVM tools test cases.
(here and below)



Comment at: llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp:143
+
+// Test that we can parse a normal-looking ExceptionStream
+TEST(MinidumpYAML, ExceptionStream) {

nit: Missing a full stop (here and below).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68657



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


[Lldb-commits] [PATCH] D68943: [llvm][yaml2obj] no more implicit ELF .symtab section

2019-10-15 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

I have not looked what is needed to fix yaml2obj testcases yet, but below there 
are
few first comments.

Also, 2 LLVM side tests added should live in "llvm/test/tools/yaml2obj" I think 
(not in llvm/test/ObjectYAML/ELF/),
because this is actually the place where we test "yaml2obj" usually.




Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:513
   bool IsStatic = STType == SymtabType::Static;
-  const auto &Symbols = IsStatic ? Doc.Symbols : Doc.DynamicSymbols;
+  const auto &Symbols = (IsStatic && Doc.Symbols) ? *Doc.Symbols : 
Doc.DynamicSymbols;
 

It doesn't look correct. We should never use dynamic symbols instead of static 
symbols I believe.



Comment at: llvm/test/ObjectYAML/ELF/no-symtab-generated.yaml:14
+Sections:
+  - Name:.debug_line
+Type:SHT_PROGBITS

You do not need any sections.



Comment at: llvm/test/ObjectYAML/ELF/no-symtab-generated.yaml:18
+
+# CHECK-NOT: Name: .symtab
+# CHECK-NOT: Type: SHT_SYMTAB

We often use the following order:
1) Run lines
2) Check lines
3) YAML

I.e. the order you have used in symtab-generated.yaml. I'd suggest to be 
consistent and stick to it.

Also, probably would be better to have a single test case file, i.e. to merge 
them. You can see other our tests which do that.



Comment at: llvm/test/ObjectYAML/ELF/symtab-generated.yaml:1
+# In this test we define a "Symbols" entry in the YAML and expect a .symtab
+# section to be generated. Notice that this is automatically added even though

We usually use ## for comments in yaml2obj tests.



Comment at: llvm/test/ObjectYAML/ELF/symtab-generated.yaml:31
+  Machine: EM_X86_64
+  Entry:   0x004004C0
+Sections:

You do not need Entry.



Comment at: llvm/test/ObjectYAML/ELF/symtab-generated.yaml:33
+Sections:
+- Name:.text
+  Type:SHT_PROGBITS

You do not need any sections it seems.



Comment at: llvm/test/ObjectYAML/ELF/symtab-generated.yaml:41
+- Name:main
+  Type:STT_FUNC
+  Section: .text

Having only a "Name" should be enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68943



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


[Lldb-commits] [PATCH] D68943: [llvm][yaml2obj] no more implicit ELF .symtab section

2019-10-15 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

In D68943#1709330 , @kwk wrote:

> I noticed that the order of sections does matter to some tests. Before the 
> `.symtab` section was always the first one and now it is the last of the 
> implicit sections being created. Some `Link: X`  checks break because `X` 
> points to a different section. In order to compensate for this I will make 
> `.symtab` the first of the implicit sections again.


Please upload the version with this change and I'll try to debug to take a look 
what happens.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68943



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


[Lldb-commits] [PATCH] D68657: Update MinidumpYAML to use minidump::Exception for exception stream

2019-10-15 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: llvm/test/tools/yaml2obj/minidump-exception-missing-parameter.yaml:3
+
+# Test that we report an error for an ExceptionStream where the specified
+# number of parameters is greater than the number of ExceptionInformation

JosephTremoulet wrote:
> grimar wrote:
> > nit: It is became common to use ## for comments in yaml2obj and actually 
> > many other LLVM tools test cases.
> > (here and below)
> Sorry, when you say "here and below", do you just mean lines 3 and 4-5, or do 
> you also mean the CHECK line (line 20)?  Grepping in test/tools it appears to 
> be very uncommon to use ## for CHECK lines, but that's what I'd have 
> otherwise assumed "and below" referred to...
Sorry, I think I misread the line 20, i.e. I read it as a comment. Indeed we do 
not use ## for CHECK lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68657



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


[Lldb-commits] [PATCH] D68943: [llvm][yaml2obj] no more implicit ELF .symtab section

2019-10-15 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

Ok, I was able to debug it finally.

I think we should add a .symtab in a few more cases implicitly.
For example, when we have a SHT_RELA/SHT_REL section that has an empty Link,
i.e. it refers to .symtab by default and we should provide it.
There are other cases, like when Link just explicitly refers to .symtab.

Here is a patch based on this one.
It is unpolished, but shows the idea. With it all yaml2obj tests pass.

F10276544: patch.diff 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68943



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


[Lldb-commits] [PATCH] D68943: [llvm][yaml2obj] no more implicit ELF .symtab section

2019-10-16 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

In D68943#1710525 , @MaskRay wrote:

> In D68943#1709998 , @grimar wrote:
>
> > Ok, I was able to debug it finally.
> >
> > I think we should add a .symtab in a few more cases implicitly.
> >  For example, when we have a SHT_RELA/SHT_REL section that has an empty 
> > Link,
> >  i.e. it refers to .symtab by default and we should provide it.
> >  There are other cases, like when Link just explicitly refers to .symtab.
> >
> > Here is a patch based on this one.
> >  It is unpolished, but shows the idea. With it all yaml2obj tests pass.
> >
> > F10276544: patch.diff 
>
>
> Nice! Can you post a differential for the yaml2obj change? I believe the 
> differential can focus on lldb and remove yaml2obj changes (kwk will still 
> get credited for the test cleanups).


Yes. It needs polishing + fixes for obj2yaml (I do not think it compiled for me 
at all). Also probably makes sence to add tests for obj2yaml too, I need to 
take a look what it does
when the object doesn't have symbol table with such change. I'll try to suggest 
a patch today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68943



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


[Lldb-commits] [PATCH] D68943: [llvm][yaml2obj] no more implicit ELF .symtab section

2019-10-16 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

I've posted a change for yaml2obj/obj2yaml here: D69041 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68943



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


[Lldb-commits] [PATCH] D69254: [lldb] drop .symtab removal in minidebuginfo tests

2019-10-21 Thread George Rimar via Phabricator via lldb-commits
grimar accepted this revision.
grimar added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69254



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


[Lldb-commits] [PATCH] D62570: [WIP] Use LLVM's debug line parser in LLDB

2019-05-30 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: lldb/include/lldb/Core/FileSpecList.h:29
+  typedef std::vector collection;
+  typedef collection::iterator iterator;
+  typedef collection::const_iterator const_iterator;

Seems you don't use `iterator` anywhere?



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:792
+  cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list, DW_INVALID_OFFSET);
+  if (stmt_list == DW_INVALID_OFFSET)
+return false;

You do not use `stmt_list` anywhere else, so I would suggest to:

```
  if (cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list, DW_INVALID_OFFSET) ==
  DW_INVALID_OFFSET)
continue;
```



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:879
+
+  auto AddSection = [&](Section §ion) {
+DataExtractor section_data;

`AddSection`->`addSection`?



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:929-938
+  llvm::DWARFDebugLine line;
+  llvm::Expected line_table =
+  line.getOrParseLineTable(
+  data, offset, *ctx, ctx->getUnitForOffset(dwarf_cu->GetOffset()),
+  [](llvm::Error e) { llvm::consumeError(std::move(e)); });
+
+  if (!line_table) {

clayborg wrote:
> Can we make a function out of this that just returns the "const 
> llvm::DWARFDebugLine::LineTable *"? Or make a new location variable that is 
> just a "const llvm::DWARFDebugLine::LineTable *" to avoid the 
> "(*line_table)->" stuff below?
+1 for `new location variable`.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:974
+if (!found_original)
+  continue;
+std::string remapped_file;

Seems you can avoid having `found_original` and `found_remapped`:
(assuming `table` is a new variable mentioned above)

```
  if (!table->getFileNameByIndex(
  index + 1, compile_dir,
  llvm::DILineInfoSpecifier::FileLineInfoKind::Default, original_file))
continue;
```


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62570



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


[Lldb-commits] [PATCH] D72909: Make SymbolFileDWARF::ParseLineTable use std::sort instead of insertion sort

2020-01-21 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: lldb/source/Symbol/LineTable.cpp:27
+  LineTable::Entry::LessThanBinaryPredicate less_than_bp(this);
+  std::sort(sequences.begin(), sequences.end(), less_than_bp);
+  for (auto *sequence : sequences) {

I wonder if this have to be `std::stable_sort`?
For `std::sort` the order of equal elements is not guaranteed to be preserved.

nit: you could also probably use the `llvm::sort` (it would be a bit shorter):
`llvm::sort(sequences, less_than_bp);`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72909



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