[Lldb-commits] [PATCH] D106466: [llvm+lldb] 2/2: Fix#2 of DW_AT_ranges DW_FORM_sec_offset not using DW_AT_rnglists_base (used by GCC)

2021-08-03 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added a comment.

As far as I understand it, you need a specially constructed 
`llvm::DWARFDebugRnglistTable` object so that 
`DWARFUnit::FindRnglistFromOffset()` can call its `findList()` method and get a 
list of records located at a specific offset. It looks like a newly created 
`llvm::DWARFDebugRnglistTable` object has its `Header.Length` set to `0`, so it 
already works as required for the usage, and there is no need to fill its 
fields with artificial values that do not represent real content of the 
section. Am I right?




Comment at: llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp:54
+
+  Data.setAddressSize(HeaderData.AddrSize);
+  return Error::success();

The line looks suspicious because `Data` is a local variable that is destroyed 
right after the statement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106466

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


[Lldb-commits] [PATCH] D107470: 2/3: [llvm+lldb] Remove dead-code in DWARFListTableHeader::extract modifying DWARFDataExtractor

2021-08-11 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added inline comments.



Comment at: llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp:128
+  EXPECT_EQ(Table.getAddrSize(), 8U);
+  Extractor.setAddressSize(Table.getAddrSize());
+  Expected List = Table.findList(Extractor, Offset);

This looks odd. `DWARFListTableBase::findList()` should not require the setting 
to be done in the calling code if it can apply it itself. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107470

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


[Lldb-commits] [PATCH] D106466: 3/3: [llvm+lldb] Fix#2 of DW_AT_ranges DW_FORM_sec_offset not using DW_AT_rnglists_base (used by GCC)

2021-08-11 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added a comment.

In D106466#2926185 , @jankratochvil 
wrote:

> In D106466#2922549 , @ikudrin wrote:
>
>> As far as I understand it, you need a specially constructed 
>> `llvm::DWARFDebugRnglistTable` object so that 
>> `DWARFUnit::FindRnglistFromOffset()` can call its `findList()` method and 
>> get a list of records located at a specific offset.
>
> Yes.
>
>> It looks like a newly created `llvm::DWARFDebugRnglistTable` object has its 
>> `Header.Length` set to `0`,
>
> But that is wrong `Length`, the correct one is to cover the whole section 
> which I set by:
>
>   HeaderData.Length = Data.size() - dwarf::getUnitLengthFieldByteSize(Format);

This value is not incorrect, but a special one, with custom handling. 
`DWARFUnit::findRnglistFromOffset(uint64_t Offset)` fetches the list without 
creating a fake header.

>> so it already works as required for the usage, and there is no need to fill 
>> its fields with artificial values that do not represent real content of the 
>> section. Am I right?
>
> One needs to set at least `AddrSize` and `OffsetEntryCount` as callers do use 
> it.

Could you please point me to that usage? I am not that familiar with the LLDB 
code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106466

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


[Lldb-commits] [PATCH] D107470: 2/3: [llvm+lldb] Remove dead-code in DWARFListTableHeader::extract modifying DWARFDataExtractor

2021-08-12 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added inline comments.



Comment at: llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h:289-291
   if (Header.length())
 Data = DWARFDataExtractor(Data, getHeaderOffset() + Header.length());
+  Data.setAddressSize(getAddrSize());

if `Header.Length` is zero that means that there is no header discovered for 
the table. That can be handled accordingly and no need to fill header fields 
with artificial values based on a particular use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107470

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


[Lldb-commits] [PATCH] D106466: [llvm+lldb] Fix#2 of DW_AT_ranges DW_FORM_sec_offset not using DW_AT_rnglists_base (used by GCC)

2021-08-16 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added a comment.

The code looks good, but please improve the comments and wait for approval from 
a more LLDB-knowledgeable person than me,




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:441
+  if (offset == 0) {
+// Caller must not use this default initializater for GetRnglistOffset.
+return ListTableType();

Please extend the comment to emphasize that even if `DW_AT_rnglists_base` is 
missing and `DW_FORM_rnglistx` cannot be handled, returning a 
default-constructed Table allows `DW_FORM_sec_offset` to be supported.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:1005
+
+  // As \a offset can be zero we need to call setAddressSize.
+  data.setAddressSize(m_header.GetAddressByteSize());

This comment is quite misleading as it references `offset` which is the 
argument of the method.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106466

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


[Lldb-commits] [PATCH] D107470: [llvm+lldb] Remove dead-code in DWARFListTableHeader::extract modifying DWARFDataExtractor

2021-08-16 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added a comment.

`DWARFDebugInfo.TestRnglistsAddressSize`, 
`DWARFListTableHeader.AddressSize64Offset`, and 
`DWARFListTableHeader.AddressSize32Offset` pass without applying the patch. Why 
adding them?




Comment at: llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp:123
+  llvm::Error E = Table.extractHeaderAndOffsets(Extractor, &Offset);
+  EXPECT_FALSE(!!E);
+  EXPECT_EQ(Offset, 12U);

The rest of the test makes no sense if `extractHeaderAndOffsets()` returns an 
error.



Comment at: llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp:129-130
+  Expected List = Table.findList(Extractor, Offset);
+  EXPECT_TRUE(!!List);
+  EXPECT_EQ(List->getEntries().size(), 2U);
+  EXPECT_EQ(List->getEntries()[0].Offset, 12 + 0U);

If these checks fail, the execution of the test should be terminated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107470

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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-10 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin created this revision.
ikudrin added reviewers: dblaikie, probinson, jhenderson, aprantl, labath.
ikudrin added projects: LLVM, debug-info.
Herald added subscribers: lldb-commits, arphaman, hiraditya.
Herald added a project: LLDB.

DWARFv5 defines index sections in package files in a slightly different way 
than the pre-standard GNU proposal, see Section 7.3.5 in the DWARF standard and 
https://gcc.gnu.org/wiki/DebugFissionDWP for GNU proposal. The main concern 
here is values for section identifiers, which are partially overlapped with 
changed meanings. The patch adds support for v5 index sections and resolves 
that difficulty by defining a set of identifiers for internal use which can 
represent and distinct values of both standards.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75929

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-loc.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-loclists.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/test/tools/llvm-dwp/X86/unsupported_cu_index_version.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -214,6 +214,19 @@
   StringRef DWPName;
 };
 
+// Convert an internal section identifier into the index to use with
+// UnitIndexEntry::Contributions.
+static unsigned SectionKindToIndex(DWARFSectionKind Kind) {
+  // Assuming pre-standard DWP format.
+  return SerializeSectionKind(Kind, 2) - 1;
+}
+
+// Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
+// value of the section identifier. 
+static unsigned IndexToOnDiskSectionId(unsigned Index) {
+  return Index + 1;
+}
+
 static StringRef getSubsection(StringRef Section,
const DWARFUnitIndex::Entry &Entry,
DWARFSectionKind Kind) {
@@ -239,15 +252,15 @@
 // Zero out the debug_info contribution
 Entry.Contributions[0] = {};
 for (auto Kind : TUIndex.getColumnKinds()) {
-  auto &C = Entry.Contributions[Kind - DW_SECT_INFO];
+  auto &C = Entry.Contributions[SectionKindToIndex(Kind)];
   C.Offset += I->Offset;
   C.Length = I->Length;
   ++I;
 }
-auto &C = Entry.Contributions[DW_SECT_TYPES - DW_SECT_INFO];
+const unsigned TypesIndex = SectionKindToIndex(DW_SECT_GNU_TYPES);
+auto &C = Entry.Contributions[TypesIndex];
 Out.emitBytes(Types.substr(
-C.Offset - TUEntry.Contributions[DW_SECT_TYPES - DW_SECT_INFO].Offset,
-C.Length));
+C.Offset - TUEntry.Contributions[TypesIndex].Offset, C.Length));
 C.Offset = TypesOffset;
 TypesOffset += C.Length;
   }
@@ -266,7 +279,7 @@
   UnitIndexEntry Entry = CUEntry;
   // Zero out the debug_info contribution
   Entry.Contributions[0] = {};
-  auto &C = Entry.Contributions[DW_SECT_TYPES - DW_SECT_INFO];
+  auto &C = Entry.Contributions[SectionKindToIndex(DW_SECT_GNU_TYPES)];
   C.Offset = TypesOffset;
   auto PrevOffset = Offset;
   // Length of the unit, including the 4 byte length field.
@@ -343,7 +356,7 @@
   // Write the column headers (which sections will appear in the table)
   for (size_t i = 0; i != ContributionOffsets.size(); ++i)
 if (ContributionOffsets[i])
-  Out.emitIntValue(i + DW_SECT_INFO, 4);
+  Out.emitIntValue(IndexToOnDiskSectionId(i), 4);
 
   // Write the offsets.
   writeIndexTable(Out, ContributionOffsets, IndexEntries,
@@ -436,8 +449,8 @@
 return Error::success();
 
   if (DWARFSectionKind Kind = SectionPair->second.second) {
-auto Index = Kind - DW_SECT_INFO;
-if (Kind != DW_SECT_TYPES) {
+auto Index = SectionKindToIndex(Kind);
+if (Kind != DW_SECT_GNU_TYPES) {
   CurEntry.Contributions[Index].Offset = ContributionOffsets[Index];
   ContributionOffsets[Index] +=
   (CurEntry.Contributions[Index].Length = Contents.size());
@@ -521,10 +534,10 @@
   MCSection *const TUIndexSection = MCOFI.getDwarfTUIndexSection();
   const StringMap> KnownSections = {
   {"debug_info.dwo", {MCOFI.getDwarfInfoDWOSection(), DW_SECT_INFO}},
-  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_TYPES}},
+  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_GNU_TYPES}},
   {"debug_str_offsets.dwo", {StrOffsetSection, DW_SECT_STR_OFFSETS}},
   {"debug_str.dwo", {StrSection, static_cast(0)}},
-  {"debug_lo

[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-11 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added a comment.

Thanks for the links! What a coincidence...

I believe that this patch is more or less compatible with any approach which 
might be taken. The idea is that there is a set of constants for internal use 
and functions to translate them to/from external representation and both 
constants and translation functions might be adjusted when needed. In any case, 
the general design remains the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75929



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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-11 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added a comment.

In D75929#1916466 , @labath wrote:

> In D75929#1916127 , @ikudrin wrote:
>
> > I believe that this patch is more or less compatible with any approach 
> > which might be taken. The idea is that there is a set of constants for 
> > internal use and functions to translate them to/from external 
> > representation and both constants and translation functions might be 
> > adjusted when needed. In any case, the general design remains the same.
>
>
> That's true, but I'm not sure it is really the best solution.


Well, I do not pretend this to be a perfect solution, but anything I can 
imagine has its drawbacks. The whole problem comes from overlapping values in 
both standards, and any solution has to fix that somehow.

> This way we will have three numbering schemes (four if you count the "index" 
> thingy in llvm-dwp) floating around: the "gnu" scheme, the "official" scheme, 
> and the "internal" scheme. That's quite a lot to keep in ones head at once.

However, you do not need to worry about all the schemas everywhere. The only 
place they meet is translation functions. Most of the code just use internal 
encoding, which is enough.

> I'm wondering if if wouldn't be simpler to have two complete enums --  with 
> the "gnu" scheme, and one with the "official" scheme -- and then to 
> internally use the enum matching the on-disk format currently in use. To 
> insulate the users from having to guess the right enum to use, we could add a 
> series of accessors: `getLocOffset`, `getMacInfoOffset`, ..., which would use 
> the appropriate enum based on the index version (or assert if there is no 
> such constant in the given version).
> 
> WDYT?

Can't see how the accessors simplify the things. For me, `getLocOffset()` is 
almost the same as `getOffset(DW_SECT_LOC)` (or `getOffset(DW_SECT_GNU_LOC)`). 
That is no more than an agreement. Note that this patch does not have things 
like `DW_SECT_GNU_INFO`. There is only one constant for each section, so their 
usage is quite determined. The only exception is `DW_SECT_MACRO` and 
`DW_SECT_GNU_MACRO`, I just did not want to overcomplicate translation 
functions before receiving the feedback about the approach in general.

> Regardless of the outcome of that, I think it would be good to split this 
> patch up and separate the enum shuffling from the new functionality (does 
> this only add parsing support for v5 indexes, or is there something more?).

I'll prepare a separate review for the refactoring in `llvm-dwp.cpp`. As for 
the new identifiers and all shuffling stuff around, I am not sure it is really 
valuable to separate them because without the parser of v5 indexes they are 
meaningless and just dead code. Anyway, the splitting should wait until we 
decide whether the approach is viable in general.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75929



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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-12 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin updated this revision to Diff 249939.
ikudrin added a comment.

- Use values for clashing identifiers proposed by @dblaikie.
- Convert all unknown section identifiers into a special value, 
`DW_SECT_EXT_unknown`; Use an optional parallel array to keep the raw values of 
unknown identifiers.
- Split the refactoring part in `llvm-dwp.cpp` into a separate patch, D76067 
.

There are some other changes that can be split into separate patches. I will 
make the series when the direction of this patch is approved in general.


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

https://reviews.llvm.org/D75929

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-loc.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-loclists.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/test/tools/llvm-dwp/X86/unsupported_cu_index_version.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -214,11 +214,12 @@
   StringRef DWPName;
 };
 
-// Convert a section identifier into the index to use with
+// Convert an internal section identifier into the index to use with
 // UnitIndexEntry::Contributions.
 static unsigned SectionKindToIndex(DWARFSectionKind Kind) {
-  assert(static_cast(Kind) >= 1);
-  return static_cast(Kind) - 1;
+  // Assuming pre-standard DWP format.
+  assert(SerializeSectionKind(Kind, 2) >= 1);
+  return SerializeSectionKind(Kind, 2) - 1;
 }
 
 // Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
@@ -250,12 +251,14 @@
 // Zero out the debug_info contribution
 Entry.Contributions[0] = {};
 for (auto Kind : TUIndex.getColumnKinds()) {
+  if (Kind == DW_SECT_EXT_unknown)
+continue;
   auto &C = Entry.Contributions[SectionKindToIndex(Kind)];
   C.Offset += I->Offset;
   C.Length = I->Length;
   ++I;
 }
-const unsigned TypesIndex = SectionKindToIndex(DW_SECT_TYPES);
+const unsigned TypesIndex = SectionKindToIndex(DW_SECT_EXT_TYPES);
 auto &C = Entry.Contributions[TypesIndex];
 Out.emitBytes(Types.substr(
 C.Offset - TUEntry.Contributions[TypesIndex].Offset, C.Length));
@@ -277,7 +280,7 @@
   UnitIndexEntry Entry = CUEntry;
   // Zero out the debug_info contribution
   Entry.Contributions[0] = {};
-  auto &C = Entry.Contributions[SectionKindToIndex(DW_SECT_TYPES)];
+  auto &C = Entry.Contributions[SectionKindToIndex(DW_SECT_EXT_TYPES)];
   C.Offset = TypesOffset;
   auto PrevOffset = Offset;
   // Length of the unit, including the 4 byte length field.
@@ -448,7 +451,7 @@
 
   if (DWARFSectionKind Kind = SectionPair->second.second) {
 auto Index = SectionKindToIndex(Kind);
-if (Kind != DW_SECT_TYPES) {
+if (Kind != DW_SECT_EXT_TYPES) {
   CurEntry.Contributions[Index].Offset = ContributionOffsets[Index];
   ContributionOffsets[Index] +=
   (CurEntry.Contributions[Index].Length = Contents.size());
@@ -532,10 +535,10 @@
   MCSection *const TUIndexSection = MCOFI.getDwarfTUIndexSection();
   const StringMap> KnownSections = {
   {"debug_info.dwo", {MCOFI.getDwarfInfoDWOSection(), DW_SECT_INFO}},
-  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_TYPES}},
+  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_EXT_TYPES}},
   {"debug_str_offsets.dwo", {StrOffsetSection, DW_SECT_STR_OFFSETS}},
   {"debug_str.dwo", {StrSection, static_cast(0)}},
-  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_LOC}},
+  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_EXT_LOC}},
   {"debug_line.dwo", {MCOFI.getDwarfLineDWOSection(), DW_SECT_LINE}},
   {"debug_abbrev.dwo", {MCOFI.getDwarfAbbrevDWOSection(), DW_SECT_ABBREV}},
   {"debug_cu_index", {CUIndexSection, static_cast(0)}},
@@ -599,7 +602,7 @@
   P.first->second.DWOName = ID.DWOName;
   addAllTypes(Out, TypeIndexEntries, TypesSection, CurTypesSection,
   CurEntry,
-  ContributionOffsets[SectionKindToIndex(DW_SECT_TYPES)]);
+  ContributionOffsets[SectionKindToIndex(DW_SECT_EXT_TYPES)]);
   continue;
 }
 
@@ -607,6 +610,8 @@
 DataExtractor CUIndexData(CurCUIndexSection, Obj.isLittleEndian(), 0);
 if (!CUIndex.parse(CUIndexData))
   return make_error("Failed to parse cu_index");

[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-13 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added a comment.

In D75929#1920691 , @dblaikie wrote:

> > This is almost what you are doing right now -- the only difference is that 
> > the "internal" enum would no longer be internal -- it would actually match 
> > the on-disk format of a v5 index. This v5 enum would contain the official 
> > DWARFv5 constants as well as the new extensions we want to introduce for 
> > mixed 5+4 indices.
>
> Yep, this would be the direction I would suggest/encourage. It seems that if 
> the goal is to have one index in a DWP file (which seems reasonable) then all 
> future index versions will have to support column indexes all previous DWARF 
> sections - the DWARFvN enum can then be used to describe all the previous 
> versions as well.


So, what are the differences with the last update, apart from that 
`DWARFSectionKind` is still internal? I believe we should not put the 
extensions into the official part before they are approved.


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

https://reviews.llvm.org/D75929



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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-16 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin updated this revision to Diff 250537.
ikudrin marked 10 inline comments as done.
ikudrin added a comment.

@jhenderson, thank you for the comments!

- Made comments for `DWARFSectionKind`, `serializeSectionKind()` and 
`deserializeSectionKind()` in doxygen style.
- Renamed function.
- Fixed wording in a comment.
- Added descriptions to the tests.

@dblaikie, @labath, as far as I can understand, the patch complies with your 
vision. The main difference is that the enum is still intended for internal use 
only, but it probably should not go to the public part before the proposed 
values are accepted. Anyway, even while the proposal of the combined index is 
not approved, I believe that the patch is useful per se because it allows 
reading standard index sections and can later be easily extended for combined 
indexes. The patch does not restrict that movement. Please, correct me if I 
misunderstand anything.


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

https://reviews.llvm.org/D75929

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-loc.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-loclists.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/test/tools/llvm-dwp/X86/unsupported_cu_index_version.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -214,16 +214,19 @@
   StringRef DWPName;
 };
 
-// Convert a section identifier into the index to use with
+// Convert an internal section identifier into the index to use with
 // UnitIndexEntry::Contributions.
-static unsigned SectionKindToIndex(DWARFSectionKind Kind) {
-  assert(static_cast(Kind) >= 1);
-  return static_cast(Kind) - 1;
+static unsigned getContributionIndex(DWARFSectionKind Kind) {
+  // Assuming pre-standard DWP format.
+  assert(serializeSectionKind(Kind, 2) >= DW_SECT_INFO);
+  return serializeSectionKind(Kind, 2) - DW_SECT_INFO;
 }
 
 // Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
 // value of the section identifier.
-static unsigned IndexToOnDiskSectionId(unsigned Index) { return Index + 1; }
+static unsigned getOnDiskSectionId(unsigned Index) {
+  return Index + DW_SECT_INFO;
+}
 
 static StringRef getSubsection(StringRef Section,
const DWARFUnitIndex::Entry &Entry,
@@ -250,12 +253,14 @@
 // Zero out the debug_info contribution
 Entry.Contributions[0] = {};
 for (auto Kind : TUIndex.getColumnKinds()) {
-  auto &C = Entry.Contributions[SectionKindToIndex(Kind)];
+  if (Kind == DW_SECT_EXT_unknown)
+continue;
+  auto &C = Entry.Contributions[getContributionIndex(Kind)];
   C.Offset += I->Offset;
   C.Length = I->Length;
   ++I;
 }
-const unsigned TypesIndex = SectionKindToIndex(DW_SECT_TYPES);
+const unsigned TypesIndex = getContributionIndex(DW_SECT_EXT_TYPES);
 auto &C = Entry.Contributions[TypesIndex];
 Out.emitBytes(Types.substr(
 C.Offset - TUEntry.Contributions[TypesIndex].Offset, C.Length));
@@ -277,7 +282,7 @@
   UnitIndexEntry Entry = CUEntry;
   // Zero out the debug_info contribution
   Entry.Contributions[0] = {};
-  auto &C = Entry.Contributions[SectionKindToIndex(DW_SECT_TYPES)];
+  auto &C = Entry.Contributions[getContributionIndex(DW_SECT_EXT_TYPES)];
   C.Offset = TypesOffset;
   auto PrevOffset = Offset;
   // Length of the unit, including the 4 byte length field.
@@ -354,7 +359,7 @@
   // Write the column headers (which sections will appear in the table)
   for (size_t i = 0; i != ContributionOffsets.size(); ++i)
 if (ContributionOffsets[i])
-  Out.emitIntValue(IndexToOnDiskSectionId(i), 4);
+  Out.emitIntValue(getOnDiskSectionId(i), 4);
 
   // Write the offsets.
   writeIndexTable(Out, ContributionOffsets, IndexEntries,
@@ -447,8 +452,8 @@
 return Error::success();
 
   if (DWARFSectionKind Kind = SectionPair->second.second) {
-auto Index = SectionKindToIndex(Kind);
-if (Kind != DW_SECT_TYPES) {
+auto Index = getContributionIndex(Kind);
+if (Kind != DW_SECT_EXT_TYPES) {
   CurEntry.Contributions[Index].Offset = ContributionOffsets[Index];
   ContributionOffsets[Index] +=
   (CurEntry.Contributions[Index].Length = Contents.size());
@@ -532,10 +537,10 @@
   MCSection *const TUIndexSection = MCOFI.getDwarfTUIndexSection();
   const S

[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-16 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added inline comments.



Comment at: llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h:116
+  // This is a parallel array of raw section IDs for columns of unknown kinds.
+  // This array is created only if there are items in columns ColumnKinds with
+  // DW_SECT_EXT_unknown and the only initialized items here are those with

jhenderson wrote:
> "items in columns ColumnKinds" doesn't read well to me. I'm not sure if its 
> missing punctuation, an extra word, or what.
Thanks for noticing that. It was an ugly result of multiple edits. Rephrased 
again. Hope it is better now.



Comment at: llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp:101
+if (Version != 5)
+  return false;
+*OffsetPtr += 2; // Skip padding.

jhenderson wrote:
> Probably out of scope for this change, but this should return an llvm::Error 
> instead to say why parsing failed.
Added to my backlog, but do not mind if anyone willing to fix that.



Comment at: llvm/test/DebugInfo/X86/dwp-v2-loc.s:1
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-info -debug-loc - | \

jhenderson wrote:
> I might have missed something, but is this relevant? I thought this patch was 
> for supporting .debug_cu_index?
The patch adjusts the code in the constructor of `DWARFUnit` which reads the 
location table. This test checks that pre-v5 units read their location tables 
from `.debug_loc.dwo` sections. Its counterpart, `dwp-v5-loclists.s` checks 
that v5 units use `.debug_loclists.dwo`. These changes might be probably 
extracted later to a separate patch.


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

https://reviews.llvm.org/D75929



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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-17 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added inline comments.



Comment at: llvm/tools/llvm-dwp/llvm-dwp.cpp:614
+if (CUIndex.getVersion() != 2)
+  return make_error("Unsupported cu_index version");
 

jhenderson wrote:
> jhenderson wrote:
> > I see the above error message starts with a capital letter, but more 
> > generally I think we try to use lower-case for error messages. Maybe worth 
> > doing it right here and changing the above line in a separate change?
> Ping?
Fixed. Sorry for forgetting those. D76277 is added for changing the existing 
messages.


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

https://reviews.llvm.org/D75929



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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-17 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin updated this revision to Diff 250731.
ikudrin marked 8 inline comments as done.
ikudrin added a comment.

- Fixed messages in `llvm-dwp.cpp`.
- Fixed comments in the tests.


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

https://reviews.llvm.org/D75929

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-loc.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-loclists.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/test/tools/llvm-dwp/X86/unsupported_cu_index_version.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -214,16 +214,19 @@
   StringRef DWPName;
 };
 
-// Convert a section identifier into the index to use with
+// Convert an internal section identifier into the index to use with
 // UnitIndexEntry::Contributions.
-static unsigned SectionKindToIndex(DWARFSectionKind Kind) {
-  assert(static_cast(Kind) >= 1);
-  return static_cast(Kind) - 1;
+static unsigned getContributionIndex(DWARFSectionKind Kind) {
+  // Assuming pre-standard DWP format.
+  assert(serializeSectionKind(Kind, 2) >= DW_SECT_INFO);
+  return serializeSectionKind(Kind, 2) - DW_SECT_INFO;
 }
 
 // Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
 // value of the section identifier.
-static unsigned IndexToOnDiskSectionId(unsigned Index) { return Index + 1; }
+static unsigned getOnDiskSectionId(unsigned Index) {
+  return Index + DW_SECT_INFO;
+}
 
 static StringRef getSubsection(StringRef Section,
const DWARFUnitIndex::Entry &Entry,
@@ -250,12 +253,14 @@
 // Zero out the debug_info contribution
 Entry.Contributions[0] = {};
 for (auto Kind : TUIndex.getColumnKinds()) {
-  auto &C = Entry.Contributions[SectionKindToIndex(Kind)];
+  if (Kind == DW_SECT_EXT_unknown)
+continue;
+  auto &C = Entry.Contributions[getContributionIndex(Kind)];
   C.Offset += I->Offset;
   C.Length = I->Length;
   ++I;
 }
-const unsigned TypesIndex = SectionKindToIndex(DW_SECT_TYPES);
+const unsigned TypesIndex = getContributionIndex(DW_SECT_EXT_TYPES);
 auto &C = Entry.Contributions[TypesIndex];
 Out.emitBytes(Types.substr(
 C.Offset - TUEntry.Contributions[TypesIndex].Offset, C.Length));
@@ -277,7 +282,7 @@
   UnitIndexEntry Entry = CUEntry;
   // Zero out the debug_info contribution
   Entry.Contributions[0] = {};
-  auto &C = Entry.Contributions[SectionKindToIndex(DW_SECT_TYPES)];
+  auto &C = Entry.Contributions[getContributionIndex(DW_SECT_EXT_TYPES)];
   C.Offset = TypesOffset;
   auto PrevOffset = Offset;
   // Length of the unit, including the 4 byte length field.
@@ -354,7 +359,7 @@
   // Write the column headers (which sections will appear in the table)
   for (size_t i = 0; i != ContributionOffsets.size(); ++i)
 if (ContributionOffsets[i])
-  Out.emitIntValue(IndexToOnDiskSectionId(i), 4);
+  Out.emitIntValue(getOnDiskSectionId(i), 4);
 
   // Write the offsets.
   writeIndexTable(Out, ContributionOffsets, IndexEntries,
@@ -447,8 +452,8 @@
 return Error::success();
 
   if (DWARFSectionKind Kind = SectionPair->second.second) {
-auto Index = SectionKindToIndex(Kind);
-if (Kind != DW_SECT_TYPES) {
+auto Index = getContributionIndex(Kind);
+if (Kind != DW_SECT_EXT_TYPES) {
   CurEntry.Contributions[Index].Offset = ContributionOffsets[Index];
   ContributionOffsets[Index] +=
   (CurEntry.Contributions[Index].Length = Contents.size());
@@ -532,10 +537,10 @@
   MCSection *const TUIndexSection = MCOFI.getDwarfTUIndexSection();
   const StringMap> KnownSections = {
   {"debug_info.dwo", {MCOFI.getDwarfInfoDWOSection(), DW_SECT_INFO}},
-  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_TYPES}},
+  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_EXT_TYPES}},
   {"debug_str_offsets.dwo", {StrOffsetSection, DW_SECT_STR_OFFSETS}},
   {"debug_str.dwo", {StrSection, static_cast(0)}},
-  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_LOC}},
+  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_EXT_LOC}},
   {"debug_line.dwo", {MCOFI.getDwarfLineDWOSection(), DW_SECT_LINE}},
   {"debug_abbrev.dwo", {MCOFI.getDwarfAbbrevDWOSection(), DW_SECT_ABBREV}},
   {"debug_cu_index", {CUIndexSection, stati

[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-19 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin marked 3 inline comments as done.
ikudrin added a comment.

In D75929#1926834 , @labath wrote:

> (btw, is there a test case for the "unknown column" code path?)


Yes, it is checked in 
`llvm/test/DebugInfo/X86/debug-cu-index-unknown-section.s`, which was added in 
D75609  and then extended in D75668 
.

As for unknown columns in general, I believe they are not that important to 
complicate the code too much. Before D75609 , 
`llvm-dwarfdump` just crashed when saw them. `dwarfdump` prints some useless 
(for a user) error message. An unknown column cannot be used by clients of the 
library because they do not know what to do with it. Dumping is the only reason 
to support unknown identifiers, and that should be done as simple as possible. 
If the current implementation seems too complicated, we can consider, for 
example, dropping printing raw IDs for unknown sections.




Comment at: llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h:47-48
+// For pre-standard ones, which correspond to sections being deprecated in
+// DWARFv5, the values are chosen more or less arbitrary and a tag "_EXT_"
+// is added to the names.
+//

dblaikie wrote:
> Probably not arbitrarily - in the sense that this is an extension that 
> consumers/producers will need to agree to - so maybe saying that 
> ("non-standard extension"/"proposed for standardization" or something to that 
> effect) and/or linking to the dwarf-discuss thread to support why these 
> values were chosen & they can't be changed arbitrarily.
As far as the enum is internal, no one should really worry about the actual 
values; they are not important and do not need any kind of proof. They may be 
really arbitrary, that will change nothing. That is what I meant when said 
"more or less".

The plan is that this patch supports DWARFv5 unit indexes, but not the proposed 
combined indexes. When the combined indexes are approved, there will be another 
patch, which moves the enum with all extensions in the public space. At that 
moment the factual values will become important, and the references to the 
descriptive document will be added. Do you think it will be possible to add 
such a document to the [[ http://wiki.dwarfstd.org | DWARF Wiki ]]?



Comment at: llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp:96-100
   Version = IndexData.getU32(OffsetPtr);
+  if (Version != 2) {
+*OffsetPtr = BeginOffset;
+Version = IndexData.getU16(OffsetPtr);
+if (Version != 5)

dblaikie wrote:
> What endianness is this encoded with? If it's little endian, then a 2 byte 
> field with 2 bytes of zero padding should be the same as reading a 4 bytes, 
> or the other way around, right? So perhaps we could just always read it as 2 
> bytes then 2 bytes of padding rather than having to the version/reset/reread 
> dance here?
The endianness comes from the input file. I cannot find anything in the 
standard or the pre-standard proposal that would restrict it to be only 
little-endian. Thus, we should handle both cases.



Comment at: llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp:131
 
+  // Fix InfoColumnKind: in DWARFv5, type units also lay in .debug_info.dwo.
+  if (Header.Version == 5)

dblaikie wrote:
> jhenderson wrote:
> > also lay -> are
> Should we be fixing it up here - or should we avoid setting it incorrectly in 
> the first place?
As it is written at the moment, we have to pass something to distinct TU and CU 
indexes, for v2 cases. We may pass, say, a bool, but `true` and `false` are not 
that descriptive as `DW_SECT_INFO` and `DW_SECT_TYPES`. I believe that for the 
purpose of this patch, this fix is the simplest thing to do.

BTW, to support the combined TU index, the code should be adjusted anyway 
because where probably will be two "main" columns, one for v2 type units in 
`.debug_types.dwo` and another for v5 type units in `.debug_info.dwo`.


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

https://reviews.llvm.org/D75929



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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-19 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin marked 2 inline comments as done.
ikudrin added inline comments.



Comment at: llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h:47-48
+// For pre-standard ones, which correspond to sections being deprecated in
+// DWARFv5, the values are chosen more or less arbitrary and a tag "_EXT_"
+// is added to the names.
+//

dblaikie wrote:
> ikudrin wrote:
> > dblaikie wrote:
> > > Probably not arbitrarily - in the sense that this is an extension that 
> > > consumers/producers will need to agree to - so maybe saying that 
> > > ("non-standard extension"/"proposed for standardization" or something to 
> > > that effect) and/or linking to the dwarf-discuss thread to support why 
> > > these values were chosen & they can't be changed arbitrarily.
> > As far as the enum is internal, no one should really worry about the actual 
> > values; they are not important and do not need any kind of proof. They may 
> > be really arbitrary, that will change nothing. That is what I meant when 
> > said "more or less".
> > 
> > The plan is that this patch supports DWARFv5 unit indexes, but not the 
> > proposed combined indexes. When the combined indexes are approved, there 
> > will be another patch, which moves the enum with all extensions in the 
> > public space. At that moment the factual values will become important, and 
> > the references to the descriptive document will be added. Do you think it 
> > will be possible to add such a document to the [[ http://wiki.dwarfstd.org 
> > | DWARF Wiki ]]?
> Hmm, I'm confused then - ah, OK - so you've added the enum to support 
> encoding the version 2 and version 5 tables into one internal data structure, 
> but haven't extended it to actually dump or use (for parsing: eg to find the 
> debug_loc.dwo contribution for a v4 unit described by a v5 index) them when 
> parsing/rendering a v5 index.
> 
> OK, sorry I hadn't realized that. Then, yes, the comment makes sense for now. 
> Perhaps "the values are only used internally/not parsed from input files (if 
> these values appear in input files they will be considered "unknown")" would 
> be more suitable?
> 
> > The plan is that this patch supports DWARFv5 unit indexes, but not the 
> > proposed combined indexes. When the combined indexes are approved, there 
> > will be another patch, which moves the enum with all extensions in the 
> > public space. At that moment the factual values will become important, and 
> > the references to the descriptive document will be added. Do you think it 
> > will be possible to add such a document to the DWARF Wiki?
> 
> Given the DWARF committee is not in session at the moment (I think) & it'll 
> be a while before another spec is published - I think it'll be necessary and 
> appropriate to implement support for the extension columns in llvm-dwarfdump 
> at least before/when they're implemented in llvm-dwp (which will be soon) to 
> support testing that functionality & working with such files.
> 
> Might be able to put something on the DWARF wiki, but I don't know much about 
> it/how things go up there.
> Perhaps "the values are only used internally/not parsed from input files (if 
> these values appear in input files they will be considered "unknown")" would 
> be more suitable?

The comment says something similar in lines 52-53. Do you think it should be 
extended?

> I think it'll be necessary and appropriate to implement support for the 
> extension columns in llvm-dwarfdump at least before/when they're implemented 
> in llvm-dwp (which will be soon) to support testing that functionality & 
> working with such files.

I think the same. The only concern in my side is that the proposal should be 
formulated as an RFC or similar document before implementing it in the code so 
that all the implementations can reference the same source. For my taste, a 
link to the middle of a forum conversation cannot be considered as a reliable 
source.



Comment at: llvm/test/DebugInfo/X86/dwp-v5-loclists.s:1-3
+## The test checks that v5 compile units in package files read their
+## location tables from .debug_loclists.dwo sections.
+## See dwp-v2-loc.s for pre-v5 units.

dblaikie wrote:
> Might be possible/better to test this without debug_abbrev and debug_info - 
> make the test shorter & dump only the loclists section itself? Yeah, not 
> exactly valid, but no reason the dumper shouldn't support it and it'd be a 
> more targeted test (apply this suggestion to other tests if 
> possible/acceptable too)
This test is for changes in the constructor of `DWARFUnit`. It checks that 
`DWARFUnit` takes locations from the right place, so all four sections are 
necessary.


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

https://reviews.llvm.org/D75929



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


[Lldb-commits] [PATCH] D77141: [DebugInfo] Rename section identifiers which are deprecated in DWARFv5. NFC.

2020-03-31 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin created this revision.
ikudrin added reviewers: dblaikie, jhenderson, probinson, aprantl.
ikudrin added projects: LLVM, debug-info.
Herald added subscribers: lldb-commits, arphaman, hiraditya.
Herald added a project: LLDB.
ikudrin added a parent revision: D76067: [llvm-dwp] Refactor handling of 
section identifiers. NFCI..

This is a preparation for an upcoming patch which adds support for DWARFv5 unit 
index sections. The patch adds tag "_EXT_" to identifiers which reference 
sections that are deprecated in the DWARFv5 standard.

See D75929  for the discussion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77141

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -259,7 +259,7 @@
   C.Length = I->Length;
   ++I;
 }
-const unsigned TypesIndex = getContributionIndex(DW_SECT_TYPES);
+const unsigned TypesIndex = getContributionIndex(DW_SECT_EXT_TYPES);
 auto &C = Entry.Contributions[TypesIndex];
 Out.emitBytes(Types.substr(
 C.Offset - TUEntry.Contributions[TypesIndex].Offset, C.Length));
@@ -281,7 +281,7 @@
   UnitIndexEntry Entry = CUEntry;
   // Zero out the debug_info contribution
   Entry.Contributions[0] = {};
-  auto &C = Entry.Contributions[getContributionIndex(DW_SECT_TYPES)];
+  auto &C = Entry.Contributions[getContributionIndex(DW_SECT_EXT_TYPES)];
   C.Offset = TypesOffset;
   auto PrevOffset = Offset;
   // Length of the unit, including the 4 byte length field.
@@ -452,7 +452,7 @@
 
   if (DWARFSectionKind Kind = SectionPair->second.second) {
 auto Index = getContributionIndex(Kind);
-if (Kind != DW_SECT_TYPES) {
+if (Kind != DW_SECT_EXT_TYPES) {
   CurEntry.Contributions[Index].Offset = ContributionOffsets[Index];
   ContributionOffsets[Index] +=
   (CurEntry.Contributions[Index].Length = Contents.size());
@@ -536,10 +536,10 @@
   MCSection *const TUIndexSection = MCOFI.getDwarfTUIndexSection();
   const StringMap> KnownSections = {
   {"debug_info.dwo", {MCOFI.getDwarfInfoDWOSection(), DW_SECT_INFO}},
-  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_TYPES}},
+  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_EXT_TYPES}},
   {"debug_str_offsets.dwo", {StrOffsetSection, DW_SECT_STR_OFFSETS}},
   {"debug_str.dwo", {StrSection, static_cast(0)}},
-  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_LOC}},
+  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_EXT_LOC}},
   {"debug_line.dwo", {MCOFI.getDwarfLineDWOSection(), DW_SECT_LINE}},
   {"debug_abbrev.dwo", {MCOFI.getDwarfAbbrevDWOSection(), DW_SECT_ABBREV}},
   {"debug_cu_index", {CUIndexSection, static_cast(0)}},
@@ -603,7 +603,7 @@
   P.first->second.DWOName = ID.DWOName;
   addAllTypes(Out, TypeIndexEntries, TypesSection, CurTypesSection,
   CurEntry,
-  ContributionOffsets[getContributionIndex(DW_SECT_TYPES)]);
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)]);
   continue;
 }
 
@@ -642,13 +642,14 @@
 if (!CurTypesSection.empty()) {
   if (CurTypesSection.size() != 1)
 return make_error("multiple type unit sections in .dwp file");
-  DWARFUnitIndex TUIndex(DW_SECT_TYPES);
+  DWARFUnitIndex TUIndex(DW_SECT_EXT_TYPES);
   DataExtractor TUIndexData(CurTUIndexSection, Obj.isLittleEndian(), 0);
   if (!TUIndex.parse(TUIndexData))
 return make_error("failed to parse tu_index");
   addAllTypesFromDWP(
   Out, TypeIndexEntries, TUIndex, TypesSection, CurTypesSection.front(),
-  CurEntry, ContributionOffsets[getContributionIndex(DW_SECT_TYPES)]);
+  CurEntry,
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)]);
 }
   }
 
@@ -659,7 +660,7 @@
  TypeIndexEntries);
 
   // Lie about the type contribution
-  ContributionOffsets[getContributionIndex(DW_SECT_TYPES)] = 0;
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)] = 0;
   // Unlie about the info contribution
   ContributionOffsets[0] = 1;
 
Index: llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
===
--- llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -352,7 +352,7 @@
 
   OS << "Verifying .debug_types Unit Header Chain...\n";
   DObj.forEachTypesSections([&](

[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-31 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin updated this revision to Diff 253879.
ikudrin added a comment.

- Removed `DWARFUnitIndex::getVersion()` as it is related to the other patch.


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

https://reviews.llvm.org/D75929

Files:
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -216,11 +216,12 @@
   StringRef DWPName;
 };
 
-// Convert a section identifier into the index to use with
+// Convert an internal section identifier into the index to use with
 // UnitIndexEntry::Contributions.
 static unsigned getContributionIndex(DWARFSectionKind Kind) {
-  assert(Kind >= DW_SECT_INFO);
-  return Kind - DW_SECT_INFO;
+  // Assuming the pre-standard DWP format.
+  assert(serializeSectionKind(Kind, 2) >= DW_SECT_INFO);
+  return serializeSectionKind(Kind, 2) - DW_SECT_INFO;
 }
 
 // Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
Index: llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
@@ -0,0 +1,43 @@
+## The test checks that we can parse and dump a TU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-tu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_tu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE STR_OFFSETS
+# CHECK-NEXT: - --    
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040)
+
+.section .debug_tu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 4 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of Section Offsets:
+## Row 0:
+.long 1 # DW_SECT_INFO
+.long 3 # DW_SECT_ABBREV
+.long 4 # DW_SECT_LINE
+.long 6 # DW_SECT_STR_OFFSETS
+## Row 1:
+.long 0x1000# Offset in .debug_info.dwo
+.long 0x2000# Offset in .debug_abbrev.dwo
+.long 0x3000# Offset in .debug_line.dwo
+.long 0x4000# Offset in .debug_str_offsets.dwo
+## Table of Section Sizes:
+.long 0x10  # Size in .debug_info.dwo
+.long 0x20  # Size in .debug_abbrev.dwo
+.long 0x30  # Size in .debug_line.dwo
+.long 0x40  # Size in .debug_str_offsets.dwo
Index: llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
@@ -0,0 +1,52 @@
+## The test checks that we can parse and dump a CU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-cu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_cu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE LOCLISTS STR_OFFSETS  MACRORNGLISTS
+# CHECK-NEXT: - --       
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040) [0x5000, 0x5050) [0x6000, 0x6060) [0x7000, 0x7070)
+
+.section .debug_cu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 7 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of Section Offsets:
+## Row 0:
+.long 1 

[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-31 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin updated this revision to Diff 253874.
ikudrin marked 4 inline comments as done.
ikudrin added a comment.

- Updated the comment for `DWARFSectionKind`.
- Simplified the storing of raw section identifiers.
- Moved independent changes into separate patches.


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

https://reviews.llvm.org/D75929

Files:
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -216,11 +216,12 @@
   StringRef DWPName;
 };
 
-// Convert a section identifier into the index to use with
+// Convert an internal section identifier into the index to use with
 // UnitIndexEntry::Contributions.
 static unsigned getContributionIndex(DWARFSectionKind Kind) {
-  assert(Kind >= DW_SECT_INFO);
-  return Kind - DW_SECT_INFO;
+  // Assuming the pre-standard DWP format.
+  assert(serializeSectionKind(Kind, 2) >= DW_SECT_INFO);
+  return serializeSectionKind(Kind, 2) - DW_SECT_INFO;
 }
 
 // Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
Index: llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
@@ -0,0 +1,43 @@
+## The test checks that we can parse and dump a TU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-tu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_tu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE STR_OFFSETS
+# CHECK-NEXT: - --    
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040)
+
+.section .debug_tu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 4 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of Section Offsets:
+## Row 0:
+.long 1 # DW_SECT_INFO
+.long 3 # DW_SECT_ABBREV
+.long 4 # DW_SECT_LINE
+.long 6 # DW_SECT_STR_OFFSETS
+## Row 1:
+.long 0x1000# Offset in .debug_info.dwo
+.long 0x2000# Offset in .debug_abbrev.dwo
+.long 0x3000# Offset in .debug_line.dwo
+.long 0x4000# Offset in .debug_str_offsets.dwo
+## Table of Section Sizes:
+.long 0x10  # Size in .debug_info.dwo
+.long 0x20  # Size in .debug_abbrev.dwo
+.long 0x30  # Size in .debug_line.dwo
+.long 0x40  # Size in .debug_str_offsets.dwo
Index: llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
@@ -0,0 +1,52 @@
+## The test checks that we can parse and dump a CU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-cu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_cu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE LOCLISTS STR_OFFSETS  MACRORNGLISTS
+# CHECK-NEXT: - --       
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040) [0x5000, 0x5050) [0x6000, 0x6060) [0x7000, 0x7070)
+
+.section .debug_cu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 7 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+

[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-04-01 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin updated this revision to Diff 254207.
ikudrin marked an inline comment as done.
ikudrin added a comment.

Thanks, @jhenderson, @labath!

- Added a helper function `isKnownV5SectionID()`.


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

https://reviews.llvm.org/D75929

Files:
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -216,11 +216,12 @@
   StringRef DWPName;
 };
 
-// Convert a section identifier into the index to use with
+// Convert an internal section identifier into the index to use with
 // UnitIndexEntry::Contributions.
 static unsigned getContributionIndex(DWARFSectionKind Kind) {
-  assert(Kind >= DW_SECT_INFO);
-  return Kind - DW_SECT_INFO;
+  // Assuming the pre-standard DWP format.
+  assert(serializeSectionKind(Kind, 2) >= DW_SECT_INFO);
+  return serializeSectionKind(Kind, 2) - DW_SECT_INFO;
 }
 
 // Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
Index: llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
@@ -0,0 +1,43 @@
+## The test checks that we can parse and dump a TU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-tu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_tu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE STR_OFFSETS
+# CHECK-NEXT: - --    
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040)
+
+.section .debug_tu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 4 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of Section Offsets:
+## Row 0:
+.long 1 # DW_SECT_INFO
+.long 3 # DW_SECT_ABBREV
+.long 4 # DW_SECT_LINE
+.long 6 # DW_SECT_STR_OFFSETS
+## Row 1:
+.long 0x1000# Offset in .debug_info.dwo
+.long 0x2000# Offset in .debug_abbrev.dwo
+.long 0x3000# Offset in .debug_line.dwo
+.long 0x4000# Offset in .debug_str_offsets.dwo
+## Table of Section Sizes:
+.long 0x10  # Size in .debug_info.dwo
+.long 0x20  # Size in .debug_abbrev.dwo
+.long 0x30  # Size in .debug_line.dwo
+.long 0x40  # Size in .debug_str_offsets.dwo
Index: llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
@@ -0,0 +1,52 @@
+## The test checks that we can parse and dump a CU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-cu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_cu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE LOCLISTS STR_OFFSETS  MACRORNGLISTS
+# CHECK-NEXT: - --       
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040) [0x5000, 0x5050) [0x6000, 0x6060) [0x7000, 0x7070)
+
+.section .debug_cu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 7 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of 

[Lldb-commits] [PATCH] D77302: [DebugInfo] Rename getOffset() to getContribution(). NFC.

2020-04-02 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin created this revision.
ikudrin added reviewers: jhenderson, dblaikie, probinson, aprantl.
ikudrin added projects: LLVM, debug-info.
Herald added subscribers: lldb-commits, arphaman, hiraditya.
Herald added a project: LLDB.

The old name was a bit misleading because the functions actually return 
contributions to the corresponding sections. See D77146 
 for the discussion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77302

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -219,7 +219,7 @@
 static StringRef getSubsection(StringRef Section,
const DWARFUnitIndex::Entry &Entry,
DWARFSectionKind Kind) {
-  const auto *Off = Entry.getOffset(Kind);
+  const auto *Off = Entry.getContribution(Kind);
   if (!Off)
 return StringRef();
   return Section.substr(Off->Offset, Off->Length);
@@ -231,7 +231,7 @@
 const UnitIndexEntry &TUEntry, uint32_t &TypesOffset) {
   Out.SwitchSection(OutputTypes);
   for (const DWARFUnitIndex::Entry &E : TUIndex.getRows()) {
-auto *I = E.getOffsets();
+auto *I = E.getContributions();
 if (!I)
   continue;
 auto P = TypeIndexEntries.insert(std::make_pair(E.getSignature(), TUEntry));
@@ -599,7 +599,7 @@
   return make_error("failed to parse cu_index");
 
 for (const DWARFUnitIndex::Entry &E : CUIndex.getRows()) {
-  auto *I = E.getOffsets();
+  auto *I = E.getContributions();
   if (!I)
 continue;
   auto P = IndexEntries.insert(std::make_pair(E.getSignature(), CurEntry));
Index: llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
===
--- llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
@@ -154,7 +154,7 @@
 }
 
 const DWARFUnitIndex::Entry::SectionContribution *
-DWARFUnitIndex::Entry::getOffset(DWARFSectionKind Sec) const {
+DWARFUnitIndex::Entry::getContribution(DWARFSectionKind Sec) const {
   uint32_t i = 0;
   for (; i != Index->Header.NumColumns; ++i)
 if (Index->ColumnKinds[i] == Sec)
@@ -163,7 +163,7 @@
 }
 
 const DWARFUnitIndex::Entry::SectionContribution *
-DWARFUnitIndex::Entry::getOffset() const {
+DWARFUnitIndex::Entry::getContribution() const {
   return &Contributions[Index->InfoColumn];
 }
 
Index: llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
===
--- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -139,7 +139,7 @@
 
 DWARFUnit *
 DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) {
-  const auto *CUOff = E.getOffset(DW_SECT_INFO);
+  const auto *CUOff = E.getContribution(DW_SECT_INFO);
   if (!CUOff)
 return nullptr;
 
@@ -183,7 +183,7 @@
 // data based on the index entries.
 StringRef Data = LocSection->Data;
 if (auto *IndexEntry = Header.getIndexEntry())
-  if (const auto *C = IndexEntry->getOffset(DW_SECT_LOC))
+  if (const auto *C = IndexEntry->getContribution(DW_SECT_LOC))
 Data = Data.substr(C->Offset, C->Length);
 
 DWARFDataExtractor DWARFData =
@@ -294,11 +294,11 @@
   if (IndexEntry) {
 if (AbbrOffset)
   return false;
-auto *UnitContrib = IndexEntry->getOffset();
+auto *UnitContrib = IndexEntry->getContribution();
 if (!UnitContrib ||
 UnitContrib->Length != (Length + getUnitLengthFieldByteSize()))
   return false;
-auto *AbbrEntry = IndexEntry->getOffset(DW_SECT_ABBREV);
+auto *AbbrEntry = IndexEntry->getContribution(DW_SECT_ABBREV);
 if (!AbbrEntry)
   return false;
 AbbrOffset = AbbrEntry->Offset;
@@ -966,7 +966,7 @@
   uint64_t Offset = 0;
   auto IndexEntry = Header.getIndexEntry();
   const auto *C =
-  IndexEntry ? IndexEntry->getOffset(DW_SECT_STR_OFFSETS) : nullptr;
+  IndexEntry ? IndexEntry->getContribution(DW_SECT_STR_OFFSETS) : nullptr;
   if (C)
 Offset = C->Offset;
   if (getVersion() >= 5) {
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
===
--- llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
@@ -56,10 +56,10 @@
 friend class DWARFUnitIndex;
 
   public:
-const SectionContribution *getOffset(DWARFSectionKind Sec) const;
-const SectionContribution *getOffset() const;
+const SectionContribution *getContribution(DWARFSectionKind Sec) 

[Lldb-commits] [PATCH] D77302: [DebugInfo] Rename getOffset() to getContribution(). NFC.

2020-04-05 Thread Igor Kudrin via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf13ce15d4410: [DebugInfo] Rename getOffset() to 
getContribution(). NFC. (authored by ikudrin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77302

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -219,7 +219,7 @@
 static StringRef getSubsection(StringRef Section,
const DWARFUnitIndex::Entry &Entry,
DWARFSectionKind Kind) {
-  const auto *Off = Entry.getOffset(Kind);
+  const auto *Off = Entry.getContribution(Kind);
   if (!Off)
 return StringRef();
   return Section.substr(Off->Offset, Off->Length);
@@ -231,7 +231,7 @@
 const UnitIndexEntry &TUEntry, uint32_t &TypesOffset) {
   Out.SwitchSection(OutputTypes);
   for (const DWARFUnitIndex::Entry &E : TUIndex.getRows()) {
-auto *I = E.getOffsets();
+auto *I = E.getContributions();
 if (!I)
   continue;
 auto P = TypeIndexEntries.insert(std::make_pair(E.getSignature(), TUEntry));
@@ -599,7 +599,7 @@
   return make_error("failed to parse cu_index");
 
 for (const DWARFUnitIndex::Entry &E : CUIndex.getRows()) {
-  auto *I = E.getOffsets();
+  auto *I = E.getContributions();
   if (!I)
 continue;
   auto P = IndexEntries.insert(std::make_pair(E.getSignature(), CurEntry));
Index: llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
===
--- llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
@@ -154,7 +154,7 @@
 }
 
 const DWARFUnitIndex::Entry::SectionContribution *
-DWARFUnitIndex::Entry::getOffset(DWARFSectionKind Sec) const {
+DWARFUnitIndex::Entry::getContribution(DWARFSectionKind Sec) const {
   uint32_t i = 0;
   for (; i != Index->Header.NumColumns; ++i)
 if (Index->ColumnKinds[i] == Sec)
@@ -163,7 +163,7 @@
 }
 
 const DWARFUnitIndex::Entry::SectionContribution *
-DWARFUnitIndex::Entry::getOffset() const {
+DWARFUnitIndex::Entry::getContribution() const {
   return &Contributions[Index->InfoColumn];
 }
 
Index: llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
===
--- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -139,7 +139,7 @@
 
 DWARFUnit *
 DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) {
-  const auto *CUOff = E.getOffset(DW_SECT_INFO);
+  const auto *CUOff = E.getContribution(DW_SECT_INFO);
   if (!CUOff)
 return nullptr;
 
@@ -183,7 +183,7 @@
 // data based on the index entries.
 StringRef Data = LocSection->Data;
 if (auto *IndexEntry = Header.getIndexEntry())
-  if (const auto *C = IndexEntry->getOffset(DW_SECT_LOC))
+  if (const auto *C = IndexEntry->getContribution(DW_SECT_LOC))
 Data = Data.substr(C->Offset, C->Length);
 
 DWARFDataExtractor DWARFData =
@@ -294,11 +294,11 @@
   if (IndexEntry) {
 if (AbbrOffset)
   return false;
-auto *UnitContrib = IndexEntry->getOffset();
+auto *UnitContrib = IndexEntry->getContribution();
 if (!UnitContrib ||
 UnitContrib->Length != (Length + getUnitLengthFieldByteSize()))
   return false;
-auto *AbbrEntry = IndexEntry->getOffset(DW_SECT_ABBREV);
+auto *AbbrEntry = IndexEntry->getContribution(DW_SECT_ABBREV);
 if (!AbbrEntry)
   return false;
 AbbrOffset = AbbrEntry->Offset;
@@ -966,7 +966,7 @@
   uint64_t Offset = 0;
   auto IndexEntry = Header.getIndexEntry();
   const auto *C =
-  IndexEntry ? IndexEntry->getOffset(DW_SECT_STR_OFFSETS) : nullptr;
+  IndexEntry ? IndexEntry->getContribution(DW_SECT_STR_OFFSETS) : nullptr;
   if (C)
 Offset = C->Offset;
   if (getVersion() >= 5) {
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
===
--- llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
@@ -56,10 +56,10 @@
 friend class DWARFUnitIndex;
 
   public:
-const SectionContribution *getOffset(DWARFSectionKind Sec) const;
-const SectionContribution *getOffset() const;
+const SectionContribution *getContribution(DWARFSectionKind Sec) const;
+const SectionContribution *getContribution() const;
 
-const SectionContribution *getOffsets() const {
+const SectionContribution *getContribu

[Lldb-commits] [PATCH] D77141: [DebugInfo] Rename section identifiers which are deprecated in DWARFv5. NFC.

2020-04-05 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin updated this revision to Diff 254802.
ikudrin added a comment.

- Rebased to the tip.


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

https://reviews.llvm.org/D77141

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -259,7 +259,7 @@
   C.Length = I->Length;
   ++I;
 }
-const unsigned TypesIndex = getContributionIndex(DW_SECT_TYPES);
+const unsigned TypesIndex = getContributionIndex(DW_SECT_EXT_TYPES);
 auto &C = Entry.Contributions[TypesIndex];
 Out.emitBytes(Types.substr(
 C.Offset - TUEntry.Contributions[TypesIndex].Offset, C.Length));
@@ -281,7 +281,7 @@
   UnitIndexEntry Entry = CUEntry;
   // Zero out the debug_info contribution
   Entry.Contributions[0] = {};
-  auto &C = Entry.Contributions[getContributionIndex(DW_SECT_TYPES)];
+  auto &C = Entry.Contributions[getContributionIndex(DW_SECT_EXT_TYPES)];
   C.Offset = TypesOffset;
   auto PrevOffset = Offset;
   // Length of the unit, including the 4 byte length field.
@@ -452,7 +452,7 @@
 
   if (DWARFSectionKind Kind = SectionPair->second.second) {
 auto Index = getContributionIndex(Kind);
-if (Kind != DW_SECT_TYPES) {
+if (Kind != DW_SECT_EXT_TYPES) {
   CurEntry.Contributions[Index].Offset = ContributionOffsets[Index];
   ContributionOffsets[Index] +=
   (CurEntry.Contributions[Index].Length = Contents.size());
@@ -536,10 +536,10 @@
   MCSection *const TUIndexSection = MCOFI.getDwarfTUIndexSection();
   const StringMap> KnownSections = {
   {"debug_info.dwo", {MCOFI.getDwarfInfoDWOSection(), DW_SECT_INFO}},
-  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_TYPES}},
+  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_EXT_TYPES}},
   {"debug_str_offsets.dwo", {StrOffsetSection, DW_SECT_STR_OFFSETS}},
   {"debug_str.dwo", {StrSection, static_cast(0)}},
-  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_LOC}},
+  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_EXT_LOC}},
   {"debug_line.dwo", {MCOFI.getDwarfLineDWOSection(), DW_SECT_LINE}},
   {"debug_abbrev.dwo", {MCOFI.getDwarfAbbrevDWOSection(), DW_SECT_ABBREV}},
   {"debug_cu_index", {CUIndexSection, static_cast(0)}},
@@ -603,7 +603,7 @@
   P.first->second.DWOName = ID.DWOName;
   addAllTypes(Out, TypeIndexEntries, TypesSection, CurTypesSection,
   CurEntry,
-  ContributionOffsets[getContributionIndex(DW_SECT_TYPES)]);
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)]);
   continue;
 }
 
@@ -642,13 +642,14 @@
 if (!CurTypesSection.empty()) {
   if (CurTypesSection.size() != 1)
 return make_error("multiple type unit sections in .dwp file");
-  DWARFUnitIndex TUIndex(DW_SECT_TYPES);
+  DWARFUnitIndex TUIndex(DW_SECT_EXT_TYPES);
   DataExtractor TUIndexData(CurTUIndexSection, Obj.isLittleEndian(), 0);
   if (!TUIndex.parse(TUIndexData))
 return make_error("failed to parse tu_index");
   addAllTypesFromDWP(
   Out, TypeIndexEntries, TUIndex, TypesSection, CurTypesSection.front(),
-  CurEntry, ContributionOffsets[getContributionIndex(DW_SECT_TYPES)]);
+  CurEntry,
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)]);
 }
   }
 
@@ -659,7 +660,7 @@
  TypeIndexEntries);
 
   // Lie about the type contribution
-  ContributionOffsets[getContributionIndex(DW_SECT_TYPES)] = 0;
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)] = 0;
   // Unlie about the info contribution
   ContributionOffsets[0] = 1;
 
Index: llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
===
--- llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -352,7 +352,7 @@
 
   OS << "Verifying .debug_types Unit Header Chain...\n";
   DObj.forEachTypesSections([&](const DWARFSection &S) {
-NumErrors += verifyUnitSection(S, DW_SECT_TYPES);
+NumErrors += verifyUnitSection(S, DW_SECT_EXT_TYPES);
   });
   return NumErrors == 0;
 }
Index: llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
===
--- llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
@@ -110,13 +110,16 @@
 return #DS;
   switch (DS) {
 CASE(INFO);
-CASE(TYPES);
 CAS

[Lldb-commits] [PATCH] D77141: [DebugInfo] Rename section identifiers which are deprecated in DWARFv5. NFC.

2020-04-06 Thread Igor Kudrin via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0249fe91c7b: [DebugInfo] Rename section identifiers which 
are deprecated in DWARFv5. NFC. (authored by ikudrin).

Changed prior to commit:
  https://reviews.llvm.org/D77141?vs=254802&id=255232#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77141

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -259,7 +259,7 @@
   C.Length = I->Length;
   ++I;
 }
-unsigned TypesIndex = getContributionIndex(DW_SECT_TYPES);
+unsigned TypesIndex = getContributionIndex(DW_SECT_EXT_TYPES);
 auto &C = Entry.Contributions[TypesIndex];
 Out.emitBytes(Types.substr(
 C.Offset - TUEntry.Contributions[TypesIndex].Offset, C.Length));
@@ -281,7 +281,7 @@
   UnitIndexEntry Entry = CUEntry;
   // Zero out the debug_info contribution
   Entry.Contributions[0] = {};
-  auto &C = Entry.Contributions[getContributionIndex(DW_SECT_TYPES)];
+  auto &C = Entry.Contributions[getContributionIndex(DW_SECT_EXT_TYPES)];
   C.Offset = TypesOffset;
   auto PrevOffset = Offset;
   // Length of the unit, including the 4 byte length field.
@@ -452,7 +452,7 @@
 
   if (DWARFSectionKind Kind = SectionPair->second.second) {
 auto Index = getContributionIndex(Kind);
-if (Kind != DW_SECT_TYPES) {
+if (Kind != DW_SECT_EXT_TYPES) {
   CurEntry.Contributions[Index].Offset = ContributionOffsets[Index];
   ContributionOffsets[Index] +=
   (CurEntry.Contributions[Index].Length = Contents.size());
@@ -536,10 +536,10 @@
   MCSection *const TUIndexSection = MCOFI.getDwarfTUIndexSection();
   const StringMap> KnownSections = {
   {"debug_info.dwo", {MCOFI.getDwarfInfoDWOSection(), DW_SECT_INFO}},
-  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_TYPES}},
+  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_EXT_TYPES}},
   {"debug_str_offsets.dwo", {StrOffsetSection, DW_SECT_STR_OFFSETS}},
   {"debug_str.dwo", {StrSection, static_cast(0)}},
-  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_LOC}},
+  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_EXT_LOC}},
   {"debug_line.dwo", {MCOFI.getDwarfLineDWOSection(), DW_SECT_LINE}},
   {"debug_abbrev.dwo", {MCOFI.getDwarfAbbrevDWOSection(), DW_SECT_ABBREV}},
   {"debug_cu_index", {CUIndexSection, static_cast(0)}},
@@ -603,7 +603,7 @@
   P.first->second.DWOName = ID.DWOName;
   addAllTypes(Out, TypeIndexEntries, TypesSection, CurTypesSection,
   CurEntry,
-  ContributionOffsets[getContributionIndex(DW_SECT_TYPES)]);
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)]);
   continue;
 }
 
@@ -642,13 +642,14 @@
 if (!CurTypesSection.empty()) {
   if (CurTypesSection.size() != 1)
 return make_error("multiple type unit sections in .dwp file");
-  DWARFUnitIndex TUIndex(DW_SECT_TYPES);
+  DWARFUnitIndex TUIndex(DW_SECT_EXT_TYPES);
   DataExtractor TUIndexData(CurTUIndexSection, Obj.isLittleEndian(), 0);
   if (!TUIndex.parse(TUIndexData))
 return make_error("failed to parse tu_index");
   addAllTypesFromDWP(
   Out, TypeIndexEntries, TUIndex, TypesSection, CurTypesSection.front(),
-  CurEntry, ContributionOffsets[getContributionIndex(DW_SECT_TYPES)]);
+  CurEntry,
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)]);
 }
   }
 
@@ -659,7 +660,7 @@
  TypeIndexEntries);
 
   // Lie about the type contribution
-  ContributionOffsets[getContributionIndex(DW_SECT_TYPES)] = 0;
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)] = 0;
   // Unlie about the info contribution
   ContributionOffsets[0] = 1;
 
Index: llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
===
--- llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -352,7 +352,7 @@
 
   OS << "Verifying .debug_types Unit Header Chain...\n";
   DObj.forEachTypesSections([&](const DWARFSection &S) {
-NumErrors += verifyUnitSection(S, DW_SECT_TYPES);
+NumErrors += verifyUnitSection(S, DW_SECT_EXT_TYPES);
   });
   return NumErrors == 0;
 }
Index: llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
===

[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-04-06 Thread Igor Kudrin via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG714324b79ae2: [DebugInfo] Support DWARFv5 index sections. 
(authored by ikudrin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75929

Files:
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -216,11 +216,12 @@
   StringRef DWPName;
 };
 
-// Convert a section identifier into the index to use with
+// Convert an internal section identifier into the index to use with
 // UnitIndexEntry::Contributions.
 static unsigned getContributionIndex(DWARFSectionKind Kind) {
-  assert(Kind >= DW_SECT_INFO);
-  return Kind - DW_SECT_INFO;
+  // Assuming the pre-standard DWP format.
+  assert(serializeSectionKind(Kind, 2) >= DW_SECT_INFO);
+  return serializeSectionKind(Kind, 2) - DW_SECT_INFO;
 }
 
 // Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
Index: llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
@@ -0,0 +1,43 @@
+## The test checks that we can parse and dump a TU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-tu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_tu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE STR_OFFSETS
+# CHECK-NEXT: - --    
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040)
+
+.section .debug_tu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 4 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of Section Offsets:
+## Row 0:
+.long 1 # DW_SECT_INFO
+.long 3 # DW_SECT_ABBREV
+.long 4 # DW_SECT_LINE
+.long 6 # DW_SECT_STR_OFFSETS
+## Row 1:
+.long 0x1000# Offset in .debug_info.dwo
+.long 0x2000# Offset in .debug_abbrev.dwo
+.long 0x3000# Offset in .debug_line.dwo
+.long 0x4000# Offset in .debug_str_offsets.dwo
+## Table of Section Sizes:
+.long 0x10  # Size in .debug_info.dwo
+.long 0x20  # Size in .debug_abbrev.dwo
+.long 0x30  # Size in .debug_line.dwo
+.long 0x40  # Size in .debug_str_offsets.dwo
Index: llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
@@ -0,0 +1,52 @@
+## The test checks that we can parse and dump a CU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-cu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_cu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE LOCLISTS STR_OFFSETS  MACRORNGLISTS
+# CHECK-NEXT: - --       
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040) [0x5000, 0x5050) [0x6000, 0x6060) [0x7000, 0x7070)
+
+.section .debug_cu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 7 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.lo

[Lldb-commits] [PATCH] D65640: Update LLDB to follow changes in llvm::DWARFDebugNames::NameIndex (4/5)

2019-08-02 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin created this revision.
ikudrin added reviewers: dblaikie, probinson, aprantl, clayborg, labath.
ikudrin added a project: LLDB.
Herald added a subscriber: arphaman.
ikudrin added a parent revision: D65638: Switch LLVM to use 64-bit offsets 
(2/5).

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D65640

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


Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -105,7 +105,7 @@
   if (!regex.Execute(nte.getString()))
 continue;
 
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 if (entry_or->tag() != DW_TAG_variable)
@@ -125,7 +125,7 @@
   uint64_t cu_offset = cu.GetOffset();
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 for (DebugNames::NameTableEntry nte: ni) {
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 if (entry_or->tag() != DW_TAG_variable)
@@ -248,7 +248,7 @@
   if (!regex.Execute(nte.getString()))
 continue;
 
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 Tag tag = entry_or->tag();


Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -105,7 +105,7 @@
   if (!regex.Execute(nte.getString()))
 continue;
 
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 if (entry_or->tag() != DW_TAG_variable)
@@ -125,7 +125,7 @@
   uint64_t cu_offset = cu.GetOffset();
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 for (DebugNames::NameTableEntry nte: ni) {
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 if (entry_or->tag() != DW_TAG_variable)
@@ -248,7 +248,7 @@
   if (!regex.Execute(nte.getString()))
 continue;
 
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 Tag tag = entry_or->tag();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65640: Update LLDB to follow changes in llvm::DWARFDebugNames::NameIndex (4/5)

2019-08-06 Thread Igor Kudrin via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL368033: Update LLDB to follow changes in 
llvm::DWARFDebugNames::NameIndex (4/5) (authored by ikudrin, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65640?vs=212996&id=213596#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65640

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


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -105,7 +105,7 @@
   if (!regex.Execute(nte.getString()))
 continue;
 
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 if (entry_or->tag() != DW_TAG_variable)
@@ -125,7 +125,7 @@
   uint64_t cu_offset = cu.GetOffset();
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 for (DebugNames::NameTableEntry nte: ni) {
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 if (entry_or->tag() != DW_TAG_variable)
@@ -248,7 +248,7 @@
   if (!regex.Execute(nte.getString()))
 continue;
 
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 Tag tag = entry_or->tag();


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -105,7 +105,7 @@
   if (!regex.Execute(nte.getString()))
 continue;
 
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 if (entry_or->tag() != DW_TAG_variable)
@@ -125,7 +125,7 @@
   uint64_t cu_offset = cu.GetOffset();
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 for (DebugNames::NameTableEntry nte: ni) {
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 if (entry_or->tag() != DW_TAG_variable)
@@ -248,7 +248,7 @@
   if (!regex.Execute(nte.getString()))
 continue;
 
-  uint32_t entry_offset = nte.getEntryOffset();
+  uint64_t entry_offset = nte.getEntryOffset();
   llvm::Expected entry_or = ni.getEntry(&entry_offset);
   for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
 Tag tag = entry_or->tag();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D59381: Change CompileUnit and ARanges interfaces to propagate errors

2019-12-24 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added inline comments.



Comment at: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp:60
+llvm::Error error = set.extract(debug_aranges_data, &offset);
+if (!error)
+  return error;

@zturner, this probably should be
```
if (error)
  return std::move(error);
```


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59381



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