Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 15d5238

Browse files
committed
llvm-dwarfdump: support the --ignore-case option.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314723 91177308-0d34-0410-b5e6-96231b3b80d8 (cherry picked from commit 706e8dc)
1 parent 3d26096 commit 15d5238

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

test/tools/llvm-dwarfdump/X86/name.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ RUN: llvm-dwarfdump %S/../../dsymutil/Inputs/odr-anon-namespace/1.o \
3737
RUN: -name="(anonymous namespace)" \
3838
RUN: | FileCheck %s --check-prefix=EMPTY
3939

40+
Test the -ignore-case option.
41+
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
42+
RUN: | llvm-dwarfdump -name=Main - | FileCheck %s -check-prefix=EMPTY
43+
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
44+
RUN: | llvm-dwarfdump -name=Main -i - | FileCheck %s
45+
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
46+
RUN: | llvm-dwarfdump -name=MAIN -ignore-case - | FileCheck %s

test/tools/llvm-dwarfdump/cmdline.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ HELP: -debug-info - Dump the .debug_info section
77
HELP: -eh-frame
88
HELP: Specific Options
99
HELP: -find
10+
HELP: -ignore-case
1011
HELP: -name
1112
HELP: -recurse-depth=<N>
1213
HELP: -show-children

tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ static list<std::string>
143143
"-name option can be used instead."),
144144
value_desc("name"), cat(DwarfDumpCategory));
145145
static alias FindAlias("f", desc("Alias for -find"), aliasopt(Find));
146+
static opt<bool>
147+
IgnoreCase("ignore-case",
148+
desc("Ignore case distinctions in when searching by name."),
149+
value_desc("i"), cat(DwarfDumpCategory));
150+
static alias IgnoreCaseAlias("i", desc("Alias for -ignore-case"),
151+
aliasopt(IgnoreCase));
146152
static list<std::string>
147153
Name("name",
148154
desc("Find and print all debug info entries whose name (DW_AT_name "
@@ -265,8 +271,11 @@ static void filterByName(const StringSet<> &Names,
265271
for (const auto &CU : CUs)
266272
for (const auto &Entry : CU->dies()) {
267273
DWARFDie Die = {CU.get(), &Entry};
268-
if (Names.count(Die.getName(DINameKind::ShortName)))
269-
Die.dump(OS, 0, getDumpOpts());
274+
if (const char *NamePtr = Die.getName(DINameKind::ShortName)) {
275+
std::string Name = IgnoreCase ? StringRef(NamePtr).lower() : NamePtr;
276+
if (Names.count(Name))
277+
Die.dump(OS, 0, getDumpOpts());
278+
}
270279
}
271280
}
272281

@@ -283,7 +292,7 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename,
283292
if (!Name.empty()) {
284293
StringSet<> Names;
285294
for (auto name : Name)
286-
Names.insert(name);
295+
Names.insert(IgnoreCase ? StringRef(name).lower() : name);
287296

288297
filterByName(Names, DICtx.compile_units(), OS);
289298
filterByName(Names, DICtx.dwo_compile_units(), OS);

0 commit comments

Comments
 (0)