2017-02-28 07:43:14 +08:00
|
|
|
//===- DWARFAcceleratorTable.cpp ------------------------------------------===//
|
2014-11-21 00:21:06 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2014-11-21 00:21:06 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-01-31 02:07:45 +08:00
|
|
|
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
|
2017-06-07 11:48:56 +08:00
|
|
|
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/Dwarf.h"
|
2017-02-28 07:43:14 +08:00
|
|
|
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
|
|
|
|
#include "llvm/Support/Compiler.h"
|
2018-01-28 19:05:10 +08:00
|
|
|
#include "llvm/Support/DJB.h"
|
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained
duplicating code for creating StringError instances, like:
template <typename... Ts>
static Error createError(char const *Fmt, const Ts &... Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
}
Similar function was placed in Support lib in https://reviews.llvm.org/D49824
This revision makes DWARF classes use this function
instead of their local implementation of it.
Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D49964
llvm-svn: 340163
2018-08-20 17:59:08 +08:00
|
|
|
#include "llvm/Support/Errc.h"
|
2014-11-15 00:15:53 +08:00
|
|
|
#include "llvm/Support/Format.h"
|
[dwarf] Unify unknown dwarf enum formatting code
Summary:
We have had at least three pieces of code (in DWARFAbbreviationDeclaration,
DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for
dumping unknown dwarf enum values. While not terrible, they are a bit
distracting and enable small differences to creep in (Unknown_ffff vs.
Unknown_0xffff). I ended up needing to add a fourth place
(DWARFVerifier), so it seems it would be a good time to centralize.
This patch creates an alternative to the XXXString dumping functions in
the BinaryFormat library, which formats an unknown value as
DW_TYPE_unknown_1234, instead of just an empty string. It is based on
the formatv function, as that allows us to avoid materializing the
string for unknown values (and because this way I don't have to invent a
name for the new functions :P).
In this patch I add formatters for dwarf attributes, forms, tags, and
index attributes as these are the ones in use currently, but adding
other enums is straight-forward.
Reviewers: dblaikie, JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44570
llvm-svn: 328090
2018-03-21 19:46:37 +08:00
|
|
|
#include "llvm/Support/FormatVariadic.h"
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
#include "llvm/Support/ScopedPrinter.h"
|
2014-11-15 00:15:53 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2017-02-28 07:43:14 +08:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <utility>
|
2014-11-15 00:15:53 +08:00
|
|
|
|
2017-02-28 07:43:14 +08:00
|
|
|
using namespace llvm;
|
2014-11-15 00:15:53 +08:00
|
|
|
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
namespace {
|
[dwarf] Unify unknown dwarf enum formatting code
Summary:
We have had at least three pieces of code (in DWARFAbbreviationDeclaration,
DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for
dumping unknown dwarf enum values. While not terrible, they are a bit
distracting and enable small differences to creep in (Unknown_ffff vs.
Unknown_0xffff). I ended up needing to add a fourth place
(DWARFVerifier), so it seems it would be a good time to centralize.
This patch creates an alternative to the XXXString dumping functions in
the BinaryFormat library, which formats an unknown value as
DW_TYPE_unknown_1234, instead of just an empty string. It is based on
the formatv function, as that allows us to avoid materializing the
string for unknown values (and because this way I don't have to invent a
name for the new functions :P).
In this patch I add formatters for dwarf attributes, forms, tags, and
index attributes as these are the ones in use currently, but adding
other enums is straight-forward.
Reviewers: dblaikie, JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44570
llvm-svn: 328090
2018-03-21 19:46:37 +08:00
|
|
|
struct Atom {
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
unsigned Value;
|
|
|
|
};
|
|
|
|
|
[dwarf] Unify unknown dwarf enum formatting code
Summary:
We have had at least three pieces of code (in DWARFAbbreviationDeclaration,
DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for
dumping unknown dwarf enum values. While not terrible, they are a bit
distracting and enable small differences to creep in (Unknown_ffff vs.
Unknown_0xffff). I ended up needing to add a fourth place
(DWARFVerifier), so it seems it would be a good time to centralize.
This patch creates an alternative to the XXXString dumping functions in
the BinaryFormat library, which formats an unknown value as
DW_TYPE_unknown_1234, instead of just an empty string. It is based on
the formatv function, as that allows us to avoid materializing the
string for unknown values (and because this way I don't have to invent a
name for the new functions :P).
In this patch I add formatters for dwarf attributes, forms, tags, and
index attributes as these are the ones in use currently, but adding
other enums is straight-forward.
Reviewers: dblaikie, JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44570
llvm-svn: 328090
2018-03-21 19:46:37 +08:00
|
|
|
static raw_ostream &operator<<(raw_ostream &OS, const Atom &A) {
|
|
|
|
StringRef Str = dwarf::AtomTypeString(A.Value);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
if (!Str.empty())
|
|
|
|
return OS << Str;
|
[dwarf] Unify unknown dwarf enum formatting code
Summary:
We have had at least three pieces of code (in DWARFAbbreviationDeclaration,
DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for
dumping unknown dwarf enum values. While not terrible, they are a bit
distracting and enable small differences to creep in (Unknown_ffff vs.
Unknown_0xffff). I ended up needing to add a fourth place
(DWARFVerifier), so it seems it would be a good time to centralize.
This patch creates an alternative to the XXXString dumping functions in
the BinaryFormat library, which formats an unknown value as
DW_TYPE_unknown_1234, instead of just an empty string. It is based on
the formatv function, as that allows us to avoid materializing the
string for unknown values (and because this way I don't have to invent a
name for the new functions :P).
In this patch I add formatters for dwarf attributes, forms, tags, and
index attributes as these are the ones in use currently, but adding
other enums is straight-forward.
Reviewers: dblaikie, JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44570
llvm-svn: 328090
2018-03-21 19:46:37 +08:00
|
|
|
return OS << "DW_ATOM_unknown_" << format("%x", A.Value);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
} // namespace
|
|
|
|
|
[dwarf] Unify unknown dwarf enum formatting code
Summary:
We have had at least three pieces of code (in DWARFAbbreviationDeclaration,
DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for
dumping unknown dwarf enum values. While not terrible, they are a bit
distracting and enable small differences to creep in (Unknown_ffff vs.
Unknown_0xffff). I ended up needing to add a fourth place
(DWARFVerifier), so it seems it would be a good time to centralize.
This patch creates an alternative to the XXXString dumping functions in
the BinaryFormat library, which formats an unknown value as
DW_TYPE_unknown_1234, instead of just an empty string. It is based on
the formatv function, as that allows us to avoid materializing the
string for unknown values (and because this way I don't have to invent a
name for the new functions :P).
In this patch I add formatters for dwarf attributes, forms, tags, and
index attributes as these are the ones in use currently, but adding
other enums is straight-forward.
Reviewers: dblaikie, JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44570
llvm-svn: 328090
2018-03-21 19:46:37 +08:00
|
|
|
static Atom formatAtom(unsigned Atom) { return {Atom}; }
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
|
|
|
|
DWARFAcceleratorTable::~DWARFAcceleratorTable() = default;
|
|
|
|
|
2019-04-17 17:11:08 +08:00
|
|
|
Error AppleAcceleratorTable::extract() {
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t Offset = 0;
|
2014-11-15 00:15:53 +08:00
|
|
|
|
|
|
|
// Check that we can at least read the header.
|
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained
duplicating code for creating StringError instances, like:
template <typename... Ts>
static Error createError(char const *Fmt, const Ts &... Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
}
Similar function was placed in Support lib in https://reviews.llvm.org/D49824
This revision makes DWARF classes use this function
instead of their local implementation of it.
Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D49964
llvm-svn: 340163
2018-08-20 17:59:08 +08:00
|
|
|
if (!AccelSection.isValidOffset(offsetof(Header, HeaderDataLength) + 4))
|
|
|
|
return createStringError(errc::illegal_byte_sequence,
|
|
|
|
"Section too small: cannot read header.");
|
2014-11-15 00:15:53 +08:00
|
|
|
|
|
|
|
Hdr.Magic = AccelSection.getU32(&Offset);
|
|
|
|
Hdr.Version = AccelSection.getU16(&Offset);
|
|
|
|
Hdr.HashFunction = AccelSection.getU16(&Offset);
|
2018-01-29 19:33:17 +08:00
|
|
|
Hdr.BucketCount = AccelSection.getU32(&Offset);
|
|
|
|
Hdr.HashCount = AccelSection.getU32(&Offset);
|
2014-11-15 00:15:53 +08:00
|
|
|
Hdr.HeaderDataLength = AccelSection.getU32(&Offset);
|
|
|
|
|
|
|
|
// Check that we can read all the hashes and offsets from the
|
|
|
|
// section (see SourceLevelDebugging.rst for the structure of the index).
|
2017-12-12 02:22:47 +08:00
|
|
|
// We need to substract one because we're checking for an *offset* which is
|
|
|
|
// equal to the size for an empty table and hence pointer after the section.
|
2014-11-15 00:15:53 +08:00
|
|
|
if (!AccelSection.isValidOffset(sizeof(Hdr) + Hdr.HeaderDataLength +
|
2018-01-29 19:33:17 +08:00
|
|
|
Hdr.BucketCount * 4 + Hdr.HashCount * 8 - 1))
|
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained
duplicating code for creating StringError instances, like:
template <typename... Ts>
static Error createError(char const *Fmt, const Ts &... Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
}
Similar function was placed in Support lib in https://reviews.llvm.org/D49824
This revision makes DWARF classes use this function
instead of their local implementation of it.
Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D49964
llvm-svn: 340163
2018-08-20 17:59:08 +08:00
|
|
|
return createStringError(
|
|
|
|
errc::illegal_byte_sequence,
|
|
|
|
"Section too small: cannot read buckets and hashes.");
|
2014-11-15 00:15:53 +08:00
|
|
|
|
|
|
|
HdrData.DIEOffsetBase = AccelSection.getU32(&Offset);
|
|
|
|
uint32_t NumAtoms = AccelSection.getU32(&Offset);
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < NumAtoms; ++i) {
|
|
|
|
uint16_t AtomType = AccelSection.getU16(&Offset);
|
2016-10-28 00:32:04 +08:00
|
|
|
auto AtomForm = static_cast<dwarf::Form>(AccelSection.getU16(&Offset));
|
2014-11-15 00:15:53 +08:00
|
|
|
HdrData.Atoms.push_back(std::make_pair(AtomType, AtomForm));
|
|
|
|
}
|
|
|
|
|
2017-09-29 02:10:52 +08:00
|
|
|
IsValid = true;
|
2017-12-12 02:22:47 +08:00
|
|
|
return Error::success();
|
2014-11-15 00:15:53 +08:00
|
|
|
}
|
|
|
|
|
2018-01-29 19:33:17 +08:00
|
|
|
uint32_t AppleAcceleratorTable::getNumBuckets() { return Hdr.BucketCount; }
|
|
|
|
uint32_t AppleAcceleratorTable::getNumHashes() { return Hdr.HashCount; }
|
2018-01-22 21:17:23 +08:00
|
|
|
uint32_t AppleAcceleratorTable::getSizeHdr() { return sizeof(Hdr); }
|
|
|
|
uint32_t AppleAcceleratorTable::getHeaderDataLength() {
|
2017-06-14 08:17:55 +08:00
|
|
|
return Hdr.HeaderDataLength;
|
|
|
|
}
|
|
|
|
|
2018-01-22 21:17:23 +08:00
|
|
|
ArrayRef<std::pair<AppleAcceleratorTable::HeaderData::AtomType,
|
|
|
|
AppleAcceleratorTable::HeaderData::Form>>
|
|
|
|
AppleAcceleratorTable::getAtomsDesc() {
|
2017-06-30 04:13:05 +08:00
|
|
|
return HdrData.Atoms;
|
|
|
|
}
|
|
|
|
|
2018-01-22 21:17:23 +08:00
|
|
|
bool AppleAcceleratorTable::validateForms() {
|
2017-06-30 04:13:05 +08:00
|
|
|
for (auto Atom : getAtomsDesc()) {
|
|
|
|
DWARFFormValue FormValue(Atom.second);
|
|
|
|
switch (Atom.first) {
|
|
|
|
case dwarf::DW_ATOM_die_offset:
|
2017-08-01 02:01:16 +08:00
|
|
|
case dwarf::DW_ATOM_die_tag:
|
|
|
|
case dwarf::DW_ATOM_type_flags:
|
2017-06-30 04:13:05 +08:00
|
|
|
if ((!FormValue.isFormClass(DWARFFormValue::FC_Constant) &&
|
|
|
|
!FormValue.isFormClass(DWARFFormValue::FC_Flag)) ||
|
|
|
|
FormValue.getForm() == dwarf::DW_FORM_sdata)
|
|
|
|
return false;
|
2017-12-20 06:05:25 +08:00
|
|
|
break;
|
2017-06-30 04:13:05 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-08-06 18:49:40 +08:00
|
|
|
std::pair<uint64_t, dwarf::Tag>
|
|
|
|
AppleAcceleratorTable::readAtoms(uint64_t *HashDataOffset) {
|
|
|
|
uint64_t DieOffset = dwarf::DW_INVALID_OFFSET;
|
2017-08-01 02:01:16 +08:00
|
|
|
dwarf::Tag DieTag = dwarf::DW_TAG_null;
|
2018-03-14 17:39:54 +08:00
|
|
|
dwarf::FormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32};
|
2017-06-30 04:13:05 +08:00
|
|
|
|
|
|
|
for (auto Atom : getAtomsDesc()) {
|
|
|
|
DWARFFormValue FormValue(Atom.second);
|
2019-08-06 18:49:40 +08:00
|
|
|
FormValue.extractValue(AccelSection, HashDataOffset, FormParams);
|
2017-06-30 04:13:05 +08:00
|
|
|
switch (Atom.first) {
|
|
|
|
case dwarf::DW_ATOM_die_offset:
|
|
|
|
DieOffset = *FormValue.getAsUnsignedConstant();
|
|
|
|
break;
|
2017-08-01 02:01:16 +08:00
|
|
|
case dwarf::DW_ATOM_die_tag:
|
|
|
|
DieTag = (dwarf::Tag)*FormValue.getAsUnsignedConstant();
|
|
|
|
break;
|
2017-06-30 04:13:05 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-08-01 02:01:16 +08:00
|
|
|
return {DieOffset, DieTag};
|
2017-06-30 04:13:05 +08:00
|
|
|
}
|
|
|
|
|
2018-01-29 19:33:17 +08:00
|
|
|
void AppleAcceleratorTable::Header::dump(ScopedPrinter &W) const {
|
|
|
|
DictScope HeaderScope(W, "Header");
|
|
|
|
W.printHex("Magic", Magic);
|
|
|
|
W.printHex("Version", Version);
|
|
|
|
W.printHex("Hash function", HashFunction);
|
|
|
|
W.printNumber("Bucket count", BucketCount);
|
|
|
|
W.printNumber("Hashes count", HashCount);
|
|
|
|
W.printNumber("HeaderData length", HeaderDataLength);
|
|
|
|
}
|
|
|
|
|
[DebugInfo/AccelTable] Fix inconsistency in getDIEOffset implementations
Summary:
Even though the getDIEOffset offset function was common for the two
accelerator table implementations, it was doing two different things:
for the Apple tables, it was returning the die offset relative to the
start of the section, whereas for DWARF v5 tables, it was relative to
the start of the CU.
I resolve this by renaming the function to getDIESectionOffset to make
it obvious what the function returns, and change the DWARF
implementation to return the section offset. I also keep the CU-relative
accessor, but only in the DWARF implementation (there is no way to get
this information for the Apple tables). This was not caught by existing
tests because the hand-written inputs also erroneously used section
offsets instead of CU-relative ones.
While looking at this, I noticed that the Apple implementation was not
fully correct either -- the header contains a DIEOffsetBase field, which
should be added to offsets encoded with the DW_FORM_ref*** family, but
this was not being used. This went unnoticed because all current writers
set this field to zero anyway. I fix this as well and add a hand-written
test which demonstrates the issue.
Reviewers: JDevlieghere, dblaikie
Subscribers: aprantl, llvm-commits
Differential Revision: https://reviews.llvm.org/D44202
llvm-svn: 327116
2018-03-09 19:58:59 +08:00
|
|
|
Optional<uint64_t> AppleAcceleratorTable::HeaderData::extractOffset(
|
|
|
|
Optional<DWARFFormValue> Value) const {
|
|
|
|
if (!Value)
|
|
|
|
return None;
|
|
|
|
|
|
|
|
switch (Value->getForm()) {
|
|
|
|
case dwarf::DW_FORM_ref1:
|
|
|
|
case dwarf::DW_FORM_ref2:
|
|
|
|
case dwarf::DW_FORM_ref4:
|
|
|
|
case dwarf::DW_FORM_ref8:
|
|
|
|
case dwarf::DW_FORM_ref_udata:
|
|
|
|
return Value->getRawUValue() + DIEOffsetBase;
|
|
|
|
default:
|
|
|
|
return Value->getAsSectionOffset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 19:33:17 +08:00
|
|
|
bool AppleAcceleratorTable::dumpName(ScopedPrinter &W,
|
|
|
|
SmallVectorImpl<DWARFFormValue> &AtomForms,
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t *DataOffset) const {
|
2018-03-14 17:39:54 +08:00
|
|
|
dwarf::FormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32};
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t NameOffset = *DataOffset;
|
2018-01-29 19:33:17 +08:00
|
|
|
if (!AccelSection.isValidOffsetForDataOfSize(*DataOffset, 4)) {
|
|
|
|
W.printString("Incorrectly terminated list.");
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t StringOffset = AccelSection.getRelocatedValue(4, DataOffset);
|
2018-01-29 19:33:17 +08:00
|
|
|
if (!StringOffset)
|
|
|
|
return false; // End of list
|
|
|
|
|
|
|
|
DictScope NameScope(W, ("Name@0x" + Twine::utohexstr(NameOffset)).str());
|
2019-08-06 18:49:40 +08:00
|
|
|
W.startLine() << format("String: 0x%08" PRIx64, StringOffset);
|
2018-01-29 19:33:17 +08:00
|
|
|
W.getOStream() << " \"" << StringSection.getCStr(&StringOffset) << "\"\n";
|
|
|
|
|
|
|
|
unsigned NumData = AccelSection.getU32(DataOffset);
|
|
|
|
for (unsigned Data = 0; Data < NumData; ++Data) {
|
|
|
|
ListScope DataScope(W, ("Data " + Twine(Data)).str());
|
|
|
|
unsigned i = 0;
|
|
|
|
for (auto &Atom : AtomForms) {
|
2018-07-14 01:21:51 +08:00
|
|
|
W.startLine() << format("Atom[%d]: ", i);
|
|
|
|
if (Atom.extractValue(AccelSection, DataOffset, FormParams)) {
|
2018-01-29 19:33:17 +08:00
|
|
|
Atom.dump(W.getOStream());
|
2018-07-14 01:21:51 +08:00
|
|
|
if (Optional<uint64_t> Val = Atom.getAsUnsignedConstant()) {
|
|
|
|
StringRef Str = dwarf::AtomValueString(HdrData.Atoms[i].first, *Val);
|
|
|
|
if (!Str.empty())
|
|
|
|
W.getOStream() << " (" << Str << ")";
|
|
|
|
}
|
|
|
|
} else
|
2018-01-29 19:33:17 +08:00
|
|
|
W.getOStream() << "Error extracting the value";
|
|
|
|
W.getOStream() << "\n";
|
2018-07-14 01:21:51 +08:00
|
|
|
i++;
|
2018-01-29 19:33:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true; // more entries follow
|
|
|
|
}
|
|
|
|
|
2018-01-22 21:17:23 +08:00
|
|
|
LLVM_DUMP_METHOD void AppleAcceleratorTable::dump(raw_ostream &OS) const {
|
2017-09-29 02:10:52 +08:00
|
|
|
if (!IsValid)
|
|
|
|
return;
|
|
|
|
|
2018-01-29 19:33:17 +08:00
|
|
|
ScopedPrinter W(OS);
|
|
|
|
|
|
|
|
Hdr.dump(W);
|
|
|
|
|
|
|
|
W.printNumber("DIE offset base", HdrData.DIEOffsetBase);
|
2018-01-29 19:53:46 +08:00
|
|
|
W.printNumber("Number of atoms", uint64_t(HdrData.Atoms.size()));
|
2014-11-21 00:21:11 +08:00
|
|
|
SmallVector<DWARFFormValue, 3> AtomForms;
|
2018-01-29 19:33:17 +08:00
|
|
|
{
|
|
|
|
ListScope AtomsScope(W, "Atoms");
|
|
|
|
unsigned i = 0;
|
|
|
|
for (const auto &Atom : HdrData.Atoms) {
|
|
|
|
DictScope AtomScope(W, ("Atom " + Twine(i++)).str());
|
|
|
|
W.startLine() << "Type: " << formatAtom(Atom.first) << '\n';
|
[dwarf] Unify unknown dwarf enum formatting code
Summary:
We have had at least three pieces of code (in DWARFAbbreviationDeclaration,
DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for
dumping unknown dwarf enum values. While not terrible, they are a bit
distracting and enable small differences to creep in (Unknown_ffff vs.
Unknown_0xffff). I ended up needing to add a fourth place
(DWARFVerifier), so it seems it would be a good time to centralize.
This patch creates an alternative to the XXXString dumping functions in
the BinaryFormat library, which formats an unknown value as
DW_TYPE_unknown_1234, instead of just an empty string. It is based on
the formatv function, as that allows us to avoid materializing the
string for unknown values (and because this way I don't have to invent a
name for the new functions :P).
In this patch I add formatters for dwarf attributes, forms, tags, and
index attributes as these are the ones in use currently, but adding
other enums is straight-forward.
Reviewers: dblaikie, JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44570
llvm-svn: 328090
2018-03-21 19:46:37 +08:00
|
|
|
W.startLine() << "Form: " << formatv("{0}", Atom.second) << '\n';
|
2018-01-29 19:33:17 +08:00
|
|
|
AtomForms.push_back(DWARFFormValue(Atom.second));
|
|
|
|
}
|
2014-11-15 00:15:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now go through the actual tables and dump them.
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t Offset = sizeof(Hdr) + Hdr.HeaderDataLength;
|
|
|
|
uint64_t HashesBase = Offset + Hdr.BucketCount * 4;
|
|
|
|
uint64_t OffsetsBase = HashesBase + Hdr.HashCount * 4;
|
2014-11-15 00:15:53 +08:00
|
|
|
|
2018-01-29 19:33:17 +08:00
|
|
|
for (unsigned Bucket = 0; Bucket < Hdr.BucketCount; ++Bucket) {
|
2014-11-15 00:15:53 +08:00
|
|
|
unsigned Index = AccelSection.getU32(&Offset);
|
|
|
|
|
2018-01-29 19:33:17 +08:00
|
|
|
ListScope BucketScope(W, ("Bucket " + Twine(Bucket)).str());
|
2014-11-15 00:15:53 +08:00
|
|
|
if (Index == UINT32_MAX) {
|
2018-01-29 19:33:17 +08:00
|
|
|
W.printString("EMPTY");
|
2014-11-15 00:15:53 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-01-29 19:33:17 +08:00
|
|
|
for (unsigned HashIdx = Index; HashIdx < Hdr.HashCount; ++HashIdx) {
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t HashOffset = HashesBase + HashIdx*4;
|
|
|
|
uint64_t OffsetsOffset = OffsetsBase + HashIdx*4;
|
2014-11-15 00:15:53 +08:00
|
|
|
uint32_t Hash = AccelSection.getU32(&HashOffset);
|
|
|
|
|
2018-01-29 19:33:17 +08:00
|
|
|
if (Hash % Hdr.BucketCount != Bucket)
|
2014-11-15 00:15:53 +08:00
|
|
|
break;
|
|
|
|
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t DataOffset = AccelSection.getU32(&OffsetsOffset);
|
2018-01-29 19:33:17 +08:00
|
|
|
ListScope HashScope(W, ("Hash 0x" + Twine::utohexstr(Hash)).str());
|
2014-11-15 00:15:53 +08:00
|
|
|
if (!AccelSection.isValidOffset(DataOffset)) {
|
2018-01-29 19:33:17 +08:00
|
|
|
W.printString("Invalid section offset");
|
2014-11-15 00:15:53 +08:00
|
|
|
continue;
|
|
|
|
}
|
2018-01-29 19:33:17 +08:00
|
|
|
while (dumpName(W, AtomForms, &DataOffset))
|
|
|
|
/*empty*/;
|
2014-11-15 00:15:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-29 02:10:52 +08:00
|
|
|
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
AppleAcceleratorTable::Entry::Entry(
|
|
|
|
const AppleAcceleratorTable::HeaderData &HdrData)
|
|
|
|
: HdrData(&HdrData) {
|
|
|
|
Values.reserve(HdrData.Atoms.size());
|
|
|
|
for (const auto &Atom : HdrData.Atoms)
|
|
|
|
Values.push_back(DWARFFormValue(Atom.second));
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppleAcceleratorTable::Entry::extract(
|
2019-08-06 18:49:40 +08:00
|
|
|
const AppleAcceleratorTable &AccelTable, uint64_t *Offset) {
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
|
2018-03-14 17:39:54 +08:00
|
|
|
dwarf::FormParams FormParams = {AccelTable.Hdr.Version, 0,
|
|
|
|
dwarf::DwarfFormat::DWARF32};
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
for (auto &Atom : Values)
|
|
|
|
Atom.extractValue(AccelTable.AccelSection, Offset, FormParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
Optional<DWARFFormValue>
|
|
|
|
AppleAcceleratorTable::Entry::lookup(HeaderData::AtomType Atom) const {
|
|
|
|
assert(HdrData && "Dereferencing end iterator?");
|
|
|
|
assert(HdrData->Atoms.size() == Values.size());
|
2020-01-02 00:23:21 +08:00
|
|
|
for (auto Tuple : zip_first(HdrData->Atoms, Values)) {
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
if (std::get<0>(Tuple).first == Atom)
|
|
|
|
return std::get<1>(Tuple);
|
|
|
|
}
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
[DebugInfo/AccelTable] Fix inconsistency in getDIEOffset implementations
Summary:
Even though the getDIEOffset offset function was common for the two
accelerator table implementations, it was doing two different things:
for the Apple tables, it was returning the die offset relative to the
start of the section, whereas for DWARF v5 tables, it was relative to
the start of the CU.
I resolve this by renaming the function to getDIESectionOffset to make
it obvious what the function returns, and change the DWARF
implementation to return the section offset. I also keep the CU-relative
accessor, but only in the DWARF implementation (there is no way to get
this information for the Apple tables). This was not caught by existing
tests because the hand-written inputs also erroneously used section
offsets instead of CU-relative ones.
While looking at this, I noticed that the Apple implementation was not
fully correct either -- the header contains a DIEOffsetBase field, which
should be added to offsets encoded with the DW_FORM_ref*** family, but
this was not being used. This went unnoticed because all current writers
set this field to zero anyway. I fix this as well and add a hand-written
test which demonstrates the issue.
Reviewers: JDevlieghere, dblaikie
Subscribers: aprantl, llvm-commits
Differential Revision: https://reviews.llvm.org/D44202
llvm-svn: 327116
2018-03-09 19:58:59 +08:00
|
|
|
Optional<uint64_t> AppleAcceleratorTable::Entry::getDIESectionOffset() const {
|
|
|
|
return HdrData->extractOffset(lookup(dwarf::DW_ATOM_die_offset));
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Optional<uint64_t> AppleAcceleratorTable::Entry::getCUOffset() const {
|
[DebugInfo/AccelTable] Fix inconsistency in getDIEOffset implementations
Summary:
Even though the getDIEOffset offset function was common for the two
accelerator table implementations, it was doing two different things:
for the Apple tables, it was returning the die offset relative to the
start of the section, whereas for DWARF v5 tables, it was relative to
the start of the CU.
I resolve this by renaming the function to getDIESectionOffset to make
it obvious what the function returns, and change the DWARF
implementation to return the section offset. I also keep the CU-relative
accessor, but only in the DWARF implementation (there is no way to get
this information for the Apple tables). This was not caught by existing
tests because the hand-written inputs also erroneously used section
offsets instead of CU-relative ones.
While looking at this, I noticed that the Apple implementation was not
fully correct either -- the header contains a DIEOffsetBase field, which
should be added to offsets encoded with the DW_FORM_ref*** family, but
this was not being used. This went unnoticed because all current writers
set this field to zero anyway. I fix this as well and add a hand-written
test which demonstrates the issue.
Reviewers: JDevlieghere, dblaikie
Subscribers: aprantl, llvm-commits
Differential Revision: https://reviews.llvm.org/D44202
llvm-svn: 327116
2018-03-09 19:58:59 +08:00
|
|
|
return HdrData->extractOffset(lookup(dwarf::DW_ATOM_cu_offset));
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Optional<dwarf::Tag> AppleAcceleratorTable::Entry::getTag() const {
|
|
|
|
Optional<DWARFFormValue> Tag = lookup(dwarf::DW_ATOM_die_tag);
|
|
|
|
if (!Tag)
|
|
|
|
return None;
|
|
|
|
if (Optional<uint64_t> Value = Tag->getAsUnsignedConstant())
|
|
|
|
return dwarf::Tag(*Value);
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
2018-01-22 21:17:23 +08:00
|
|
|
AppleAcceleratorTable::ValueIterator::ValueIterator(
|
2019-08-06 18:49:40 +08:00
|
|
|
const AppleAcceleratorTable &AccelTable, uint64_t Offset)
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
: AccelTable(&AccelTable), Current(AccelTable.HdrData), DataOffset(Offset) {
|
2017-09-29 02:10:52 +08:00
|
|
|
if (!AccelTable.AccelSection.isValidOffsetForDataOfSize(DataOffset, 4))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Read the first entry.
|
|
|
|
NumData = AccelTable.AccelSection.getU32(&DataOffset);
|
|
|
|
Next();
|
|
|
|
}
|
|
|
|
|
2018-01-22 21:17:23 +08:00
|
|
|
void AppleAcceleratorTable::ValueIterator::Next() {
|
2017-09-29 02:10:52 +08:00
|
|
|
assert(NumData > 0 && "attempted to increment iterator past the end");
|
|
|
|
auto &AccelSection = AccelTable->AccelSection;
|
|
|
|
if (Data >= NumData ||
|
|
|
|
!AccelSection.isValidOffsetForDataOfSize(DataOffset, 4)) {
|
|
|
|
NumData = 0;
|
2018-05-31 16:47:00 +08:00
|
|
|
DataOffset = 0;
|
2017-09-29 02:10:52 +08:00
|
|
|
return;
|
|
|
|
}
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
Current.extract(*AccelTable, &DataOffset);
|
2017-09-29 02:10:52 +08:00
|
|
|
++Data;
|
|
|
|
}
|
|
|
|
|
2018-01-22 21:17:23 +08:00
|
|
|
iterator_range<AppleAcceleratorTable::ValueIterator>
|
|
|
|
AppleAcceleratorTable::equal_range(StringRef Key) const {
|
2017-09-29 02:10:52 +08:00
|
|
|
if (!IsValid)
|
|
|
|
return make_range(ValueIterator(), ValueIterator());
|
|
|
|
|
|
|
|
// Find the bucket.
|
2018-01-28 19:05:10 +08:00
|
|
|
unsigned HashValue = djbHash(Key);
|
2018-01-29 19:33:17 +08:00
|
|
|
unsigned Bucket = HashValue % Hdr.BucketCount;
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t BucketBase = sizeof(Hdr) + Hdr.HeaderDataLength;
|
|
|
|
uint64_t HashesBase = BucketBase + Hdr.BucketCount * 4;
|
|
|
|
uint64_t OffsetsBase = HashesBase + Hdr.HashCount * 4;
|
2017-09-29 02:10:52 +08:00
|
|
|
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t BucketOffset = BucketBase + Bucket * 4;
|
2017-09-29 02:10:52 +08:00
|
|
|
unsigned Index = AccelSection.getU32(&BucketOffset);
|
|
|
|
|
|
|
|
// Search through all hashes in the bucket.
|
2018-01-29 19:33:17 +08:00
|
|
|
for (unsigned HashIdx = Index; HashIdx < Hdr.HashCount; ++HashIdx) {
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t HashOffset = HashesBase + HashIdx * 4;
|
|
|
|
uint64_t OffsetsOffset = OffsetsBase + HashIdx * 4;
|
2017-09-29 02:10:52 +08:00
|
|
|
uint32_t Hash = AccelSection.getU32(&HashOffset);
|
|
|
|
|
2018-01-29 19:33:17 +08:00
|
|
|
if (Hash % Hdr.BucketCount != Bucket)
|
2017-09-29 02:10:52 +08:00
|
|
|
// We are already in the next bucket.
|
|
|
|
break;
|
|
|
|
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t DataOffset = AccelSection.getU32(&OffsetsOffset);
|
|
|
|
uint64_t StringOffset = AccelSection.getRelocatedValue(4, &DataOffset);
|
2017-09-29 02:10:52 +08:00
|
|
|
if (!StringOffset)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Finally, compare the key.
|
|
|
|
if (Key == StringSection.getCStr(&StringOffset))
|
|
|
|
return make_range({*this, DataOffset}, ValueIterator());
|
|
|
|
}
|
|
|
|
return make_range(ValueIterator(), ValueIterator());
|
|
|
|
}
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
|
|
|
|
void DWARFDebugNames::Header::dump(ScopedPrinter &W) const {
|
|
|
|
DictScope HeaderScope(W, "Header");
|
|
|
|
W.printHex("Length", UnitLength);
|
2020-06-02 13:31:02 +08:00
|
|
|
W.printString("Format", dwarf::FormatString(Format));
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
W.printNumber("Version", Version);
|
|
|
|
W.printNumber("CU count", CompUnitCount);
|
|
|
|
W.printNumber("Local TU count", LocalTypeUnitCount);
|
|
|
|
W.printNumber("Foreign TU count", ForeignTypeUnitCount);
|
|
|
|
W.printNumber("Bucket count", BucketCount);
|
|
|
|
W.printNumber("Name count", NameCount);
|
|
|
|
W.printHex("Abbreviations table size", AbbrevTableSize);
|
|
|
|
W.startLine() << "Augmentation: '" << AugmentationString << "'\n";
|
|
|
|
}
|
|
|
|
|
2019-04-17 17:11:08 +08:00
|
|
|
Error DWARFDebugNames::Header::extract(const DWARFDataExtractor &AS,
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t *Offset) {
|
2020-02-25 22:40:49 +08:00
|
|
|
auto HeaderError = [Offset = *Offset](Error E) {
|
2020-01-15 11:20:58 +08:00
|
|
|
return createStringError(errc::illegal_byte_sequence,
|
2020-02-25 22:40:49 +08:00
|
|
|
"parsing .debug_names header at 0x%" PRIx64 ": %s",
|
|
|
|
Offset, toString(std::move(E)).c_str());
|
|
|
|
};
|
|
|
|
|
|
|
|
DataExtractor::Cursor C(*Offset);
|
|
|
|
std::tie(UnitLength, Format) = AS.getInitialLength(C);
|
|
|
|
|
|
|
|
Version = AS.getU16(C);
|
|
|
|
AS.skip(C, 2); // padding
|
|
|
|
CompUnitCount = AS.getU32(C);
|
|
|
|
LocalTypeUnitCount = AS.getU32(C);
|
|
|
|
ForeignTypeUnitCount = AS.getU32(C);
|
|
|
|
BucketCount = AS.getU32(C);
|
|
|
|
NameCount = AS.getU32(C);
|
|
|
|
AbbrevTableSize = AS.getU32(C);
|
|
|
|
AugmentationStringSize = alignTo(AS.getU32(C), 4);
|
|
|
|
|
|
|
|
if (!C)
|
|
|
|
return HeaderError(C.takeError());
|
|
|
|
|
|
|
|
if (!AS.isValidOffsetForDataOfSize(C.tell(), AugmentationStringSize))
|
|
|
|
return HeaderError(createStringError(errc::illegal_byte_sequence,
|
|
|
|
"cannot read header augmentation"));
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
AugmentationString.resize(AugmentationStringSize);
|
2020-02-25 22:40:49 +08:00
|
|
|
AS.getU8(C, reinterpret_cast<uint8_t *>(AugmentationString.data()),
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
AugmentationStringSize);
|
2020-02-25 22:40:49 +08:00
|
|
|
*Offset = C.tell();
|
|
|
|
return C.takeError();
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugNames::Abbrev::dump(ScopedPrinter &W) const {
|
|
|
|
DictScope AbbrevScope(W, ("Abbreviation 0x" + Twine::utohexstr(Code)).str());
|
[dwarf] Unify unknown dwarf enum formatting code
Summary:
We have had at least three pieces of code (in DWARFAbbreviationDeclaration,
DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for
dumping unknown dwarf enum values. While not terrible, they are a bit
distracting and enable small differences to creep in (Unknown_ffff vs.
Unknown_0xffff). I ended up needing to add a fourth place
(DWARFVerifier), so it seems it would be a good time to centralize.
This patch creates an alternative to the XXXString dumping functions in
the BinaryFormat library, which formats an unknown value as
DW_TYPE_unknown_1234, instead of just an empty string. It is based on
the formatv function, as that allows us to avoid materializing the
string for unknown values (and because this way I don't have to invent a
name for the new functions :P).
In this patch I add formatters for dwarf attributes, forms, tags, and
index attributes as these are the ones in use currently, but adding
other enums is straight-forward.
Reviewers: dblaikie, JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44570
llvm-svn: 328090
2018-03-21 19:46:37 +08:00
|
|
|
W.startLine() << formatv("Tag: {0}\n", Tag);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
|
[dwarf] Unify unknown dwarf enum formatting code
Summary:
We have had at least three pieces of code (in DWARFAbbreviationDeclaration,
DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for
dumping unknown dwarf enum values. While not terrible, they are a bit
distracting and enable small differences to creep in (Unknown_ffff vs.
Unknown_0xffff). I ended up needing to add a fourth place
(DWARFVerifier), so it seems it would be a good time to centralize.
This patch creates an alternative to the XXXString dumping functions in
the BinaryFormat library, which formats an unknown value as
DW_TYPE_unknown_1234, instead of just an empty string. It is based on
the formatv function, as that allows us to avoid materializing the
string for unknown values (and because this way I don't have to invent a
name for the new functions :P).
In this patch I add formatters for dwarf attributes, forms, tags, and
index attributes as these are the ones in use currently, but adding
other enums is straight-forward.
Reviewers: dblaikie, JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44570
llvm-svn: 328090
2018-03-21 19:46:37 +08:00
|
|
|
for (const auto &Attr : Attributes)
|
|
|
|
W.startLine() << formatv("{0}: {1}\n", Attr.Index, Attr.Form);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr DWARFDebugNames::AttributeEncoding sentinelAttrEnc() {
|
|
|
|
return {dwarf::Index(0), dwarf::Form(0)};
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isSentinel(const DWARFDebugNames::AttributeEncoding &AE) {
|
|
|
|
return AE == sentinelAttrEnc();
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWARFDebugNames::Abbrev sentinelAbbrev() {
|
|
|
|
return DWARFDebugNames::Abbrev(0, dwarf::Tag(0), {});
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isSentinel(const DWARFDebugNames::Abbrev &Abbr) {
|
|
|
|
return Abbr.Code == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWARFDebugNames::Abbrev DWARFDebugNames::AbbrevMapInfo::getEmptyKey() {
|
|
|
|
return sentinelAbbrev();
|
|
|
|
}
|
|
|
|
|
|
|
|
DWARFDebugNames::Abbrev DWARFDebugNames::AbbrevMapInfo::getTombstoneKey() {
|
|
|
|
return DWARFDebugNames::Abbrev(~0, dwarf::Tag(0), {});
|
|
|
|
}
|
|
|
|
|
|
|
|
Expected<DWARFDebugNames::AttributeEncoding>
|
2019-08-06 18:49:40 +08:00
|
|
|
DWARFDebugNames::NameIndex::extractAttributeEncoding(uint64_t *Offset) {
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
if (*Offset >= EntriesBase) {
|
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained
duplicating code for creating StringError instances, like:
template <typename... Ts>
static Error createError(char const *Fmt, const Ts &... Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
}
Similar function was placed in Support lib in https://reviews.llvm.org/D49824
This revision makes DWARF classes use this function
instead of their local implementation of it.
Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D49964
llvm-svn: 340163
2018-08-20 17:59:08 +08:00
|
|
|
return createStringError(errc::illegal_byte_sequence,
|
|
|
|
"Incorrectly terminated abbreviation table.");
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Index = Section.AccelSection.getULEB128(Offset);
|
|
|
|
uint32_t Form = Section.AccelSection.getULEB128(Offset);
|
|
|
|
return AttributeEncoding(dwarf::Index(Index), dwarf::Form(Form));
|
|
|
|
}
|
|
|
|
|
|
|
|
Expected<std::vector<DWARFDebugNames::AttributeEncoding>>
|
2019-08-06 18:49:40 +08:00
|
|
|
DWARFDebugNames::NameIndex::extractAttributeEncodings(uint64_t *Offset) {
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
std::vector<AttributeEncoding> Result;
|
|
|
|
for (;;) {
|
|
|
|
auto AttrEncOr = extractAttributeEncoding(Offset);
|
|
|
|
if (!AttrEncOr)
|
|
|
|
return AttrEncOr.takeError();
|
|
|
|
if (isSentinel(*AttrEncOr))
|
2020-02-10 23:06:45 +08:00
|
|
|
return std::move(Result);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
|
|
|
|
Result.emplace_back(*AttrEncOr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Expected<DWARFDebugNames::Abbrev>
|
2019-08-06 18:49:40 +08:00
|
|
|
DWARFDebugNames::NameIndex::extractAbbrev(uint64_t *Offset) {
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
if (*Offset >= EntriesBase) {
|
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained
duplicating code for creating StringError instances, like:
template <typename... Ts>
static Error createError(char const *Fmt, const Ts &... Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
}
Similar function was placed in Support lib in https://reviews.llvm.org/D49824
This revision makes DWARF classes use this function
instead of their local implementation of it.
Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D49964
llvm-svn: 340163
2018-08-20 17:59:08 +08:00
|
|
|
return createStringError(errc::illegal_byte_sequence,
|
|
|
|
"Incorrectly terminated abbreviation table.");
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Code = Section.AccelSection.getULEB128(Offset);
|
|
|
|
if (Code == 0)
|
|
|
|
return sentinelAbbrev();
|
|
|
|
|
|
|
|
uint32_t Tag = Section.AccelSection.getULEB128(Offset);
|
|
|
|
auto AttrEncOr = extractAttributeEncodings(Offset);
|
|
|
|
if (!AttrEncOr)
|
|
|
|
return AttrEncOr.takeError();
|
|
|
|
return Abbrev(Code, dwarf::Tag(Tag), std::move(*AttrEncOr));
|
|
|
|
}
|
|
|
|
|
|
|
|
Error DWARFDebugNames::NameIndex::extract() {
|
|
|
|
const DWARFDataExtractor &AS = Section.AccelSection;
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t Offset = Base;
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
if (Error E = Hdr.extract(AS, &Offset))
|
|
|
|
return E;
|
|
|
|
|
2020-01-15 11:20:58 +08:00
|
|
|
const unsigned SectionOffsetSize = dwarf::getDwarfOffsetByteSize(Hdr.Format);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
CUsBase = Offset;
|
2020-01-15 11:20:58 +08:00
|
|
|
Offset += Hdr.CompUnitCount * SectionOffsetSize;
|
|
|
|
Offset += Hdr.LocalTypeUnitCount * SectionOffsetSize;
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
Offset += Hdr.ForeignTypeUnitCount * 8;
|
|
|
|
BucketsBase = Offset;
|
|
|
|
Offset += Hdr.BucketCount * 4;
|
|
|
|
HashesBase = Offset;
|
|
|
|
if (Hdr.BucketCount > 0)
|
|
|
|
Offset += Hdr.NameCount * 4;
|
|
|
|
StringOffsetsBase = Offset;
|
2020-01-15 11:20:58 +08:00
|
|
|
Offset += Hdr.NameCount * SectionOffsetSize;
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
EntryOffsetsBase = Offset;
|
2020-01-15 11:20:58 +08:00
|
|
|
Offset += Hdr.NameCount * SectionOffsetSize;
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
|
|
|
|
if (!AS.isValidOffsetForDataOfSize(Offset, Hdr.AbbrevTableSize))
|
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained
duplicating code for creating StringError instances, like:
template <typename... Ts>
static Error createError(char const *Fmt, const Ts &... Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
}
Similar function was placed in Support lib in https://reviews.llvm.org/D49824
This revision makes DWARF classes use this function
instead of their local implementation of it.
Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D49964
llvm-svn: 340163
2018-08-20 17:59:08 +08:00
|
|
|
return createStringError(errc::illegal_byte_sequence,
|
|
|
|
"Section too small: cannot read abbreviations.");
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
|
|
|
|
EntriesBase = Offset + Hdr.AbbrevTableSize;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
auto AbbrevOr = extractAbbrev(&Offset);
|
|
|
|
if (!AbbrevOr)
|
|
|
|
return AbbrevOr.takeError();
|
|
|
|
if (isSentinel(*AbbrevOr))
|
|
|
|
return Error::success();
|
|
|
|
|
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained
duplicating code for creating StringError instances, like:
template <typename... Ts>
static Error createError(char const *Fmt, const Ts &... Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
}
Similar function was placed in Support lib in https://reviews.llvm.org/D49824
This revision makes DWARF classes use this function
instead of their local implementation of it.
Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D49964
llvm-svn: 340163
2018-08-20 17:59:08 +08:00
|
|
|
if (!Abbrevs.insert(std::move(*AbbrevOr)).second)
|
|
|
|
return createStringError(errc::invalid_argument,
|
|
|
|
"Duplicate abbreviation code.");
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 17:11:08 +08:00
|
|
|
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
DWARFDebugNames::Entry::Entry(const NameIndex &NameIdx, const Abbrev &Abbr)
|
|
|
|
: NameIdx(&NameIdx), Abbr(&Abbr) {
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
// This merely creates form values. It is up to the caller
|
|
|
|
// (NameIndex::getEntry) to populate them.
|
|
|
|
Values.reserve(Abbr.Attributes.size());
|
|
|
|
for (const auto &Attr : Abbr.Attributes)
|
|
|
|
Values.emplace_back(Attr.Form);
|
|
|
|
}
|
|
|
|
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
Optional<DWARFFormValue>
|
|
|
|
DWARFDebugNames::Entry::lookup(dwarf::Index Index) const {
|
|
|
|
assert(Abbr->Attributes.size() == Values.size());
|
2020-01-02 00:23:21 +08:00
|
|
|
for (auto Tuple : zip_first(Abbr->Attributes, Values)) {
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
if (std::get<0>(Tuple).Index == Index)
|
|
|
|
return std::get<1>(Tuple);
|
|
|
|
}
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
[DebugInfo/AccelTable] Fix inconsistency in getDIEOffset implementations
Summary:
Even though the getDIEOffset offset function was common for the two
accelerator table implementations, it was doing two different things:
for the Apple tables, it was returning the die offset relative to the
start of the section, whereas for DWARF v5 tables, it was relative to
the start of the CU.
I resolve this by renaming the function to getDIESectionOffset to make
it obvious what the function returns, and change the DWARF
implementation to return the section offset. I also keep the CU-relative
accessor, but only in the DWARF implementation (there is no way to get
this information for the Apple tables). This was not caught by existing
tests because the hand-written inputs also erroneously used section
offsets instead of CU-relative ones.
While looking at this, I noticed that the Apple implementation was not
fully correct either -- the header contains a DIEOffsetBase field, which
should be added to offsets encoded with the DW_FORM_ref*** family, but
this was not being used. This went unnoticed because all current writers
set this field to zero anyway. I fix this as well and add a hand-written
test which demonstrates the issue.
Reviewers: JDevlieghere, dblaikie
Subscribers: aprantl, llvm-commits
Differential Revision: https://reviews.llvm.org/D44202
llvm-svn: 327116
2018-03-09 19:58:59 +08:00
|
|
|
Optional<uint64_t> DWARFDebugNames::Entry::getDIEUnitOffset() const {
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
if (Optional<DWARFFormValue> Off = lookup(dwarf::DW_IDX_die_offset))
|
2018-03-29 21:47:57 +08:00
|
|
|
return Off->getAsReferenceUVal();
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
Optional<uint64_t> DWARFDebugNames::Entry::getCUIndex() const {
|
|
|
|
if (Optional<DWARFFormValue> Off = lookup(dwarf::DW_IDX_compile_unit))
|
|
|
|
return Off->getAsUnsignedConstant();
|
[DebugInfo/AccelTable] Fix inconsistency in getDIEOffset implementations
Summary:
Even though the getDIEOffset offset function was common for the two
accelerator table implementations, it was doing two different things:
for the Apple tables, it was returning the die offset relative to the
start of the section, whereas for DWARF v5 tables, it was relative to
the start of the CU.
I resolve this by renaming the function to getDIESectionOffset to make
it obvious what the function returns, and change the DWARF
implementation to return the section offset. I also keep the CU-relative
accessor, but only in the DWARF implementation (there is no way to get
this information for the Apple tables). This was not caught by existing
tests because the hand-written inputs also erroneously used section
offsets instead of CU-relative ones.
While looking at this, I noticed that the Apple implementation was not
fully correct either -- the header contains a DIEOffsetBase field, which
should be added to offsets encoded with the DW_FORM_ref*** family, but
this was not being used. This went unnoticed because all current writers
set this field to zero anyway. I fix this as well and add a hand-written
test which demonstrates the issue.
Reviewers: JDevlieghere, dblaikie
Subscribers: aprantl, llvm-commits
Differential Revision: https://reviews.llvm.org/D44202
llvm-svn: 327116
2018-03-09 19:58:59 +08:00
|
|
|
// In a per-CU index, the entries without a DW_IDX_compile_unit attribute
|
|
|
|
// implicitly refer to the single CU.
|
|
|
|
if (NameIdx->getCUCount() == 1)
|
|
|
|
return 0;
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
Optional<uint64_t> DWARFDebugNames::Entry::getCUOffset() const {
|
|
|
|
Optional<uint64_t> Index = getCUIndex();
|
|
|
|
if (!Index || *Index >= NameIdx->getCUCount())
|
|
|
|
return None;
|
|
|
|
return NameIdx->getCUOffset(*Index);
|
|
|
|
}
|
|
|
|
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
void DWARFDebugNames::Entry::dump(ScopedPrinter &W) const {
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
W.printHex("Abbrev", Abbr->Code);
|
[dwarf] Unify unknown dwarf enum formatting code
Summary:
We have had at least three pieces of code (in DWARFAbbreviationDeclaration,
DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for
dumping unknown dwarf enum values. While not terrible, they are a bit
distracting and enable small differences to creep in (Unknown_ffff vs.
Unknown_0xffff). I ended up needing to add a fourth place
(DWARFVerifier), so it seems it would be a good time to centralize.
This patch creates an alternative to the XXXString dumping functions in
the BinaryFormat library, which formats an unknown value as
DW_TYPE_unknown_1234, instead of just an empty string. It is based on
the formatv function, as that allows us to avoid materializing the
string for unknown values (and because this way I don't have to invent a
name for the new functions :P).
In this patch I add formatters for dwarf attributes, forms, tags, and
index attributes as these are the ones in use currently, but adding
other enums is straight-forward.
Reviewers: dblaikie, JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44570
llvm-svn: 328090
2018-03-21 19:46:37 +08:00
|
|
|
W.startLine() << formatv("Tag: {0}\n", Abbr->Tag);
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
assert(Abbr->Attributes.size() == Values.size());
|
2020-01-02 00:23:21 +08:00
|
|
|
for (auto Tuple : zip_first(Abbr->Attributes, Values)) {
|
[dwarf] Unify unknown dwarf enum formatting code
Summary:
We have had at least three pieces of code (in DWARFAbbreviationDeclaration,
DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for
dumping unknown dwarf enum values. While not terrible, they are a bit
distracting and enable small differences to creep in (Unknown_ffff vs.
Unknown_0xffff). I ended up needing to add a fourth place
(DWARFVerifier), so it seems it would be a good time to centralize.
This patch creates an alternative to the XXXString dumping functions in
the BinaryFormat library, which formats an unknown value as
DW_TYPE_unknown_1234, instead of just an empty string. It is based on
the formatv function, as that allows us to avoid materializing the
string for unknown values (and because this way I don't have to invent a
name for the new functions :P).
In this patch I add formatters for dwarf attributes, forms, tags, and
index attributes as these are the ones in use currently, but adding
other enums is straight-forward.
Reviewers: dblaikie, JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44570
llvm-svn: 328090
2018-03-21 19:46:37 +08:00
|
|
|
W.startLine() << formatv("{0}: ", std::get<0>(Tuple).Index);
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
std::get<1>(Tuple).dump(W.getOStream());
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
W.getOStream() << '\n';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char DWARFDebugNames::SentinelError::ID;
|
|
|
|
std::error_code DWARFDebugNames::SentinelError::convertToErrorCode() const {
|
|
|
|
return inconvertibleErrorCode();
|
|
|
|
}
|
|
|
|
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t DWARFDebugNames::NameIndex::getCUOffset(uint32_t CU) const {
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
assert(CU < Hdr.CompUnitCount);
|
2020-01-15 11:20:58 +08:00
|
|
|
const unsigned SectionOffsetSize = dwarf::getDwarfOffsetByteSize(Hdr.Format);
|
|
|
|
uint64_t Offset = CUsBase + SectionOffsetSize * CU;
|
|
|
|
return Section.AccelSection.getRelocatedValue(SectionOffsetSize, &Offset);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t DWARFDebugNames::NameIndex::getLocalTUOffset(uint32_t TU) const {
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
assert(TU < Hdr.LocalTypeUnitCount);
|
2020-01-15 11:20:58 +08:00
|
|
|
const unsigned SectionOffsetSize = dwarf::getDwarfOffsetByteSize(Hdr.Format);
|
|
|
|
uint64_t Offset = CUsBase + SectionOffsetSize * (Hdr.CompUnitCount + TU);
|
|
|
|
return Section.AccelSection.getRelocatedValue(SectionOffsetSize, &Offset);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
uint64_t DWARFDebugNames::NameIndex::getForeignTUSignature(uint32_t TU) const {
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
assert(TU < Hdr.ForeignTypeUnitCount);
|
2020-01-15 11:20:58 +08:00
|
|
|
const unsigned SectionOffsetSize = dwarf::getDwarfOffsetByteSize(Hdr.Format);
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t Offset =
|
2020-01-15 11:20:58 +08:00
|
|
|
CUsBase +
|
|
|
|
SectionOffsetSize * (Hdr.CompUnitCount + Hdr.LocalTypeUnitCount) + 8 * TU;
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
return Section.AccelSection.getU64(&Offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
Expected<DWARFDebugNames::Entry>
|
2019-08-06 18:49:40 +08:00
|
|
|
DWARFDebugNames::NameIndex::getEntry(uint64_t *Offset) const {
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
const DWARFDataExtractor &AS = Section.AccelSection;
|
|
|
|
if (!AS.isValidOffset(*Offset))
|
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained
duplicating code for creating StringError instances, like:
template <typename... Ts>
static Error createError(char const *Fmt, const Ts &... Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
}
Similar function was placed in Support lib in https://reviews.llvm.org/D49824
This revision makes DWARF classes use this function
instead of their local implementation of it.
Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D49964
llvm-svn: 340163
2018-08-20 17:59:08 +08:00
|
|
|
return createStringError(errc::illegal_byte_sequence,
|
|
|
|
"Incorrectly terminated entry list.");
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
|
|
|
|
uint32_t AbbrevCode = AS.getULEB128(Offset);
|
|
|
|
if (AbbrevCode == 0)
|
|
|
|
return make_error<SentinelError>();
|
|
|
|
|
|
|
|
const auto AbbrevIt = Abbrevs.find_as(AbbrevCode);
|
|
|
|
if (AbbrevIt == Abbrevs.end())
|
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained
duplicating code for creating StringError instances, like:
template <typename... Ts>
static Error createError(char const *Fmt, const Ts &... Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
}
Similar function was placed in Support lib in https://reviews.llvm.org/D49824
This revision makes DWARF classes use this function
instead of their local implementation of it.
Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D49964
llvm-svn: 340163
2018-08-20 17:59:08 +08:00
|
|
|
return createStringError(errc::invalid_argument, "Invalid abbreviation.");
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
Entry E(*this, *AbbrevIt);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
|
2020-01-15 11:20:58 +08:00
|
|
|
dwarf::FormParams FormParams = {Hdr.Version, 0, Hdr.Format};
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
for (auto &Value : E.Values) {
|
|
|
|
if (!Value.extractValue(AS, Offset, FormParams))
|
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained
duplicating code for creating StringError instances, like:
template <typename... Ts>
static Error createError(char const *Fmt, const Ts &... Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
}
Similar function was placed in Support lib in https://reviews.llvm.org/D49824
This revision makes DWARF classes use this function
instead of their local implementation of it.
Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D49964
llvm-svn: 340163
2018-08-20 17:59:08 +08:00
|
|
|
return createStringError(errc::io_error,
|
|
|
|
"Error extracting index attribute values.");
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
2020-02-10 23:06:45 +08:00
|
|
|
return std::move(E);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DWARFDebugNames::NameTableEntry
|
|
|
|
DWARFDebugNames::NameIndex::getNameTableEntry(uint32_t Index) const {
|
|
|
|
assert(0 < Index && Index <= Hdr.NameCount);
|
2020-01-15 11:20:58 +08:00
|
|
|
const unsigned SectionOffsetSize = dwarf::getDwarfOffsetByteSize(Hdr.Format);
|
|
|
|
uint64_t StringOffsetOffset =
|
|
|
|
StringOffsetsBase + SectionOffsetSize * (Index - 1);
|
|
|
|
uint64_t EntryOffsetOffset =
|
|
|
|
EntryOffsetsBase + SectionOffsetSize * (Index - 1);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
const DWARFDataExtractor &AS = Section.AccelSection;
|
|
|
|
|
2020-01-15 11:20:58 +08:00
|
|
|
uint64_t StringOffset =
|
|
|
|
AS.getRelocatedValue(SectionOffsetSize, &StringOffsetOffset);
|
|
|
|
uint64_t EntryOffset = AS.getUnsigned(&EntryOffsetOffset, SectionOffsetSize);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
EntryOffset += EntriesBase;
|
2018-06-01 18:33:11 +08:00
|
|
|
return {Section.StringSection, Index, StringOffset, EntryOffset};
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
DWARFDebugNames::NameIndex::getBucketArrayEntry(uint32_t Bucket) const {
|
|
|
|
assert(Bucket < Hdr.BucketCount);
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t BucketOffset = BucketsBase + 4 * Bucket;
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
return Section.AccelSection.getU32(&BucketOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t DWARFDebugNames::NameIndex::getHashArrayEntry(uint32_t Index) const {
|
|
|
|
assert(0 < Index && Index <= Hdr.NameCount);
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t HashOffset = HashesBase + 4 * (Index - 1);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
return Section.AccelSection.getU32(&HashOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if we should continue scanning for entries, false if this is the
|
|
|
|
// last (sentinel) entry). In case of a parsing error we also return false, as
|
|
|
|
// it's not possible to recover this entry list (but the other lists may still
|
|
|
|
// parse OK).
|
|
|
|
bool DWARFDebugNames::NameIndex::dumpEntry(ScopedPrinter &W,
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t *Offset) const {
|
|
|
|
uint64_t EntryId = *Offset;
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
auto EntryOr = getEntry(Offset);
|
|
|
|
if (!EntryOr) {
|
|
|
|
handleAllErrors(EntryOr.takeError(), [](const SentinelError &) {},
|
|
|
|
[&W](const ErrorInfoBase &EI) { EI.log(W.startLine()); });
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
DictScope EntryScope(W, ("Entry @ 0x" + Twine::utohexstr(EntryId)).str());
|
|
|
|
EntryOr->dump(W);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-06-01 18:33:11 +08:00
|
|
|
void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W,
|
|
|
|
const NameTableEntry &NTE,
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
Optional<uint32_t> Hash) const {
|
2018-06-01 18:33:11 +08:00
|
|
|
DictScope NameScope(W, ("Name " + Twine(NTE.getIndex())).str());
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
if (Hash)
|
|
|
|
W.printHex("Hash", *Hash);
|
|
|
|
|
2019-08-06 18:49:40 +08:00
|
|
|
W.startLine() << format("String: 0x%08" PRIx64, NTE.getStringOffset());
|
2018-06-01 18:33:11 +08:00
|
|
|
W.getOStream() << " \"" << NTE.getString() << "\"\n";
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t EntryOffset = NTE.getEntryOffset();
|
2018-06-01 18:33:11 +08:00
|
|
|
while (dumpEntry(W, &EntryOffset))
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
/*empty*/;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugNames::NameIndex::dumpCUs(ScopedPrinter &W) const {
|
|
|
|
ListScope CUScope(W, "Compilation Unit offsets");
|
|
|
|
for (uint32_t CU = 0; CU < Hdr.CompUnitCount; ++CU)
|
2019-08-06 18:49:40 +08:00
|
|
|
W.startLine() << format("CU[%u]: 0x%08" PRIx64 "\n", CU, getCUOffset(CU));
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const {
|
|
|
|
if (Hdr.LocalTypeUnitCount == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ListScope TUScope(W, "Local Type Unit offsets");
|
|
|
|
for (uint32_t TU = 0; TU < Hdr.LocalTypeUnitCount; ++TU)
|
2019-08-06 18:49:40 +08:00
|
|
|
W.startLine() << format("LocalTU[%u]: 0x%08" PRIx64 "\n", TU,
|
|
|
|
getLocalTUOffset(TU));
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugNames::NameIndex::dumpForeignTUs(ScopedPrinter &W) const {
|
|
|
|
if (Hdr.ForeignTypeUnitCount == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ListScope TUScope(W, "Foreign Type Unit signatures");
|
|
|
|
for (uint32_t TU = 0; TU < Hdr.ForeignTypeUnitCount; ++TU) {
|
|
|
|
W.startLine() << format("ForeignTU[%u]: 0x%016" PRIx64 "\n", TU,
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
getForeignTUSignature(TU));
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugNames::NameIndex::dumpAbbreviations(ScopedPrinter &W) const {
|
|
|
|
ListScope AbbrevsScope(W, "Abbreviations");
|
|
|
|
for (const auto &Abbr : Abbrevs)
|
|
|
|
Abbr.dump(W);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugNames::NameIndex::dumpBucket(ScopedPrinter &W,
|
|
|
|
uint32_t Bucket) const {
|
|
|
|
ListScope BucketScope(W, ("Bucket " + Twine(Bucket)).str());
|
|
|
|
uint32_t Index = getBucketArrayEntry(Bucket);
|
|
|
|
if (Index == 0) {
|
|
|
|
W.printString("EMPTY");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Index > Hdr.NameCount) {
|
|
|
|
W.printString("Name index is invalid");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; Index <= Hdr.NameCount; ++Index) {
|
|
|
|
uint32_t Hash = getHashArrayEntry(Index);
|
|
|
|
if (Hash % Hdr.BucketCount != Bucket)
|
|
|
|
break;
|
|
|
|
|
2018-06-01 18:33:11 +08:00
|
|
|
dumpName(W, getNameTableEntry(Index), Hash);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LLVM_DUMP_METHOD void DWARFDebugNames::NameIndex::dump(ScopedPrinter &W) const {
|
|
|
|
DictScope UnitScope(W, ("Name Index @ 0x" + Twine::utohexstr(Base)).str());
|
|
|
|
Hdr.dump(W);
|
|
|
|
dumpCUs(W);
|
|
|
|
dumpLocalTUs(W);
|
|
|
|
dumpForeignTUs(W);
|
|
|
|
dumpAbbreviations(W);
|
|
|
|
|
|
|
|
if (Hdr.BucketCount > 0) {
|
|
|
|
for (uint32_t Bucket = 0; Bucket < Hdr.BucketCount; ++Bucket)
|
|
|
|
dumpBucket(W, Bucket);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
W.startLine() << "Hash table not present\n";
|
2018-06-01 18:33:11 +08:00
|
|
|
for (NameTableEntry NTE : *this)
|
|
|
|
dumpName(W, NTE, None);
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
}
|
|
|
|
|
2019-04-17 17:11:08 +08:00
|
|
|
Error DWARFDebugNames::extract() {
|
2019-08-06 18:49:40 +08:00
|
|
|
uint64_t Offset = 0;
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
while (AccelSection.isValidOffset(Offset)) {
|
|
|
|
NameIndex Next(*this, Offset);
|
2019-04-17 17:11:08 +08:00
|
|
|
if (Error E = Next.extract())
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
return E;
|
|
|
|
Offset = Next.getNextUnitOffset();
|
|
|
|
NameIndices.push_back(std::move(Next));
|
|
|
|
}
|
|
|
|
return Error::success();
|
|
|
|
}
|
|
|
|
|
2018-05-15 21:24:10 +08:00
|
|
|
iterator_range<DWARFDebugNames::ValueIterator>
|
|
|
|
DWARFDebugNames::NameIndex::equal_range(StringRef Key) const {
|
|
|
|
return make_range(ValueIterator(*this, Key), ValueIterator());
|
|
|
|
}
|
|
|
|
|
[DebugInfo] Basic .debug_names dumping support
Summary:
This commit renames DWARFAcceleratorTable to AppleAcceleratorTable to free up
the first name as an interface for the different accelerator tables.
Then I add a DWARFDebugNames class for the dwarf5 table.
Presently, the only common functionality of the two classes is the dump()
method, because this is the only method that was necessary to implement
dwarfdump -debug-names; and because the rest of the
AppleAcceleratorTable interface does not directly transfer to the dwarf5
tables (the main reason for that is that the present interface assumes
the tables are homogeneous, but the dwarf5 tables can have different
keys associated with each entry).
I expect to make the common interface richer as I add more functionality
to the new class (and invent a way to represent it in generic way).
In terms of sharing the implementation, I found the format of the two
tables sufficiently different to frustrate any attempts to have common
parsing or dumping code, so presently the implementations share just low
level code for formatting dwarf constants.
Reviewers: vleschuk, JDevlieghere, clayborg, aprantl, probinson, echristo, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42297
llvm-svn: 323638
2018-01-29 19:08:32 +08:00
|
|
|
LLVM_DUMP_METHOD void DWARFDebugNames::dump(raw_ostream &OS) const {
|
|
|
|
ScopedPrinter W(OS);
|
|
|
|
for (const NameIndex &NI : NameIndices)
|
|
|
|
NI.dump(W);
|
|
|
|
}
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
|
2019-08-06 18:49:40 +08:00
|
|
|
Optional<uint64_t>
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
DWARFDebugNames::ValueIterator::findEntryOffsetInCurrentIndex() {
|
|
|
|
const Header &Hdr = CurrentIndex->Hdr;
|
|
|
|
if (Hdr.BucketCount == 0) {
|
|
|
|
// No Hash Table, We need to search through all names in the Name Index.
|
2018-06-01 18:33:11 +08:00
|
|
|
for (NameTableEntry NTE : *CurrentIndex) {
|
|
|
|
if (NTE.getString() == Key)
|
|
|
|
return NTE.getEntryOffset();
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
}
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The Name Index has a Hash Table, so use that to speed up the search.
|
|
|
|
// Compute the Key Hash, if it has not been done already.
|
|
|
|
if (!Hash)
|
|
|
|
Hash = caseFoldingDjbHash(Key);
|
|
|
|
uint32_t Bucket = *Hash % Hdr.BucketCount;
|
|
|
|
uint32_t Index = CurrentIndex->getBucketArrayEntry(Bucket);
|
|
|
|
if (Index == 0)
|
|
|
|
return None; // Empty bucket
|
|
|
|
|
|
|
|
for (; Index <= Hdr.NameCount; ++Index) {
|
|
|
|
uint32_t Hash = CurrentIndex->getHashArrayEntry(Index);
|
|
|
|
if (Hash % Hdr.BucketCount != Bucket)
|
|
|
|
return None; // End of bucket
|
|
|
|
|
|
|
|
NameTableEntry NTE = CurrentIndex->getNameTableEntry(Index);
|
2018-06-01 18:33:11 +08:00
|
|
|
if (NTE.getString() == Key)
|
|
|
|
return NTE.getEntryOffset();
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
}
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DWARFDebugNames::ValueIterator::getEntryAtCurrentOffset() {
|
|
|
|
auto EntryOr = CurrentIndex->getEntry(&DataOffset);
|
|
|
|
if (!EntryOr) {
|
|
|
|
consumeError(EntryOr.takeError());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
CurrentEntry = std::move(*EntryOr);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DWARFDebugNames::ValueIterator::findInCurrentIndex() {
|
2019-08-06 18:49:40 +08:00
|
|
|
Optional<uint64_t> Offset = findEntryOffsetInCurrentIndex();
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
if (!Offset)
|
|
|
|
return false;
|
|
|
|
DataOffset = *Offset;
|
|
|
|
return getEntryAtCurrentOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugNames::ValueIterator::searchFromStartOfCurrentIndex() {
|
|
|
|
for (const NameIndex *End = CurrentIndex->Section.NameIndices.end();
|
|
|
|
CurrentIndex != End; ++CurrentIndex) {
|
|
|
|
if (findInCurrentIndex())
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugNames::ValueIterator::next() {
|
|
|
|
assert(CurrentIndex && "Incrementing an end() iterator?");
|
|
|
|
|
|
|
|
// First try the next entry in the current Index.
|
|
|
|
if (getEntryAtCurrentOffset())
|
|
|
|
return;
|
|
|
|
|
2018-05-31 16:47:00 +08:00
|
|
|
// If we're a local iterator or we have reached the last Index, we're done.
|
|
|
|
if (IsLocal || CurrentIndex == &CurrentIndex->Section.NameIndices.back()) {
|
2018-05-15 21:24:10 +08:00
|
|
|
setEnd();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, try the next index.
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
++CurrentIndex;
|
|
|
|
searchFromStartOfCurrentIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
DWARFDebugNames::ValueIterator::ValueIterator(const DWARFDebugNames &AccelTable,
|
|
|
|
StringRef Key)
|
2020-01-29 03:23:46 +08:00
|
|
|
: CurrentIndex(AccelTable.NameIndices.begin()), IsLocal(false),
|
|
|
|
Key(std::string(Key)) {
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
searchFromStartOfCurrentIndex();
|
|
|
|
}
|
|
|
|
|
2018-05-15 21:24:10 +08:00
|
|
|
DWARFDebugNames::ValueIterator::ValueIterator(
|
|
|
|
const DWARFDebugNames::NameIndex &NI, StringRef Key)
|
2020-01-29 03:23:46 +08:00
|
|
|
: CurrentIndex(&NI), IsLocal(true), Key(std::string(Key)) {
|
2018-05-15 21:24:10 +08:00
|
|
|
if (!findInCurrentIndex())
|
|
|
|
setEnd();
|
|
|
|
}
|
|
|
|
|
Implement equal_range for the DWARF v5 accelerator table
Summary:
This patch implements the name lookup functionality of the .debug_names
accelerator table and hooks it up to "llvm-dwarfdump -find". To make the
interface of the two kinds of accelerator tables more consistent, I've
created an abstract "DWARFAcceleratorTable::Entry" class, which provides
a consistent interface to access the common functionality of the table
entries (such as getting the die offset, die tag, etc.). I've also
modified the apple table to vend entries conforming to this interface.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: vleschuk, clayborg, echristo, llvm-commits
Differential Revision: https://reviews.llvm.org/D43067
llvm-svn: 326003
2018-02-24 08:35:21 +08:00
|
|
|
iterator_range<DWARFDebugNames::ValueIterator>
|
|
|
|
DWARFDebugNames::equal_range(StringRef Key) const {
|
|
|
|
if (NameIndices.empty())
|
|
|
|
return make_range(ValueIterator(), ValueIterator());
|
|
|
|
return make_range(ValueIterator(*this, Key), ValueIterator());
|
|
|
|
}
|
2018-05-15 21:24:10 +08:00
|
|
|
|
|
|
|
const DWARFDebugNames::NameIndex *
|
2019-08-06 18:49:40 +08:00
|
|
|
DWARFDebugNames::getCUNameIndex(uint64_t CUOffset) {
|
2018-05-15 21:24:10 +08:00
|
|
|
if (CUToNameIndex.size() == 0 && NameIndices.size() > 0) {
|
|
|
|
for (const auto &NI : *this) {
|
|
|
|
for (uint32_t CU = 0; CU < NI.getCUCount(); ++CU)
|
|
|
|
CUToNameIndex.try_emplace(NI.getCUOffset(CU), &NI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CUToNameIndex.lookup(CUOffset);
|
|
|
|
}
|