[llvm] r250086 - [llvm-symbolizer] Add -print-address option
Hemant Kulkarni via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 12 12:26:44 PDT 2015
Author: khemant
Date: Mon Oct 12 14:26:44 2015
New Revision: 250086
URL: http://llvm.org/viewvc/llvm-project?rev=250086&view=rev
Log:
[llvm-symbolizer] Add -print-address option
Differential Revision: http://reviews.llvm.org/D13518
Added:
llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.exe (with props)
llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.inp
llvm/trunk/test/tools/llvm-symbolizer/sym.test
Modified:
llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst
llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
Modified: llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst?rev=250086&r1=250085&r2=250086&view=diff
==============================================================================
--- llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst (original)
+++ llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst Mon Oct 12 14:26:44 2015
@@ -98,6 +98,8 @@ OPTIONS
location, look for the debug info at the .dSYM path provided via the
``-dsym-hint`` flag. This flag can be used multiple times.
+.. option:: -print-address
+ Print address before the source code location. Defaults to false.
EXIT STATUS
-----------
Added: llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.exe
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.exe?rev=250086&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.exe
------------------------------------------------------------------------------
svn:executable = *
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.exe
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.inp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.inp?rev=250086&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.inp (added)
+++ llvm/trunk/test/tools/llvm-symbolizer/Inputs/addr.inp Mon Oct 12 14:26:44 2015
@@ -0,0 +1 @@
+0x40054d
Added: llvm/trunk/test/tools/llvm-symbolizer/sym.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/sym.test?rev=250086&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/sym.test (added)
+++ llvm/trunk/test/tools/llvm-symbolizer/sym.test Mon Oct 12 14:26:44 2015
@@ -0,0 +1,19 @@
+#Source:
+##include <stdio.h>
+#static inline int inc (int *a) {
+# printf ("%d\n",(*a)++);
+# return (*a)++;
+#}
+#
+#int main () {
+# int x = 1;
+# return inc(&x);
+#}
+#Build as : clang -g -O2 addr.c
+
+RUN: llvm-symbolizer -inlining -print-address -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s
+
+#CHECK: 0x40054d
+#CHECK: main
+#CHECK: {{[/\]+}}tmp{{[/\]+}}x.c:9:0
+
Modified: llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp?rev=250086&r1=250085&r2=250086&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp Mon Oct 12 14:26:44 2015
@@ -73,6 +73,9 @@ static cl::list<std::string>
ClDsymHint("dsym-hint", cl::ZeroOrMore,
cl::desc("Path to .dSYM bundles to search for debug info for the "
"object files"));
+static cl::opt<bool>
+ ClPrintAddress("print-address", cl::init(false),
+ cl::desc("Show address before line information"));
static bool parseCommand(bool &IsData, std::string &ModuleName,
uint64_t &ModuleOffset) {
@@ -152,6 +155,11 @@ int main(int argc, char **argv) {
std::string Result =
IsData ? Symbolizer.symbolizeData(ModuleName, ModuleOffset)
: Symbolizer.symbolizeCode(ModuleName, ModuleOffset);
+ if (ClPrintAddress) {
+ outs() << "0x";
+ outs().write_hex(ModuleOffset);
+ outs() << "\n";
+ }
outs() << Result << "\n";
outs().flush();
}
More information about the llvm-commits
mailing list