[PATCH] D60190: [llvm-symbolizer] Add `--output-style` switch.
Igor Kudrin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 01:40:51 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357675: [llvm-symbolizer] Add `--output-style` switch. (authored by ikudrin, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D60190?vs=193453&id=193672#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60190/new/
https://reviews.llvm.org/D60190
Files:
llvm/trunk/include/llvm/DebugInfo/Symbolize/DIPrinter.h
llvm/trunk/lib/DebugInfo/Symbolize/DIPrinter.cpp
llvm/trunk/test/tools/llvm-symbolizer/output-style.test
llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
Index: llvm/trunk/lib/DebugInfo/Symbolize/DIPrinter.cpp
===================================================================
--- llvm/trunk/lib/DebugInfo/Symbolize/DIPrinter.cpp
+++ llvm/trunk/lib/DebugInfo/Symbolize/DIPrinter.cpp
@@ -81,7 +81,10 @@
else if (Basenames)
Filename = llvm::sys::path::filename(Filename);
if (!Verbose) {
- OS << Filename << ":" << Info.Line << ":" << Info.Column << "\n";
+ OS << Filename << ":" << Info.Line;
+ if (Style == OutputStyle::LLVM)
+ OS << ":" << Info.Column;
+ OS << "\n";
printContext(Filename, Info.Line);
return;
}
Index: llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
===================================================================
--- llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -147,6 +147,14 @@
ClFallbackDebugPath("fallback-debug-path", cl::init(""),
cl::desc("Fallback path for debug binaries."));
+static cl::opt<DIPrinter::OutputStyle>
+ ClOutputStyle("output-style", cl::init(DIPrinter::OutputStyle::LLVM),
+ cl::desc("Specify print style"), cl::Hidden,
+ cl::values(clEnumValN(DIPrinter::OutputStyle::LLVM, "LLVM",
+ "LLVM default style"),
+ clEnumValN(DIPrinter::OutputStyle::GNU, "GNU",
+ "GNU addr2line style")));
+
template<typename T>
static bool error(Expected<T> &ResOrErr) {
if (ResOrErr)
@@ -256,7 +264,7 @@
DIPrinter Printer(outs(), ClPrintFunctions != FunctionNameKind::None,
ClPrettyPrint, ClPrintSourceContextLines, ClVerbose,
- ClBasenames);
+ ClBasenames, ClOutputStyle);
if (ClInputAddresses.empty()) {
const int kMaxInputStringLength = 1024;
Index: llvm/trunk/include/llvm/DebugInfo/Symbolize/DIPrinter.h
===================================================================
--- llvm/trunk/include/llvm/DebugInfo/Symbolize/DIPrinter.h
+++ llvm/trunk/include/llvm/DebugInfo/Symbolize/DIPrinter.h
@@ -24,12 +24,17 @@
namespace symbolize {
class DIPrinter {
+public:
+ enum class OutputStyle { LLVM, GNU };
+
+private:
raw_ostream &OS;
bool PrintFunctionNames;
bool PrintPretty;
int PrintSourceContext;
bool Verbose;
bool Basenames;
+ OutputStyle Style;
void print(const DILineInfo &Info, bool Inlined);
void printContext(const std::string &FileName, int64_t Line);
@@ -37,10 +42,11 @@
public:
DIPrinter(raw_ostream &OS, bool PrintFunctionNames = true,
bool PrintPretty = false, int PrintSourceContext = 0,
- bool Verbose = false, bool Basenames = false)
+ bool Verbose = false, bool Basenames = false,
+ OutputStyle Style = OutputStyle::LLVM)
: OS(OS), PrintFunctionNames(PrintFunctionNames),
PrintPretty(PrintPretty), PrintSourceContext(PrintSourceContext),
- Verbose(Verbose), Basenames(Basenames) {}
+ Verbose(Verbose), Basenames(Basenames), Style(Style) {}
DIPrinter &operator<<(const DILineInfo &Info);
DIPrinter &operator<<(const DIInliningInfo &Info);
Index: llvm/trunk/test/tools/llvm-symbolizer/output-style.test
===================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/output-style.test
+++ llvm/trunk/test/tools/llvm-symbolizer/output-style.test
@@ -0,0 +1,11 @@
+RUN: llvm-symbolizer -e %p/Inputs/addr.exe 0x40054d \
+RUN: | FileCheck %s --check-prefix=LLVM
+
+RUN: llvm-symbolizer --output-style=GNU -e %p/Inputs/addr.exe 0x40054d \
+RUN: | FileCheck %s --check-prefix=GNU
+
+RUN: llvm-symbolizer --output-style=LLVM -e %p/Inputs/addr.exe 0x40054d \
+RUN: | FileCheck %s --check-prefix=LLVM
+
+LLVM: {{^}}/tmp{{\\|/}}x.c:3:3{{$}}
+GNU: {{^}}/tmp{{\\|/}}x.c:3{{$}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60190.193672.patch
Type: text/x-patch
Size: 3898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190404/5d72284b/attachment.bin>
More information about the llvm-commits
mailing list