Skip to content

Commit 8ef57f3

Browse files
johnislarrysmeenai
authored andcommitted
[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
1 parent 30a8865 commit 8ef57f3

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This test makes sure we can extract the instrumentation map from an
2+
XRay-instrumented PIE file.
3+
4+
RUN: yaml2obj %S/Inputs/elf64-pic.yaml -o %t.so
5+
RUN: llvm-xray extract -s --no-demangle %t.so | FileCheck %s
6+
7+
CHECK: ---
8+
CHECK-NEXT: - { id: 1, address: 0x0000000000000420, function: 0x0000000000000420, kind: function-enter, always-instrument: true, function-name: _Z3foov }
9+
CHECK-NEXT: - { id: 1, address: 0x0000000000000440, function: 0x0000000000000420, kind: function-exit, always-instrument: true, function-name: _Z3foov }
10+
CHECK-NEXT: - { id: 2, address: 0x0000000000000464, function: 0x0000000000000464, kind: function-enter, always-instrument: true, function-name: _Z3barv }
11+
CHECK-NEXT: - { id: 2, address: 0x0000000000000484, function: 0x0000000000000464, kind: function-exit, always-instrument: true, function-name: _Z3barv }
12+
CHECK-NEXT: - { id: 3, address: 0x00000000000004A8, function: 0x00000000000004A8, kind: function-enter, always-instrument: true, function-name: _Z3jarv }
13+
CHECK-NEXT: - { id: 3, address: 0x00000000000004C8, function: 0x00000000000004A8, kind: function-exit, always-instrument: true, function-name: _Z3jarv }
14+
CHECK-NEXT: ...

llvm/tools/llvm-xray/xray-extract.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ static cl::opt<bool> ExtractSymbolize("symbolize", cl::value_desc("symbolize"),
4545
cl::sub(Extract));
4646
static cl::alias ExtractSymbolize2("s", cl::aliasopt(ExtractSymbolize),
4747
cl::desc("alias for -symbolize"));
48+
static cl::opt<bool> ExtractNoDemangle("no-demangle",
49+
cl::value_desc("no-demangle"),
50+
cl::init(false),
51+
cl::desc("don't demangle symbols"),
52+
cl::sub(Extract));
4853

4954
namespace {
5055

@@ -84,7 +89,10 @@ static CommandRegistration Unused(&Extract, []() -> Error {
8489
Twine("Cannot open file '") + ExtractOutput + "' for writing.", EC);
8590
const auto &FunctionAddresses =
8691
InstrumentationMapOrError->getFunctionAddresses();
87-
symbolize::LLVMSymbolizer Symbolizer;
92+
symbolize::LLVMSymbolizer::Options opts;
93+
if (ExtractNoDemangle)
94+
opts.Demangle = false;
95+
symbolize::LLVMSymbolizer Symbolizer(opts);
8896
llvm::xray::FuncIdConversionHelper FuncIdHelper(ExtractInput, Symbolizer,
8997
FunctionAddresses);
9098
exportAsYAML(*InstrumentationMapOrError, OS, FuncIdHelper);

0 commit comments

Comments
 (0)