forked from OSchip/llvm-project
llvm-dwarfdump: add a --show-parents options when selectively dumping DIEs.
llvm-svn: 313567
This commit is contained in:
parent
f077b5b885
commit
c2bc717028
|
@ -139,6 +139,7 @@ enum DIDumpType : unsigned {
|
||||||
struct DIDumpOptions {
|
struct DIDumpOptions {
|
||||||
unsigned DumpType = DIDT_All;
|
unsigned DumpType = DIDT_All;
|
||||||
bool ShowChildren = false;
|
bool ShowChildren = false;
|
||||||
|
bool ShowParents = false;
|
||||||
bool SummarizeTypes = false;
|
bool SummarizeTypes = false;
|
||||||
bool Verbose = false;
|
bool Verbose = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -367,6 +367,16 @@ void DWARFDie::getCallerFrame(uint32_t &CallFile, uint32_t &CallLine,
|
||||||
CallDiscriminator = toUnsigned(find(DW_AT_GNU_discriminator), 0);
|
CallDiscriminator = toUnsigned(find(DW_AT_GNU_discriminator), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper to dump a DIE with all of its parents, but no siblings.
|
||||||
|
static unsigned dumpParentChain(DWARFDie Die, raw_ostream &OS, unsigned Indent,
|
||||||
|
DIDumpOptions DumpOpts) {
|
||||||
|
if (!Die)
|
||||||
|
return Indent;
|
||||||
|
Indent = dumpParentChain(Die.getParent(), OS, Indent, DumpOpts);
|
||||||
|
Die.dump(OS, 0, Indent, DumpOpts);
|
||||||
|
return Indent + 2;
|
||||||
|
}
|
||||||
|
|
||||||
void DWARFDie::dump(raw_ostream &OS, unsigned RecurseDepth, unsigned Indent,
|
void DWARFDie::dump(raw_ostream &OS, unsigned RecurseDepth, unsigned Indent,
|
||||||
DIDumpOptions DumpOpts) const {
|
DIDumpOptions DumpOpts) const {
|
||||||
if (!isValid())
|
if (!isValid())
|
||||||
|
@ -374,7 +384,12 @@ void DWARFDie::dump(raw_ostream &OS, unsigned RecurseDepth, unsigned Indent,
|
||||||
DWARFDataExtractor debug_info_data = U->getDebugInfoExtractor();
|
DWARFDataExtractor debug_info_data = U->getDebugInfoExtractor();
|
||||||
const uint32_t Offset = getOffset();
|
const uint32_t Offset = getOffset();
|
||||||
uint32_t offset = Offset;
|
uint32_t offset = Offset;
|
||||||
RecurseDepth += DumpOpts.ShowChildren ? 1 : 0;
|
if (DumpOpts.ShowChildren)
|
||||||
|
RecurseDepth++;
|
||||||
|
if (DumpOpts.ShowParents) {
|
||||||
|
DumpOpts.ShowParents = false;
|
||||||
|
Indent = dumpParentChain(getParent(), OS, Indent, DumpOpts);
|
||||||
|
}
|
||||||
|
|
||||||
if (debug_info_data.isValidOffset(offset)) {
|
if (debug_info_data.isValidOffset(offset)) {
|
||||||
uint32_t abbrCode = debug_info_data.getULEB128(&offset);
|
uint32_t abbrCode = debug_info_data.getULEB128(&offset);
|
||||||
|
|
|
@ -20,3 +20,18 @@ RUN: | FileCheck %s --check-prefix=CHILDREN
|
||||||
CHILDREN: .debug_info contents:
|
CHILDREN: .debug_info contents:
|
||||||
CHILDREN: 0x0000000b: DW_TAG_compile_unit
|
CHILDREN: 0x0000000b: DW_TAG_compile_unit
|
||||||
CHILDREN: DW_TAG_subprogram
|
CHILDREN: DW_TAG_subprogram
|
||||||
|
|
||||||
|
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
|
||||||
|
RUN: | llvm-dwarfdump -debug-info=0x00000043 --show-parents - \
|
||||||
|
RUN: | FileCheck %s --check-prefix=PARENTS
|
||||||
|
|
||||||
|
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
|
||||||
|
RUN: | llvm-dwarfdump -debug-info=0x00000043 -p - \
|
||||||
|
RUN: | FileCheck %s --check-prefix=PARENTS
|
||||||
|
PARENTS: .debug_info contents:
|
||||||
|
PARENTS: 0x0000000b:{{ }}DW_TAG_compile_unit
|
||||||
|
PARENTS: DW_AT_name
|
||||||
|
PARENTS-NOT: {{:}}
|
||||||
|
PARENTS: 0x00000043:{{ }}DW_TAG_base_type
|
||||||
|
PARENTS: DW_AT_name
|
||||||
|
PARENTS-NOT: {{:}}
|
||||||
|
|
|
@ -131,9 +131,15 @@ static alias DumpUUIDAlias("u", desc("Alias for -uuid"), aliasopt(DumpUUID));
|
||||||
static opt<bool>
|
static opt<bool>
|
||||||
ShowChildren("show-children",
|
ShowChildren("show-children",
|
||||||
desc("Show a debug info entry's children when selectively "
|
desc("Show a debug info entry's children when selectively "
|
||||||
"printing with the =<Offset> option"));
|
"printing with the =<offset> option"));
|
||||||
static alias ShowChildrenAlias("c", desc("Alias for -show-children"),
|
static alias ShowChildrenAlias("c", desc("Alias for -show-children"),
|
||||||
aliasopt(ShowChildren));
|
aliasopt(ShowChildren));
|
||||||
|
static opt<bool>
|
||||||
|
ShowParents("show-parents",
|
||||||
|
desc("Show a debug info entry's parents when selectively "
|
||||||
|
"printing with the =<offset> option"));
|
||||||
|
static alias ShowParentsAlias("p", desc("Alias for -show-parents"),
|
||||||
|
aliasopt(ShowParents));
|
||||||
static opt<bool>
|
static opt<bool>
|
||||||
SummarizeTypes("summarize-types",
|
SummarizeTypes("summarize-types",
|
||||||
desc("Abbreviate the description of type unit entries"));
|
desc("Abbreviate the description of type unit entries"));
|
||||||
|
@ -162,6 +168,7 @@ static DIDumpOptions getDumpOpts() {
|
||||||
DIDumpOptions DumpOpts;
|
DIDumpOptions DumpOpts;
|
||||||
DumpOpts.DumpType = DumpType;
|
DumpOpts.DumpType = DumpType;
|
||||||
DumpOpts.ShowChildren = ShowChildren;
|
DumpOpts.ShowChildren = ShowChildren;
|
||||||
|
DumpOpts.ShowParents = ShowParents;
|
||||||
DumpOpts.SummarizeTypes = SummarizeTypes;
|
DumpOpts.SummarizeTypes = SummarizeTypes;
|
||||||
DumpOpts.Verbose = Verbose;
|
DumpOpts.Verbose = Verbose;
|
||||||
return DumpOpts;
|
return DumpOpts;
|
||||||
|
|
Loading…
Reference in New Issue