xref: /llvm-project/llvm/docs/CommandGuide/llvm-dwarfdump.rst (revision fcdb178bb477a7bd93048fa09a5ca6b1927bdb25)
1llvm-dwarfdump - dump and verify DWARF debug information
2========================================================
3
4.. program:: llvm-dwarfdump
5
6SYNOPSIS
7--------
8
9:program:`llvm-dwarfdump` [*options*] [*filename ...*]
10
11DESCRIPTION
12-----------
13
14:program:`llvm-dwarfdump` parses DWARF sections in object files,
15archives, and `.dSYM` bundles and prints their contents in
16human-readable form. Only the .debug_info section is printed unless one of
17the section-specific options or :option:`--all` is specified.
18
19If no input file is specified, `a.out` is used instead. If `-` is used as the
20input file, :program:`llvm-dwarfdump` reads the input from its standard input
21stream.
22
23OPTIONS
24-------
25
26.. option:: -a, --all
27
28            Dump all supported DWARF sections.
29
30.. option:: --arch=<arch>
31
32            Dump DWARF debug information for the specified CPU architecture.
33            Architectures may be specified by name or by number.  This
34            option can be specified multiple times, once for each desired
35            architecture.  All CPU architectures will be printed by
36            default.
37
38.. option:: -c, --show-children
39
40            Show a debug info entry's children when selectively printing with
41            the `=<offset>` argument of :option:`--debug-info`, or options such
42            as :option:`--find` or :option:`--name`.
43
44.. option:: --color
45
46            Use colors in output.
47
48.. option:: --error-display=<value>
49
50            Set the level of detail and summary to display when verifying.
51            Implies :option:`--verify`. The supported values are:
52
53            `quiet`   - Only display whether errors occurred.
54            `summary` - Display only a summary of the errors found.
55            `details` - Display each error in detail but no summary.
56            `full`    - Display each error as well as a summary. [default]
57
58.. option:: -f <name>, --find=<name>
59
60            Search for the exact text <name> in the accelerator tables
61            and print the matching debug information entries.
62            When there is no accelerator tables or the name of the DIE
63            you are looking for is not found in the accelerator tables,
64            try using the slower but more complete :option:`--name` option.
65
66.. option:: -F, --show-form
67
68            Show DWARF form types after the DWARF attribute types.
69
70.. option:: -h, --help
71
72            Show help and usage for this command.
73
74.. option:: --help-list
75
76            Show help and usage for this command without grouping the options
77            into categories.
78
79.. option:: -i, --ignore-case
80
81            Ignore case distinctions when using :option:`--name`.
82
83.. option:: -n <name>, --name=<name>
84
85            Find and print all debug info entries whose name
86            (`DW_AT_name` attribute) is <name>.
87
88.. option:: --lookup=<address>
89
90            Look up <address> in the debug information and print out the file,
91            function, block, and line table details.
92
93.. option:: -o <path>
94
95            Redirect output to a file specified by <path>, where `-` is the
96            standard output stream.
97
98.. option:: -p, --show-parents
99
100            Show a debug info entry's parents when selectively printing with
101            the `=<offset>` argument of :option:`--debug-info`, or options such
102            as :option:`--find` or :option:`--name`.
103
104.. option:: --parent-recurse-depth=<N>
105
106            When displaying debug info entry parents, only show them to a
107            maximum depth of <N>.
108
109.. option:: --quiet
110
111            Use with :option:`--verify` to not emit to `STDOUT`.
112
113.. option:: -r <N>, --recurse-depth=<N>
114
115            When displaying debug info entries, only show children to a maximum
116            depth of <N>.
117
118.. option:: --show-section-sizes
119
120            Show the sizes of all debug sections, expressed in bytes.
121
122.. option:: --show-sources
123
124            Print all source files mentioned in the debug information. Absolute
125            paths are given whenever possible.
126
127.. option:: --statistics
128
129            Collect debug info quality metrics and print the results
130            as machine-readable single-line JSON output. The output
131            format is described in the section below (:ref:`stats-format`).
132
133.. option:: --summarize-types
134
135            Abbreviate the description of type unit entries.
136
137.. option:: -x, --regex
138
139            Treat any <name> strings as regular expressions when searching
140            with :option:`--name`. If :option:`--ignore-case` is also specified,
141            the regular expression becomes case-insensitive.
142
143.. option:: -u, --uuid
144
145            Show the UUID for each architecture.
146
147.. option:: --diff
148
149            Dump the output in a format that is more friendly for comparing
150            DWARF output from two different files.
151
152.. option:: -v, --verbose
153
154            Display verbose information when dumping. This can help to debug
155            DWARF issues.
156
157.. option:: --verify
158
159            Verify the structure of the DWARF information by verifying the
160            compile unit chains, DIE relationships graph, address
161            ranges, and more.
162
163.. option:: --verify-json=<path>
164
165            Output JSON-formatted error summary to the a file specfied by
166            <path>. Implies :option:`--verify`.  The output format is described
167            in the section below (:ref:`verify-json-format`).
168
169.. option:: --version
170
171            Display the version of the tool.
172
173.. option:: --debug-abbrev, --debug-addr, --debug-aranges, --debug-cu-index, --debug-frame [=<offset>], --debug-gnu-pubnames, --debug-gnu-pubtypes, --debug-info [=<offset>], --debug-line [=<offset>], --debug-line-str, --debug-loc [=<offset>], --debug-loclists [=<offset>], --debug-macro, --debug-names, --debug-pubnames, --debug-pubtypes, --debug-ranges, --debug-rnglists, --debug-str, --debug-str-offsets, --debug-tu-index, --debug-types [=<offset>], --eh-frame [=<offset>], --gdb-index, --apple-names, --apple-types, --apple-namespaces, --apple-objc
174
175            Dump the specified DWARF section by name. Only the
176            `.debug_info` section is shown by default. Some entries
177            support adding an `=<offset>` as a way to provide an
178            optional offset of the exact entry to dump within the
179            respective section. When an offset is provided, only the
180            entry at that offset will be dumped, else the entire
181            section will be dumped.
182
183            The :option:`--debug-macro` option prints both the .debug_macro and the .debug_macinfo sections.
184
185            The :option:`--debug-frame` and :option:`--eh-frame` options are aliases, in cases where both sections are present one command outputs both.
186
187.. option:: @<FILE>
188
189            Read command-line options from `<FILE>`.
190
191.. _stats-format:
192
193FORMAT OF STATISTICS OUTPUT
194---------------------------
195
196The :option:`--statistics` option generates single-line JSON output
197representing quality metrics of the processed debug info. These metrics are
198useful to compare changes between two compilers, particularly for judging
199the effect that a change to the compiler has on the debug info quality.
200
201The output is formatted as key-value pairs. The first pair contains a version
202number. The following naming scheme is used for the keys:
203
204      - `variables` ==> local variables and parameters
205      - `local vars` ==> local variables
206      - `params` ==> formal parameters
207
208For aggregated values, the following keys are used:
209
210      - `sum_of_all_variables(...)` ==> the sum applied to all variables
211      - `#bytes` ==> the number of bytes
212      - `#variables - entry values ...` ==> the number of variables excluding
213        the entry values etc.
214
215.. _verify-json-format:
216
217FORMAT OF VERIFY JSON OUTPUT
218----------------------------
219
220The format of the JSON output created by the :option:`--verify-json` is::
221
222  {
223    "error-categories": {
224      "<first category description>": {"count": 1234},
225      "<next category description>": {"count": 4321}
226    },
227    "error-count": 5555
228  }
229
230The following is generated if there are no errors reported::
231
232  {
233    "error-categories": {},
234    "error-count": 0
235  }
236
237EXIT STATUS
238-----------
239
240:program:`llvm-dwarfdump` returns 0 if the input files were parsed and dumped
241successfully. Otherwise, it returns 1.
242
243SEE ALSO
244--------
245
246:manpage:`dsymutil(1)`
247