From e8d28f3d7a73297b28bc60fe81ab38d116f3dc6c Mon Sep 17 00:00:00 2001 From: Hemant Kulkarni <khemant@codeaurora.org> Date: Mon, 12 Oct 2015 19:26:44 +0000 Subject: [PATCH] [llvm-symbolizer] Add -print-address option Differential Revision: http://reviews.llvm.org/D13518 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250086 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/CommandGuide/llvm-symbolizer.rst | 2 ++ test/tools/llvm-symbolizer/Inputs/addr.exe | Bin 0 -> 9749 bytes test/tools/llvm-symbolizer/Inputs/addr.inp | 1 + test/tools/llvm-symbolizer/sym.test | 19 +++++++++++++++++++ tools/llvm-symbolizer/llvm-symbolizer.cpp | 8 ++++++++ 5 files changed, 30 insertions(+) create mode 100755 test/tools/llvm-symbolizer/Inputs/addr.exe create mode 100644 test/tools/llvm-symbolizer/Inputs/addr.inp create mode 100644 test/tools/llvm-symbolizer/sym.test diff --git a/docs/CommandGuide/llvm-symbolizer.rst b/docs/CommandGuide/llvm-symbolizer.rst index 96720e633f2..9d6571d5c4c 100644 --- a/docs/CommandGuide/llvm-symbolizer.rst +++ b/docs/CommandGuide/llvm-symbolizer.rst @@ -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 ----------- diff --git a/test/tools/llvm-symbolizer/Inputs/addr.exe b/test/tools/llvm-symbolizer/Inputs/addr.exe new file mode 100755 index 0000000000000000000000000000000000000000..0d9e87dd7232196dac17fe42d9135f0b6b1d19bb GIT binary patch literal 9749 zcmeHNZERat89w(qPMoH5+@$N0wp+c;VePcsCT$k7RcmjWrnM*cV_gCat-EnzH!(PN zWM8+*7+X+RG^_h45<(MbQpK<G1Bo99RS0eFidK;JqvHom3`CgNNcSOvRz@_oh37r@ zyvg;o!$62%^ho!-=Y7umob#TKd(OGXequ1bU)MCjK^MCPX<c=ugq&E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q7`A6Xd9u2oWd>)V> zq8IQ``Fuad_z#fKMD_gn1@Kz!TCKfw9?|ei^MX1DarwWMcy&L#Ee%?${QSGLuQ3m0 z1FQXP1+LYYhueU+puHo0Q`W@G;XS~^5~+-aC0;#mM}UVgzTSB|4!ottdp#-f%CbrO z#wz$ZS$=iBKLj4GE=K$e_&U8^w0Yj6UlI;ac|GCt#_PbTALwUm3MCoiUK2RAYpbW6 z_m#bO9lNINz5RemCCfKe`FwBc2Od^+xkWp0^50ud$13)FWcfAL;ju&}<N8a27|YuQ zyNF+)$M9E#`v;C%@z{ey_@hEHl~0YQ3%F{r>`7}Zlgr}vpax`F$(%Kw$&Ds5R?^Pp z3s#~yEpUG^l}XvDq|tlN&K)SZhLJ@#DbBr!g}aXYjBsvJlEul%8BkoBMHes?rgW)f zS^JOn9~`s>5AB1)j`y6dAS8vg@1aBe2V(=Ua^=WBWeDp){P5oXxOI5{{s#w#tfBtB z@j)t1{x4&!P?UZOD>ih{TIrObg9FqhLy6H$O3=lP^A8STrQ|J+!*TxNVVdrLbX5J{ z!<+3c%r#K5g~>wBnn+}msMCraMwQ8Q)+!cKXyA&w)Ij)=1*jTm;Z8}V<prsA{|W1; b8r^|RqENulS{9nbT}f@_v94&T>^<>Mg4DJ( literal 0 HcmV?d00001 diff --git a/test/tools/llvm-symbolizer/Inputs/addr.inp b/test/tools/llvm-symbolizer/Inputs/addr.inp new file mode 100644 index 00000000000..4de096479da --- /dev/null +++ b/test/tools/llvm-symbolizer/Inputs/addr.inp @@ -0,0 +1 @@ +0x40054d diff --git a/test/tools/llvm-symbolizer/sym.test b/test/tools/llvm-symbolizer/sym.test new file mode 100644 index 00000000000..559124a44c0 --- /dev/null +++ b/test/tools/llvm-symbolizer/sym.test @@ -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 + diff --git a/tools/llvm-symbolizer/llvm-symbolizer.cpp b/tools/llvm-symbolizer/llvm-symbolizer.cpp index 9c9f3adbf60..b4485339b0d 100644 --- a/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -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(); } -- 2.40.0