diff --git a/llvm/test/tools/llvm-xray/AArch64/extract-instrmap.test b/llvm/test/tools/llvm-xray/AArch64/extract-instrmap.test --- a/llvm/test/tools/llvm-xray/AArch64/extract-instrmap.test +++ b/llvm/test/tools/llvm-xray/AArch64/extract-instrmap.test @@ -3,6 +3,7 @@ # RUN: yaml2obj %S/Inputs/elf64-pic.yaml -o %t.so # RUN: llvm-xray extract %t.so -s | FileCheck %s +# RUN: llvm-xray extract %t.so --no-demangle --demangle -s | FileCheck %s # CHECK: --- # CHECK-NEXT: - { id: 1, address: 0x420, function: 0x420, kind: function-enter, always-instrument: true, function-name: 'foo()' } @@ -14,6 +15,7 @@ # CHECK-NEXT: ... # RUN: llvm-xray extract -s --no-demangle %t.so | FileCheck --check-prefix=MANGLED %s +# RUN: llvm-xray extract -s --demangle --no-demangle %t.so | FileCheck --check-prefix=MANGLED %s # MANGLED: --- # MANGLED-NEXT: - { id: 1, address: 0x420, function: 0x420, kind: function-enter, always-instrument: true, function-name: _Z3foov } diff --git a/llvm/test/tools/llvm-xray/X86/convert-with-debug-syms.txt b/llvm/test/tools/llvm-xray/X86/convert-with-debug-syms.txt --- a/llvm/test/tools/llvm-xray/X86/convert-with-debug-syms.txt +++ b/llvm/test/tools/llvm-xray/X86/convert-with-debug-syms.txt @@ -1,4 +1,5 @@ -; RUN: llvm-xray convert -m %S/Inputs/elf64-sample-o2.bin -y %S/Inputs/naive-log-simple.xray -f yaml -o - 2>&1 | FileCheck %s +; RUN: llvm-xray convert -m %S/Inputs/elf64-sample-o2.bin -y %S/Inputs/naive-log-simple.xray -f yaml 2>&1 | FileCheck %s +; RUN: llvm-xray convert -m %S/Inputs/elf64-sample-o2.bin -y %S/Inputs/naive-log-simple.xray -f yaml --demangle 2>&1 | FileCheck %s ; CHECK: --- ; CHECK-NEXT: header: diff --git a/llvm/test/tools/llvm-xray/X86/extract-instrmap-pie.ll b/llvm/test/tools/llvm-xray/X86/extract-instrmap-pie.ll --- a/llvm/test/tools/llvm-xray/X86/extract-instrmap-pie.ll +++ b/llvm/test/tools/llvm-xray/X86/extract-instrmap-pie.ll @@ -4,8 +4,8 @@ ; RUN: llvm-xray extract %S/Inputs/elf64-pie.bin -s | FileCheck %s ; CHECK: --- -; CHECK-NEXT: - { id: 1, address: 0x299C0, function: 0x299C0, kind: function-enter, always-instrument: true, function-name: {{.*foo.*}} } -; CHECK-NEXT: - { id: 1, address: 0x299D0, function: 0x299C0, kind: function-exit, always-instrument: true, function-name: {{.*foo.*}} } -; CHECK-NEXT: - { id: 2, address: 0x299E0, function: 0x299E0, kind: function-enter, always-instrument: true, function-name: {{.*bar.*}} } -; CHECK-NEXT: - { id: 2, address: 0x299F6, function: 0x299E0, kind: function-exit, always-instrument: true, function-name: {{.*bar.*}} } +; CHECK-NEXT: - { id: 1, address: 0x299C0, function: 0x299C0, kind: function-enter, always-instrument: true, function-name: 'foo()' } +; CHECK-NEXT: - { id: 1, address: 0x299D0, function: 0x299C0, kind: function-exit, always-instrument: true, function-name: 'foo()' } +; CHECK-NEXT: - { id: 2, address: 0x299E0, function: 0x299E0, kind: function-enter, always-instrument: true, function-name: 'bar()' } +; CHECK-NEXT: - { id: 2, address: 0x299F6, function: 0x299E0, kind: function-exit, always-instrument: true, function-name: 'bar()' } ; CHECK-NEXT: ... diff --git a/llvm/tools/llvm-xray/xray-converter.cpp b/llvm/tools/llvm-xray/xray-converter.cpp --- a/llvm/tools/llvm-xray/xray-converter.cpp +++ b/llvm/tools/llvm-xray/xray-converter.cpp @@ -63,6 +63,10 @@ "when symbolizing function ids from the input log"), cl::init(false), cl::sub(Convert)); +static cl::opt Demangle("demangle", + cl::desc("demangle symbols (default)"), + cl::sub(Convert)); + static cl::opt ConvertInstrMap("instr_map", cl::desc("binary with the instrumentation map, or " @@ -379,7 +383,7 @@ const auto &FunctionAddresses = Map.getFunctionAddresses(); symbolize::LLVMSymbolizer::Options SymbolizerOpts; - if (NoDemangle) + if (Demangle.getPosition() < NoDemangle.getPosition()) SymbolizerOpts.Demangle = false; symbolize::LLVMSymbolizer Symbolizer(SymbolizerOpts); llvm::xray::FuncIdConversionHelper FuncIdHelper(ConvertInstrMap, Symbolizer, diff --git a/llvm/tools/llvm-xray/xray-extract.cpp b/llvm/tools/llvm-xray/xray-extract.cpp --- a/llvm/tools/llvm-xray/xray-extract.cpp +++ b/llvm/tools/llvm-xray/xray-extract.cpp @@ -45,11 +45,12 @@ cl::sub(Extract)); static cl::alias ExtractSymbolize2("s", cl::aliasopt(ExtractSymbolize), cl::desc("alias for -symbolize")); -static cl::opt ExtractNoDemangle("no-demangle", - cl::value_desc("no-demangle"), - cl::init(false), - cl::desc("don't demangle symbols"), - cl::sub(Extract)); +static cl::opt Demangle("demangle", + cl::desc("demangle symbols (default)"), + cl::sub(Extract)); +static cl::opt NoDemangle("no-demangle", + cl::desc("don't demangle symbols"), + cl::sub(Extract)); namespace { @@ -90,7 +91,7 @@ const auto &FunctionAddresses = InstrumentationMapOrError->getFunctionAddresses(); symbolize::LLVMSymbolizer::Options opts; - if (ExtractNoDemangle) + if (Demangle.getPosition() < NoDemangle.getPosition()) opts.Demangle = false; symbolize::LLVMSymbolizer Symbolizer(opts); llvm::xray::FuncIdConversionHelper FuncIdHelper(ExtractInput, Symbolizer,