[llvm] 8ef57f3 - [xray] add --no-demangle cli opt for llvm-xray extract to output mangled names
Shoaib Meenai via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 16:38:05 PST 2020
Author: Max Sherman
Date: 2020-01-16T16:37:00-08:00
New Revision: 8ef57f3e3f1b241e5b544a167ac64b35f7275759
URL: https://github.com/llvm/llvm-project/commit/8ef57f3e3f1b241e5b544a167ac64b35f7275759
DIFF: https://github.com/llvm/llvm-project/commit/8ef57f3e3f1b241e5b544a167ac64b35f7275759.diff
LOG: [xray] add --no-demangle cli opt for llvm-xray extract to output mangled names
This adds an additional cli flag for the llvm-xray extract tool. This
is useful if you're more interested in consuming the mangled symbol
name, instead of the default now which is demangled.
Differential Revision: https://reviews.llvm.org/D72804
Added:
llvm/test/tools/llvm-xray/AArch64/extract-instrmap-aarch64-mangled.test
Modified:
llvm/tools/llvm-xray/xray-extract.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-xray/AArch64/extract-instrmap-aarch64-mangled.test b/llvm/test/tools/llvm-xray/AArch64/extract-instrmap-aarch64-mangled.test
new file mode 100644
index 000000000000..5c8755164a5b
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/AArch64/extract-instrmap-aarch64-mangled.test
@@ -0,0 +1,14 @@
+This test makes sure we can extract the instrumentation map from an
+XRay-instrumented PIE file.
+
+RUN: yaml2obj %S/Inputs/elf64-pic.yaml -o %t.so
+RUN: llvm-xray extract -s --no-demangle %t.so | FileCheck %s
+
+CHECK: ---
+CHECK-NEXT: - { id: 1, address: 0x0000000000000420, function: 0x0000000000000420, kind: function-enter, always-instrument: true, function-name: _Z3foov }
+CHECK-NEXT: - { id: 1, address: 0x0000000000000440, function: 0x0000000000000420, kind: function-exit, always-instrument: true, function-name: _Z3foov }
+CHECK-NEXT: - { id: 2, address: 0x0000000000000464, function: 0x0000000000000464, kind: function-enter, always-instrument: true, function-name: _Z3barv }
+CHECK-NEXT: - { id: 2, address: 0x0000000000000484, function: 0x0000000000000464, kind: function-exit, always-instrument: true, function-name: _Z3barv }
+CHECK-NEXT: - { id: 3, address: 0x00000000000004A8, function: 0x00000000000004A8, kind: function-enter, always-instrument: true, function-name: _Z3jarv }
+CHECK-NEXT: - { id: 3, address: 0x00000000000004C8, function: 0x00000000000004A8, kind: function-exit, always-instrument: true, function-name: _Z3jarv }
+CHECK-NEXT: ...
diff --git a/llvm/tools/llvm-xray/xray-extract.cpp b/llvm/tools/llvm-xray/xray-extract.cpp
index af9255af21c3..6ea0f59e5eb9 100644
--- a/llvm/tools/llvm-xray/xray-extract.cpp
+++ b/llvm/tools/llvm-xray/xray-extract.cpp
@@ -45,6 +45,11 @@ static cl::opt<bool> ExtractSymbolize("symbolize", cl::value_desc("symbolize"),
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));
namespace {
@@ -84,7 +89,10 @@ static CommandRegistration Unused(&Extract, []() -> Error {
Twine("Cannot open file '") + ExtractOutput + "' for writing.", EC);
const auto &FunctionAddresses =
InstrumentationMapOrError->getFunctionAddresses();
- symbolize::LLVMSymbolizer Symbolizer;
+ symbolize::LLVMSymbolizer::Options opts;
+ if (ExtractNoDemangle)
+ opts.Demangle = false;
+ symbolize::LLVMSymbolizer Symbolizer(opts);
llvm::xray::FuncIdConversionHelper FuncIdHelper(ExtractInput, Symbolizer,
FunctionAddresses);
exportAsYAML(*InstrumentationMapOrError, OS, FuncIdHelper);
More information about the llvm-commits
mailing list