[PATCH] D108100: llvm-xray {convert,extract}: Add --demangle
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 15 20:57:30 PDT 2021
MaskRay created this revision.
MaskRay added reviewers: dberris, Enna1, smeenai.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
No demangling may be a better default in the future.
Add `--demangle` for migration convenience.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D108100
Files:
llvm/test/tools/llvm-xray/AArch64/extract-instrmap.test
llvm/test/tools/llvm-xray/X86/convert-with-debug-syms.txt
llvm/test/tools/llvm-xray/X86/extract-instrmap-pie.ll
llvm/tools/llvm-xray/xray-converter.cpp
llvm/tools/llvm-xray/xray-extract.cpp
Index: llvm/tools/llvm-xray/xray-extract.cpp
===================================================================
--- llvm/tools/llvm-xray/xray-extract.cpp
+++ 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<bool> ExtractNoDemangle("no-demangle",
- cl::value_desc("no-demangle"),
- cl::init(false),
- cl::desc("don't demangle symbols"),
- cl::sub(Extract));
+static cl::opt<bool> Demangle("demangle",
+ cl::desc("demangle symbols (default)"),
+ cl::sub(Extract));
+static cl::opt<bool> 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,
Index: llvm/tools/llvm-xray/xray-converter.cpp
===================================================================
--- llvm/tools/llvm-xray/xray-converter.cpp
+++ llvm/tools/llvm-xray/xray-converter.cpp
@@ -58,6 +58,10 @@
static cl::alias ConvertSymbolize2("y", cl::aliasopt(ConvertSymbolize),
cl::desc("Alias for -symbolize"));
+static cl::opt<bool> Demangle("demangle",
+ cl::desc("demangle symbols (default)"),
+ cl::sub(Convert));
+
static cl::opt<std::string>
ConvertInstrMap("instr_map",
cl::desc("binary with the instrumentation map, or "
Index: llvm/test/tools/llvm-xray/X86/extract-instrmap-pie.ll
===================================================================
--- llvm/test/tools/llvm-xray/X86/extract-instrmap-pie.ll
+++ 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: ...
Index: llvm/test/tools/llvm-xray/X86/convert-with-debug-syms.txt
===================================================================
--- llvm/test/tools/llvm-xray/X86/convert-with-debug-syms.txt
+++ 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 --demangle 2>&1 | FileCheck %s
; CHECK: ---
; CHECK-NEXT: header:
Index: llvm/test/tools/llvm-xray/AArch64/extract-instrmap.test
===================================================================
--- llvm/test/tools/llvm-xray/AArch64/extract-instrmap.test
+++ 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 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108100.366546.patch
Type: text/x-patch
Size: 5163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210816/6fbac125/attachment.bin>
More information about the llvm-commits
mailing list