Index: docs/CommandGuide/llvm-symbolizer.rst =================================================================== --- docs/CommandGuide/llvm-symbolizer.rst +++ docs/CommandGuide/llvm-symbolizer.rst @@ -72,7 +72,7 @@ Path to object file to be symbolized. -.. option:: -functions=[none|short|linkage] +.. option:: -functions[=], -f Specify the way function names are printed (omit function name, print short function name, or print full linkage name, respectively). Index: test/DebugInfo/llvm-symbolizer.test =================================================================== --- test/DebugInfo/llvm-symbolizer.test +++ test/DebugInfo/llvm-symbolizer.test @@ -207,23 +207,22 @@ STRIPPED: global_func -RUN: echo "%p/Inputs/dwarfdump-test4.elf-x86-64 0x62c" > %t.input7 -RUN: llvm-symbolizer --functions=short --demangle=false < %t.input7 \ -RUN: | FileCheck %s --check-prefix=SHORT_FUNCTION_NAME -RUN: llvm-symbolizer --functions=short -C=false < %t.input7 \ -RUN: | FileCheck %s --check-prefix=SHORT_FUNCTION_NAME - -SHORT_FUNCTION_NAME-NOT: _Z1cv - ; Check that the last of --demangle and --no-demangle wins. +RUN: echo "%p/Inputs/dwarfdump-test4.elf-x86-64 0x62c" > %t.input7 RUN: llvm-symbolizer --demangle < %t.input7 \ RUN: | FileCheck %s --check-prefix=DEMANGLED_FUNCTION_NAME +RUN: llvm-symbolizer -C < %t.input7 \ +RUN: | FileCheck %s --check-prefix=DEMANGLED_FUNCTION_NAME RUN: llvm-symbolizer --no-demangle < %t.input7 \ RUN: | FileCheck %s --check-prefix=MANGLED_FUNCTION_NAME RUN: llvm-symbolizer --demangle --no-demangle < %t.input7 \ RUN: | FileCheck %s --check-prefix=MANGLED_FUNCTION_NAME +RUN: llvm-symbolizer -C --no-demangle < %t.input7 \ +RUN: | FileCheck %s --check-prefix=MANGLED_FUNCTION_NAME RUN: llvm-symbolizer --no-demangle --demangle < %t.input7 \ RUN: | FileCheck %s --check-prefix=DEMANGLED_FUNCTION_NAME +RUN: llvm-symbolizer --no-demangle -C < %t.input7 \ +RUN: | FileCheck %s --check-prefix=DEMANGLED_FUNCTION_NAME MANGLED_FUNCTION_NAME: _Z1cv DEMANGLED_FUNCTION_NAME: c() Index: test/tools/llvm-symbolizer/Inputs/functions.cpp =================================================================== --- test/tools/llvm-symbolizer/Inputs/functions.cpp +++ test/tools/llvm-symbolizer/Inputs/functions.cpp @@ -0,0 +1,2 @@ +// Build using clang -target x86_64-pc-linux -c -g +void foo(int bar) {} Index: test/tools/llvm-symbolizer/functions.test =================================================================== --- test/tools/llvm-symbolizer/functions.test +++ test/tools/llvm-symbolizer/functions.test @@ -0,0 +1,22 @@ +# REQUIRES: x86-registered-target + +# RUN: llvm-symbolizer 0 --obj=%p/Inputs/functions.o | FileCheck %s --check-prefix=LINKAGE +# RUN: llvm-symbolizer 0 --functions --obj=%p/Inputs/functions.o | FileCheck %s --check-prefix=LINKAGE +# RUN: llvm-symbolizer 0 --functions=linkage --obj=%p/Inputs/functions.o | FileCheck %s --check-prefix=LINKAGE +# RUN: llvm-symbolizer 0 --functions=short --obj=%p/Inputs/functions.o | FileCheck %s --check-prefix=SHORT +# RUN: llvm-symbolizer 0 --functions=none --obj=%p/Inputs/functions.o | FileCheck %s --check-prefix=NONE + +## Characterise behaviour for no '=' sign. llvm-symbolizer treats the next option as an +## input address, and just prints it. +# RUN: llvm-symbolizer 0 --functions none --obj=%p/Inputs/functions.o | FileCheck %s --check-prefixes=LINKAGE,ERR + +# LINKAGE: {{^}}foo(int){{$}} +# LINKAGE-NEXT: functions.cpp:2:0 + +# SHORT: {{^}}foo{{$}} +# SHORT-NEXT: functions.cpp:2:0 + +# NONE-NOT: foo +# NONE: functions.cpp:2:0 + +# ERR: none Index: tools/llvm-symbolizer/llvm-symbolizer.cpp =================================================================== --- tools/llvm-symbolizer/llvm-symbolizer.cpp +++ tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -38,12 +38,17 @@ static cl::opt ClPrintFunctions( "functions", cl::init(FunctionNameKind::LinkageName), - cl::desc("Print function name for a given address:"), + cl::desc("Print function name for a given address:"), cl::ValueOptional, cl::values(clEnumValN(FunctionNameKind::None, "none", "omit function name"), clEnumValN(FunctionNameKind::ShortName, "short", "print short function name"), clEnumValN(FunctionNameKind::LinkageName, "linkage", - "print function linkage name"))); + "print function linkage name (default)"), + // Sentinel value for unspecified value. + clEnumValN(FunctionNameKind::LinkageName, "", ""))); +static cl::alias ClPrintFunctionsShort("f", cl::desc("Alias for -functions"), + cl::NotHidden, + cl::aliasopt(ClPrintFunctions)); static cl::opt ClUseRelativeAddress("relative-address", cl::init(false),