[llvm] 0d673be - [llvm-objdump] Rename --disassemble-functions to --disassemble-symbols
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 9 08:26:03 PDT 2020
Author: Fangrui Song
Date: 2020-03-09T08:25:45-07:00
New Revision: 0d673be13a30eb39e5f0a315ca467f9fe81820f4
URL: https://github.com/llvm/llvm-project/commit/0d673be13a30eb39e5f0a315ca467f9fe81820f4
DIFF: https://github.com/llvm/llvm-project/commit/0d673be13a30eb39e5f0a315ca467f9fe81820f4.diff
LOG: [llvm-objdump] Rename --disassemble-functions to --disassemble-symbols
https://bugs.llvm.org/show_bug.cgi?id=41910
The feature can disassemble data and the new option name reflects its
more generic usage.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D75816
Added:
Modified:
llvm/docs/CommandGuide/llvm-objdump.rst
llvm/test/tools/llvm-objdump/X86/disassemble-functions-mangling.test
llvm/test/tools/llvm-objdump/X86/disassemble-functions.test
llvm/test/tools/llvm-objdump/X86/disassemble-implied-by-disassemble-functions.test
llvm/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test
llvm/tools/llvm-objdump/llvm-objdump.cpp
Removed:
################################################################################
diff --git a/llvm/docs/CommandGuide/llvm-objdump.rst b/llvm/docs/CommandGuide/llvm-objdump.rst
index 1b8273beb567..2730374d5810 100644
--- a/llvm/docs/CommandGuide/llvm-objdump.rst
+++ b/llvm/docs/CommandGuide/llvm-objdump.rst
@@ -33,7 +33,7 @@ combined with other commands:
Disassemble all sections found in the input files.
-.. option:: --disassemble-functions=<symbol1[,symbol2,...]>
+.. option:: --disassemble-symbols=<symbol1[,symbol2,...]>
Disassemble only the specified symbols. Takes demangled symbol names when
:option:`--demangle` is specified, otherwise takes mangled symbol names.
diff --git a/llvm/test/tools/llvm-objdump/X86/disassemble-functions-mangling.test b/llvm/test/tools/llvm-objdump/X86/disassemble-functions-mangling.test
index e85590671748..8269b4ce322c 100644
--- a/llvm/test/tools/llvm-objdump/X86/disassemble-functions-mangling.test
+++ b/llvm/test/tools/llvm-objdump/X86/disassemble-functions-mangling.test
@@ -1,29 +1,29 @@
-## Show that the --disassemble-functions switch takes demangled names when
+## Show that the --disassemble-symbols switch takes demangled names when
## --demangle is specified, otherwise the switch takes mangled names.
# RUN: yaml2obj %s -o %t.o
-## --disassemble-functions without --demangle.
-# RUN: llvm-objdump --disassemble-functions=_Z3foov %t.o | FileCheck %s --check-prefix=MANGLED
-# RUN: llvm-objdump --disassemble-functions='foo()' %t.o 2>&1 \
+## --disassemble-symbols without --demangle.
+# RUN: llvm-objdump --disassemble-symbols=_Z3foov %t.o | FileCheck %s --check-prefix=MANGLED
+# RUN: llvm-objdump --disassemble-symbols='foo()' %t.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=MANGLED-MISS
-# RUN: llvm-objdump --disassemble-functions=foo %t.o 2>&1 \
+# RUN: llvm-objdump --disassemble-symbols=foo %t.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=MANGLED-MISS
-# RUN: llvm-objdump --disassemble-functions='i,f' %t.o | FileCheck %s --check-prefix=NOMANGLE
+# RUN: llvm-objdump --disassemble-symbols='i,f' %t.o | FileCheck %s --check-prefix=NOMANGLE
-## --disassemble-functions with --demangle.
-# RUN: llvm-objdump -C --disassemble-functions='foo()' %t.o | FileCheck %s --check-prefix=DEMANGLED
-# RUN: llvm-objdump -C --disassemble-functions='_Z3foov' %t.o 2>&1 \
+## --disassemble-symbols with --demangle.
+# RUN: llvm-objdump -C --disassemble-symbols='foo()' %t.o | FileCheck %s --check-prefix=DEMANGLED
+# RUN: llvm-objdump -C --disassemble-symbols='_Z3foov' %t.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=DEMANGLED-MISS
-# RUN: llvm-objdump -C --disassemble-functions='i,f' %t.o | FileCheck %s --check-prefix=NOMANGLE
-# RUN: llvm-objdump -C --disassemble-functions='std::allocator<wchar_t>::allocator()' %t.o 2>&1 \
+# RUN: llvm-objdump -C --disassemble-symbols='i,f' %t.o | FileCheck %s --check-prefix=NOMANGLE
+# RUN: llvm-objdump -C --disassemble-symbols='std::allocator<wchar_t>::allocator()' %t.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=DEMANGLED-MULTI
# MANGLED: <_Z3foov>:
-# MANGLED-MISS: warning: '{{.*}}': failed to disassemble missing function foo
+# MANGLED-MISS: warning: '{{.*}}': failed to disassemble missing symbol foo
# DEMANGLED: <foo()>:
-# DEMANGLED-MISS: warning: '{{.*}}': failed to disassemble missing function _Z3foov
+# DEMANGLED-MISS: warning: '{{.*}}': failed to disassemble missing symbol _Z3foov
# NOMANGLE: <i>:
# NOMANGLE: <f>:
diff --git a/llvm/test/tools/llvm-objdump/X86/disassemble-functions.test b/llvm/test/tools/llvm-objdump/X86/disassemble-functions.test
index 85d75f42a08d..0644387cfe1b 100644
--- a/llvm/test/tools/llvm-objdump/X86/disassemble-functions.test
+++ b/llvm/test/tools/llvm-objdump/X86/disassemble-functions.test
@@ -2,24 +2,24 @@
## functions.
# RUN: yaml2obj -o %t.out %p/Inputs/simple-executable-x86_64.yaml
-# RUN: llvm-objdump -d %t.out --disassemble-functions=main \
+# RUN: llvm-objdump -d %t.out --disassemble-symbols=main \
# RUN: | FileCheck %s --check-prefix=MAIN --implicit-check-not=foo --implicit-check-not=somedata
-# RUN: llvm-objdump -d %t.out --disassemble-functions=main,foo \
+# RUN: llvm-objdump -d %t.out --disassemble-symbols=main,foo \
# RUN: | FileCheck %s --check-prefixes=MAIN,FOO --implicit-check-not=somedata
# FOO: <foo>:
# MAIN: <main>:
## Unknown symbol name.
-# RUN: llvm-objdump -d %t.out --disassemble-functions=baz \
+# RUN: llvm-objdump -d %t.out --disassemble-symbols=baz \
# RUN: | FileCheck %s --implicit-check-not=Disassembly
## Data symbol.
-# RUN: llvm-objdump -d %t.out --disassemble-functions=a \
+# RUN: llvm-objdump -d %t.out --disassemble-symbols=a \
# RUN: | FileCheck %s --implicit-check-not=Disassembly
## Data symbol + --disassemble-all.
-# RUN: llvm-objdump -D %t.out --disassemble-functions=a \
+# RUN: llvm-objdump -D %t.out --disassemble-symbols=a \
# RUN: | FileCheck %s --check-prefix=DATA
# DATA: a:
diff --git a/llvm/test/tools/llvm-objdump/X86/disassemble-implied-by-disassemble-functions.test b/llvm/test/tools/llvm-objdump/X86/disassemble-implied-by-disassemble-functions.test
index eceaf69dfa6b..710e4a50aa0b 100644
--- a/llvm/test/tools/llvm-objdump/X86/disassemble-implied-by-disassemble-functions.test
+++ b/llvm/test/tools/llvm-objdump/X86/disassemble-implied-by-disassemble-functions.test
@@ -1,5 +1,5 @@
-## Check that --disassemble-functions implies --disassemble.
-# RUN: yaml2obj %s | llvm-objdump - --disassemble-functions=main | FileCheck %s
+## Check that --disassemble-symbols implies --disassemble.
+# RUN: yaml2obj %s | llvm-objdump - --disassemble-symbols=main | FileCheck %s
--- !ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test b/llvm/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test
index b6656a69b49d..dfe7db4d3b24 100644
--- a/llvm/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test
+++ b/llvm/test/tools/llvm-objdump/X86/warn-missing-disasm-func.test
@@ -1,10 +1,10 @@
-## Warn if --disassemble-functions specifies an unknown symbol.
+## Warn if --disassemble-symbols specifies an unknown symbol.
# RUN: yaml2obj -o %t.o %s
# RUN: rm -f %t.a
# RUN: llvm-ar qc %t.a %t.o %t.o
-# RUN: llvm-objdump --disassemble-functions=foo %t.o 2>&1 | FileCheck %s
-# RUN: llvm-objdump --disassemble-functions=foo %t.a 2>&1 | FileCheck %s --check-prefix=MULTI
+# RUN: llvm-objdump --disassemble-symbols=foo %t.o 2>&1 | FileCheck %s
+# RUN: llvm-objdump --disassemble-symbols=foo %t.a 2>&1 | FileCheck %s --check-prefix=MULTI
--- !ELF
FileHeader:
@@ -13,9 +13,9 @@ FileHeader:
Type: ET_REL
Machine: EM_X86_64
-# CHECK: warning: {{.*}}: failed to disassemble missing function foo
+# CHECK: warning: {{.*}}: failed to disassemble missing symbol foo
# MULTI: file format elf64-x86-64
-# MULTI: warning: {{.*}}: failed to disassemble missing function foo
+# MULTI: warning: {{.*}}: failed to disassemble missing symbol foo
# MULTI: file format elf64-x86-64
-# MULTI: warning: {{.*}}: failed to disassemble missing function foo
+# MULTI: warning: {{.*}}: failed to disassemble missing symbol foo
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 1d0ec43bae03..fb3cdfbd4806 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -144,11 +144,11 @@ static cl::alias DisassembleAllShort("D",
cl::aliasopt(DisassembleAll));
static cl::list<std::string>
- DisassembleFunctions("disassemble-functions", cl::CommaSeparated,
- cl::desc("List of functions to disassemble. "
- "Accept demangled names when --demangle is "
- "specified, otherwise accept mangled names"),
- cl::cat(ObjdumpCat));
+ DisassembleSymbols("disassemble-symbols", cl::CommaSeparated,
+ cl::desc("List of symbols to disassemble. "
+ "Accept demangled names when --demangle is "
+ "specified, otherwise accept mangled names"),
+ cl::cat(ObjdumpCat));
static cl::opt<bool> DisassembleZeroes(
"disassemble-zeroes",
@@ -337,7 +337,7 @@ static cl::alias WideShort("w", cl::Grouping, cl::aliasopt(Wide));
static cl::extrahelp
HelpResponse("\nPass @FILE as argument to read options from FILE.\n");
-static StringSet<> DisasmFuncsSet;
+static StringSet<> DisasmSymbolSet;
StringSet<> FoundSectionSet;
static StringRef ToolName;
@@ -1237,7 +1237,7 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
// Sort all the symbols, this allows us to use a simple binary search to find
// a symbol near an address.
- StringSet<> FoundDisasmFuncsSet;
+ StringSet<> FoundDisasmSymbolSet;
for (std::pair<const SectionRef, SectionSymbolsTy> &SecSyms : AllSymbols)
array_pod_sort(SecSyms.second.begin(), SecSyms.second.end());
array_pod_sort(AbsoluteSymbols.begin(), AbsoluteSymbols.end());
@@ -1321,16 +1321,16 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
if (Demangle)
SymbolName = demangle(SymbolName);
- // Skip if --disassemble-functions is not empty and the symbol is not in
+ // Skip if --disassemble-symbols is not empty and the symbol is not in
// the list.
- if (!DisasmFuncsSet.empty() && !DisasmFuncsSet.count(SymbolName))
+ if (!DisasmSymbolSet.empty() && !DisasmSymbolSet.count(SymbolName))
continue;
uint64_t Start = Symbols[SI].Addr;
if (Start < SectionAddr || StopAddress <= Start)
continue;
else
- FoundDisasmFuncsSet.insert(SymbolName);
+ FoundDisasmSymbolSet.insert(SymbolName);
// The end is the section end, the beginning of the next symbol, or
// --stop-address.
@@ -1559,11 +1559,10 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
}
}
}
- StringSet<> MissingDisasmFuncsSet =
- set_
diff erence(DisasmFuncsSet, FoundDisasmFuncsSet);
- for (StringRef MissingDisasmFunc : MissingDisasmFuncsSet.keys())
- reportWarning("failed to disassemble missing function " + MissingDisasmFunc,
- FileName);
+ StringSet<> MissingDisasmSymbolSet =
+ set_
diff erence(DisasmSymbolSet, FoundDisasmSymbolSet);
+ for (StringRef Sym : MissingDisasmSymbolSet.keys())
+ reportWarning("failed to disassemble missing symbol " + Sym, FileName);
}
static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
@@ -2349,7 +2348,7 @@ int main(int argc, char **argv) {
SectionHeaders = SymbolTable = true;
if (DisassembleAll || PrintSource || PrintLines ||
- (!DisassembleFunctions.empty()))
+ !DisassembleSymbols.empty())
Disassemble = true;
if (!ArchiveHeaders && !Disassemble && DwarfDumpType == DIDT_Null &&
@@ -2365,8 +2364,7 @@ int main(int argc, char **argv) {
return 2;
}
- DisasmFuncsSet.insert(DisassembleFunctions.begin(),
- DisassembleFunctions.end());
+ DisasmSymbolSet.insert(DisassembleSymbols.begin(), DisassembleSymbols.end());
llvm::for_each(InputFilenames, dumpInput);
More information about the llvm-commits
mailing list