]> granicus.if.org Git - llvm/commitdiff
llvm-dwarfdump: support the --ignore-case option.
authorAdrian Prantl <aprantl@apple.com>
Mon, 2 Oct 2017 21:21:09 +0000 (21:21 +0000)
committerAdrian Prantl <aprantl@apple.com>
Mon, 2 Oct 2017 21:21:09 +0000 (21:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314723 91177308-0d34-0410-b5e6-96231b3b80d8

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

index d1cdc40639c20cf49ac51a228a2561944dae6f88..d757b7b53f5909ff7b43e971d2272b2b0d455b72 100644 (file)
@@ -37,3 +37,10 @@ RUN: llvm-dwarfdump %S/../../dsymutil/Inputs/odr-anon-namespace/1.o \
 RUN:    -name="(anonymous namespace)" \
 RUN:   | FileCheck %s --check-prefix=EMPTY
 
+Test the -ignore-case option.
+RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+RUN:   | llvm-dwarfdump -name=Main - | FileCheck %s -check-prefix=EMPTY
+RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+RUN:   | llvm-dwarfdump -name=Main -i - | FileCheck %s
+RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+RUN:   | llvm-dwarfdump -name=MAIN -ignore-case - | FileCheck %s
\ No newline at end of file
index 16b422a960b0874269e1e2542dc8af645df03252..f4c023af6ef93a6849d112571845287616609a3c 100644 (file)
@@ -7,6 +7,7 @@ HELP: -debug-info            - Dump the .debug_info section
 HELP: -eh-frame
 HELP: Specific Options
 HELP: -find
+HELP: -ignore-case
 HELP: -name
 HELP: -recurse-depth=<N>
 HELP: -show-children
index 28b4a136fb16d7f3c1d5d34eb64a7712d0d0044c..9abc92b7b83b6085da52d789228d5b0be3df70eb 100644 (file)
@@ -143,6 +143,12 @@ static list<std::string>
               "-name option can be used instead."),
          value_desc("name"), cat(DwarfDumpCategory));
 static alias FindAlias("f", desc("Alias for -find"), aliasopt(Find));
+static opt<bool>
+    IgnoreCase("ignore-case",
+               desc("Ignore case distinctions in when searching by name."),
+               value_desc("i"), cat(DwarfDumpCategory));
+static alias IgnoreCaseAlias("i", desc("Alias for -ignore-case"),
+                             aliasopt(IgnoreCase));
 static list<std::string>
     Name("name",
          desc("Find and print all debug info entries whose name (DW_AT_name "
@@ -265,8 +271,11 @@ static void filterByName(const StringSet<> &Names,
   for (const auto &CU : CUs)
     for (const auto &Entry : CU->dies()) {
       DWARFDie Die = {CU.get(), &Entry};
-      if (Names.count(Die.getName(DINameKind::ShortName)))
-        Die.dump(OS, 0, getDumpOpts());
+      if (const char *NamePtr = Die.getName(DINameKind::ShortName)) {
+        std::string Name = IgnoreCase ? StringRef(NamePtr).lower() : NamePtr;
+        if (Names.count(Name))
+          Die.dump(OS, 0, getDumpOpts());
+      }
     }
 }
 
@@ -283,7 +292,7 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename,
   if (!Name.empty()) {
     StringSet<> Names;
     for (auto name : Name)
-      Names.insert(name);
+      Names.insert(IgnoreCase ? StringRef(name).lower() : name);
 
     filterByName(Names, DICtx.compile_units(), OS);
     filterByName(Names, DICtx.dwo_compile_units(), OS);