[llvm] 9b96b08 - llvm-xray {convert,extract}: Add --demangle
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 24 13:35:23 PDT 2021
Author: Fangrui Song
Date: 2021-08-24T13:35:19-07:00
New Revision: 9b96b0865df158a73767c3cfdd0380f86d5dde21
URL: https://github.com/llvm/llvm-project/commit/9b96b0865df158a73767c3cfdd0380f86d5dde21
DIFF: https://github.com/llvm/llvm-project/commit/9b96b0865df158a73767c3cfdd0380f86d5dde21.diff
LOG: llvm-xray {convert,extract}: Add --demangle
No demangling may be a better default in the future.
Add `--demangle` for migration convenience.
Reviewed By: Enna1
Differential Revision: https://reviews.llvm.org/D108100
Added:
Modified:
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
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-xray/AArch64/extract-instrmap.test b/llvm/test/tools/llvm-xray/AArch64/extract-instrmap.test
index c8905c30545a..947624cb4063 100644
--- 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
index fd6695a795f6..c30427f0a7f3 100644
--- 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
index 1bff8e252aa1..f1f89e3edc0e 100644
--- 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
index 2ab18b8b9ee3..82d0261ec4da 100644
--- a/llvm/tools/llvm-xray/xray-converter.cpp
+++ b/llvm/tools/llvm-xray/xray-converter.cpp
@@ -63,6 +63,10 @@ static cl::opt<bool>
"when symbolizing function ids from the input log"),
cl::init(false), cl::sub(Convert));
+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 "
@@ -379,7 +383,7 @@ static CommandRegistration Unused(&Convert, []() -> Error {
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
index a6ffacc6ab92..52767a00f615 100644
--- a/llvm/tools/llvm-xray/xray-extract.cpp
+++ b/llvm/tools/llvm-xray/xray-extract.cpp
@@ -45,11 +45,12 @@ 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));
+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 @@ static CommandRegistration Unused(&Extract, []() -> Error {
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,
More information about the llvm-commits
mailing list