[PATCH] D72804: [xray] add --symbolize-mangled cli opt for llvm-xray extract to output mangled names
Max Sherman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 13:02:13 PST 2020
johnislarry created this revision.
johnislarry added reviewers: dblaikie, dberris, phosek, smeenai.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Test Plan: ninja check-llvm
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72804
Files:
llvm/test/tools/llvm-xray/AArch64/extract-instrmap-aarch64-mangled.test
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,6 +45,13 @@
cl::sub(Extract));
static cl::alias ExtractSymbolize2("s", cl::aliasopt(ExtractSymbolize),
cl::desc("alias for -symbolize"));
+static cl::opt<bool> ExtractSymbolizeMangled(
+ "symbolize-mangled", cl::value_desc("symbolize-mangled"), cl::init(false),
+ cl::desc("symbolize with mangled symbols"), cl::sub(Extract));
+static cl::alias
+ ExtractSymbolizeMangled2("m", cl::aliasopt(ExtractSymbolize),
+ cl::desc("alias for --symbolize-mangled"),
+ cl::sub(Extract));
namespace {
@@ -60,7 +67,9 @@
return;
YAMLSleds.push_back({*FuncId, Sled.Address, Sled.Function, Sled.Kind,
Sled.AlwaysInstrument,
- ExtractSymbolize ? FH.SymbolOrNumber(*FuncId) : ""});
+ (ExtractSymbolize || ExtractSymbolizeMangled)
+ ? FH.SymbolOrNumber(*FuncId)
+ : ""});
}
Output Out(OS, nullptr, 0);
Out << YAMLSleds;
@@ -84,7 +93,11 @@
Twine("Cannot open file '") + ExtractOutput + "' for writing.", EC);
const auto &FunctionAddresses =
InstrumentationMapOrError->getFunctionAddresses();
- symbolize::LLVMSymbolizer Symbolizer;
+ symbolize::LLVMSymbolizer::Options opts;
+ if (ExtractSymbolizeMangled) {
+ opts.Demangle = false;
+ }
+ symbolize::LLVMSymbolizer Symbolizer(opts);
llvm::xray::FuncIdConversionHelper FuncIdHelper(ExtractInput, Symbolizer,
FunctionAddresses);
exportAsYAML(*InstrumentationMapOrError, OS, FuncIdHelper);
Index: llvm/test/tools/llvm-xray/AArch64/extract-instrmap-aarch64-mangled.test
===================================================================
--- /dev/null
+++ 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 --symbolize-mangled %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: ...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72804.238344.patch
Type: text/x-patch
Size: 3331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200115/8b229567/attachment.bin>
More information about the llvm-commits
mailing list