llvm-symbolizer.rst 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. llvm-symbolizer - convert addresses into source code locations
  2. ==============================================================
  3. .. program:: llvm-symbolizer
  4. SYNOPSIS
  5. --------
  6. :program:`llvm-symbolizer` [*options*] [*addresses...*]
  7. DESCRIPTION
  8. -----------
  9. :program:`llvm-symbolizer` reads object file names and addresses from the
  10. command-line and prints corresponding source code locations to standard output.
  11. If no address is specified on the command-line, it reads the addresses from
  12. standard input. If no object file is specified on the command-line, but
  13. addresses are, or if at any time an input value is not recognized, the input is
  14. simply echoed to the output.
  15. A positional argument or standard input value can be preceded by "DATA" or
  16. "CODE" to indicate that the address should be symbolized as data or executable
  17. code respectively. If neither is specified, "CODE" is assumed. DATA is
  18. symbolized as address and symbol size rather than line number.
  19. Object files can be specified together with the addresses either on standard
  20. input or as positional arguments on the command-line, following any "DATA" or
  21. "CODE" prefix.
  22. EXAMPLES
  23. --------
  24. All of the following examples use the following two source files as input. They
  25. use a mixture of C-style and C++-style linkage to illustrate how these names are
  26. printed differently (see :option:`--demangle`).
  27. .. code-block:: c
  28. // test.h
  29. extern "C" inline int foz() {
  30. return 1234;
  31. }
  32. .. code-block:: c
  33. // test.cpp
  34. #include "test.h"
  35. int bar=42;
  36. int foo() {
  37. return bar;
  38. }
  39. int baz() {
  40. volatile int k = 42;
  41. return foz() + k;
  42. }
  43. int main() {
  44. return foo() + baz();
  45. }
  46. These files are built as follows:
  47. .. code-block:: console
  48. $ clang -g test.cpp -o test.elf
  49. $ clang -g -O2 test.cpp -o inlined.elf
  50. Example 1 - addresses and object on command-line:
  51. .. code-block:: console
  52. $ llvm-symbolizer --obj=test.elf 0x4004d0 0x400490
  53. foz
  54. /tmp/test.h:1:0
  55. baz()
  56. /tmp/test.cpp:11:0
  57. Example 2 - addresses on standard input:
  58. .. code-block:: console
  59. $ cat addr.txt
  60. 0x4004a0
  61. 0x400490
  62. 0x4004d0
  63. $ llvm-symbolizer --obj=test.elf < addr.txt
  64. main
  65. /tmp/test.cpp:15:0
  66. baz()
  67. /tmp/test.cpp:11:0
  68. foz
  69. /tmp/./test.h:1:0
  70. Example 3 - object specified with address:
  71. .. code-block:: console
  72. $ llvm-symbolizer "test.elf 0x400490" "inlined.elf 0x400480"
  73. baz()
  74. /tmp/test.cpp:11:0
  75. foo()
  76. /tmp/test.cpp:8:10
  77. $ cat addr2.txt
  78. test.elf 0x4004a0
  79. inlined.elf 0x400480
  80. $ llvm-symbolizer < addr2.txt
  81. main
  82. /tmp/test.cpp:15:0
  83. foo()
  84. /tmp/test.cpp:8:10
  85. Example 4 - CODE and DATA prefixes:
  86. .. code-block:: console
  87. $ llvm-symbolizer --obj=test.elf "CODE 0x400490" "DATA 0x601028"
  88. baz()
  89. /tmp/test.cpp:11:0
  90. bar
  91. 6295592 4
  92. $ cat addr3.txt
  93. CODE test.elf 0x4004a0
  94. DATA inlined.elf 0x601028
  95. $ llvm-symbolizer < addr3.txt
  96. main
  97. /tmp/test.cpp:15:0
  98. bar
  99. 6295592 4
  100. OPTIONS
  101. -------
  102. .. option:: --adjust-vma <offset>
  103. Add the specified offset to object file addresses when performing lookups.
  104. This can be used to perform lookups as if the object were relocated by the
  105. offset.
  106. .. option:: --basenames, -s
  107. Strip directories when printing the file path.
  108. .. _llvm-symbolizer-opt-C:
  109. .. option:: --demangle, -C
  110. Print demangled function names, if the names are mangled (e.g. the mangled
  111. name `_Z3bazv` becomes `baz()`, whilst the non-mangled name `foz` is printed
  112. as is). Defaults to true.
  113. .. option:: --dwp <path>
  114. Use the specified DWP file at ``<path>`` for any CUs that have split DWARF
  115. debug data.
  116. .. option:: --fallback-debug-path <path>
  117. When a separate file contains debug data, and is referenced by a GNU debug
  118. link section, use the specified path as a basis for locating the debug data if
  119. it cannot be found relative to the object.
  120. .. _llvm-symbolizer-opt-f:
  121. .. option:: --functions [<none|short|linkage>], -f
  122. Specify the way function names are printed (omit function name, print short
  123. function name, or print full linkage name, respectively). Defaults to
  124. ``linkage``.
  125. .. option:: --help, -h
  126. Show help and usage for this command.
  127. .. option:: --help-list
  128. Show help and usage for this command without grouping the options into categories.
  129. .. _llvm-symbolizer-opt-i:
  130. .. option:: --inlining, --inlines, -i
  131. If a source code location is in an inlined function, prints all the inlined
  132. frames. Defaults to true.
  133. .. option:: --no-demangle
  134. Don't print demangled function names.
  135. .. option:: --obj <path>, --exe, -e
  136. Path to object file to be symbolized. If ``-`` is specified, read the object
  137. directly from the standard input stream.
  138. .. _llvm-symbolizer-opt-output-style:
  139. .. option:: --output-style <LLVM|GNU>
  140. Specify the preferred output style. Defaults to ``LLVM``. When the output
  141. style is set to ``GNU``, the tool follows the style of GNU's **addr2line**.
  142. The differences from the ``LLVM`` style are:
  143. * Does not print the column of a source code location.
  144. * Does not add an empty line after the report for an address.
  145. * Does not replace the name of an inlined function with the name of the
  146. topmost caller when inlined frames are not shown and :option:`--use-symbol-table`
  147. is on.
  148. .. code-block:: console
  149. $ llvm-symbolizer --obj=inlined.elf 0x4004be 0x400486 -p
  150. baz() at /tmp/test.cpp:11:18
  151. (inlined by) main at /tmp/test.cpp:15:0
  152. foo() at /tmp/test.cpp:6:3
  153. $ llvm-symbolizer --output-style=LLVM --obj=inlined.elf 0x4004be 0x400486 -p -i=0
  154. main at /tmp/test.cpp:11:18
  155. foo() at /tmp/test.cpp:6:3
  156. $ llvm-symbolizer --output-style=GNU --obj=inlined.elf 0x4004be 0x400486 -p -i=0
  157. baz() at /tmp/test.cpp:11
  158. foo() at /tmp/test.cpp:6
  159. .. option:: --pretty-print, -p
  160. Print human readable output. If :option:`--inlining` is specified, the
  161. enclosing scope is prefixed by (inlined by).
  162. .. code-block:: console
  163. $ llvm-symbolizer --obj=inlined.elf 0x4004be --inlining --pretty-print
  164. baz() at /tmp/test.cpp:11:18
  165. (inlined by) main at /tmp/test.cpp:15:0
  166. .. option:: --print-address, --addresses, -a
  167. Print address before the source code location. Defaults to false.
  168. .. code-block:: console
  169. $ llvm-symbolizer --obj=inlined.elf --print-address 0x4004be
  170. 0x4004be
  171. baz()
  172. /tmp/test.cpp:11:18
  173. main
  174. /tmp/test.cpp:15:0
  175. $ llvm-symbolizer --obj=inlined.elf 0x4004be --pretty-print --print-address
  176. 0x4004be: baz() at /tmp/test.cpp:11:18
  177. (inlined by) main at /tmp/test.cpp:15:0
  178. .. option:: --print-source-context-lines <N>
  179. Print ``N`` lines of source context for each symbolized address.
  180. .. code-block:: console
  181. $ llvm-symbolizer --obj=test.elf 0x400490 --print-source-context-lines=2
  182. baz()
  183. /tmp/test.cpp:11:0
  184. 10 : volatile int k = 42;
  185. 11 >: return foz() + k;
  186. 12 : }
  187. .. _llvm-symbolizer-opt-use-symbol-table:
  188. .. option:: --use-symbol-table
  189. Prefer function names stored in symbol table to function names in debug info
  190. sections. Defaults to true.
  191. .. option:: --verbose
  192. Print verbose line and column information.
  193. .. code-block:: console
  194. $ llvm-symbolizer --obj=inlined.elf --verbose 0x4004be
  195. baz()
  196. Filename: /tmp/test.cpp
  197. Function start line: 9
  198. Line: 11
  199. Column: 18
  200. main
  201. Filename: /tmp/test.cpp
  202. Function start line: 14
  203. Line: 15
  204. Column: 0
  205. .. option:: --version
  206. Print version information for the tool.
  207. .. option:: @<FILE>
  208. Read command-line options from response file `<FILE>`.
  209. MACH-O SPECIFIC OPTIONS
  210. -----------------------
  211. .. option:: --default-arch <arch>
  212. If a binary contains object files for multiple architectures (e.g. it is a
  213. Mach-O universal binary), symbolize the object file for a given architecture.
  214. You can also specify the architecture by writing ``binary_name:arch_name`` in
  215. the input (see example below). If the architecture is not specified in either
  216. way, the address will not be symbolized. Defaults to empty string.
  217. .. code-block:: console
  218. $ cat addr.txt
  219. /tmp/mach_universal_binary:i386 0x1f84
  220. /tmp/mach_universal_binary:x86_64 0x100000f24
  221. $ llvm-symbolizer < addr.txt
  222. _main
  223. /tmp/source_i386.cc:8
  224. _main
  225. /tmp/source_x86_64.cc:8
  226. .. option:: --dsym-hint <path/to/file.dSYM>
  227. If the debug info for a binary isn't present in the default location, look for
  228. the debug info at the .dSYM path provided via this option. This flag can be
  229. used multiple times.
  230. EXIT STATUS
  231. -----------
  232. :program:`llvm-symbolizer` returns 0. Other exit codes imply an internal program
  233. error.
  234. SEE ALSO
  235. --------
  236. :manpage:`llvm-addr2line(1)`