Index: docs/CommandGuide/llvm-symbolizer.rst =================================================================== --- docs/CommandGuide/llvm-symbolizer.rst +++ docs/CommandGuide/llvm-symbolizer.rst @@ -87,6 +87,10 @@ Print demangled function names. Defaults to true. +.. option:: -no-demangle + + Don't print demangled function names. + .. option:: -inlining If a source code location is in an inlined function, prints all the Index: test/DebugInfo/llvm-symbolizer.test =================================================================== --- test/DebugInfo/llvm-symbolizer.test +++ test/DebugInfo/llvm-symbolizer.test @@ -39,6 +39,12 @@ RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \ RUN: --default-arch=i386 < %t.input | FileCheck --check-prefix=CHECK --check-prefix=SPLIT --check-prefix=DWO %s +Ensure that --no-demangle flag exceeds --demangle + +RUN: cd %t +RUN: llvm-symbolizer --functions=linkage --inlining --demangle --no-demangle \ +RUN: --default-arch=i386 < %t.input | FileCheck --check-prefix=CHECK --check-prefix=SPLIT --check-prefix=DWO %s + Ensure we get the same results in the absence of gmlt-like data in the executable but the presence of a .dwo file RUN: echo "%p/Inputs/split-dwarf-test-nogmlt 0x400504" >> %t.input @@ -212,5 +218,7 @@ 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 +RUN: llvm-symbolizer --functions=short --no-demangle < %t.input7 \ +RUN: | FileCheck %s --check-prefix=SHORT_FUNCTION_NAME SHORT_FUNCTION_NAME-NOT: _Z1cv Index: tools/llvm-symbolizer/llvm-symbolizer.cpp =================================================================== --- tools/llvm-symbolizer/llvm-symbolizer.cpp +++ tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -55,12 +55,15 @@ ClPrintInlining("inlining", cl::init(true), cl::desc("Print all inlined frames for a given address")); -// -demangle, -C +// -demangle, -C, -no-demangle static cl::opt ClDemangle("demangle", cl::init(true), cl::desc("Demangle function names")); static cl::alias ClDemangleShort("C", cl::desc("Alias for -demangle"), cl::NotHidden, cl::aliasopt(ClDemangle)); +static cl::opt +ClNoDemangle("no-demangle", cl::init(false), + cl::desc("Don't demangle function names")); static cl::opt ClDefaultArch("default-arch", cl::init(""), cl::desc("Default architecture " @@ -201,10 +204,16 @@ InitLLVM X(argc, argv); llvm::sys::InitializeCOMRAII COM(llvm::sys::COMThreadingMode::MultiThreaded); - cl::ParseCommandLineOptions(argc, argv, "llvm-symbolizer\n"); - LLVMSymbolizer::Options Opts(ClPrintFunctions, ClUseSymbolTable, ClDemangle, - ClUseRelativeAddress, ClDefaultArch); + + // If both --demangle and --no-demangle are specified then pick + // the last one as demangle option. + if (ClNoDemangle.getPosition() > ClDemangle.getPosition()) + ClDemangle = !ClNoDemangle; + + LLVMSymbolizer::Options Opts(ClPrintFunctions, ClUseSymbolTable, + ClDemangle, ClUseRelativeAddress, + ClDefaultArch); for (const auto &hint : ClDsymHint) { if (sys::path::extension(hint) == ".dSYM") {