Skip to content

Commit e94bc16

Browse files
authored
[llvm-objdump] Add inlined function display support (#142246)
This patch adds the support for displaying inlined functions into llvm-objdump. 1) It extends the source variable display support for inlined functions both for ascii and unicode formats. 2) It also introduces a new format called limits-only that only prints a line for the start and end of an inlined function without line-drawing characters.
1 parent 9311f38 commit e94bc16

File tree

10 files changed

+1026
-167
lines changed

10 files changed

+1026
-167
lines changed

llvm/docs/CommandGuide/llvm-objdump.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,29 @@ OPTIONS
140140
debug information for stripped binaries. Multiple instances of this argument
141141
are searched in the order given.
142142

143-
.. option:: --debuginfod, --no-debuginfod
143+
.. option:: --debug-indent=<width>
144144

145-
Whether or not to try debuginfod lookups for debug binaries. Unless specified,
146-
debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``)
147-
and at least one server URL was provided by the environment variable
148-
``DEBUGINFOD_URLS``.
145+
Distance to indent the source-level variable or inlined function display,
146+
relative to the start of the disassembly. Defaults to 52 characters.
147+
148+
.. option:: --debug-inlined-funcs[=<format>]
149149

150-
.. option:: --debug-vars=<format>
150+
Print the locations of inlined functions alongside disassembly.
151+
``format`` may be ``ascii``, ``limits-only``, or ``unicode``, defaulting to
152+
``unicode`` if omitted.
153+
154+
.. option:: --debug-vars[=<format>]
151155

152156
Print the locations (in registers or memory) of source-level variables
153-
alongside disassembly. ``format`` may be ``unicode`` or ``ascii``, defaulting
157+
alongside disassembly. ``format`` may be ``ascii`` or ``unicode``, defaulting
154158
to ``unicode`` if omitted.
155159

156-
.. option:: --debug-vars-indent=<width>
160+
.. option:: --debuginfod, --no-debuginfod
157161

158-
Distance to indent the source-level variable display, relative to the start
159-
of the disassembly. Defaults to 52 characters.
162+
Whether or not to try debuginfod lookups for debug binaries. Unless specified,
163+
debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``)
164+
and at least one server URL was provided by the environment variable
165+
``DEBUGINFOD_URLS``.
160166

161167
.. option:: -j, --section=<section1[,section2,...]>
162168

llvm/docs/ReleaseNotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ Changes to the LLVM tools
282282
([#47468](https://github.com/llvm/llvm-project/issues/47468))
283283
* llvm-addr2line now supports a `+` prefix when specifying an address.
284284
* Support for `SHT_LLVM_BB_ADDR_MAP` versions 0 and 1 has been dropped.
285+
* llvm-objdump now supports the `--debug-inlined-funcs` flag, which prints the
286+
locations of inlined functions alongside disassembly. The
287+
`--debug-vars-indent` flag has also been renamed to `--debug-indent`.
285288

286289
Changes to LLDB
287290
---------------------------------

llvm/test/tools/llvm-objdump/ELF/ARM/debug-vars-dwarf4.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
## Check that passing the default value for --debug-vars-indent (52) makes no
1717
## change to the output.
18-
# RUN: llvm-objdump %t.o -d --debug-vars --debug-vars-indent=52 | \
18+
# RUN: llvm-objdump %t.o -d --debug-vars --debug-indent=52 | \
1919
# RUN: FileCheck %s --check-prefix=RAW --strict-whitespace
2020

21-
# RUN: llvm-objdump %t.o -d --debug-vars --debug-vars-indent=30 | \
21+
# RUN: llvm-objdump %t.o -d --debug-vars --debug-indent=30 | \
2222
# RUN: FileCheck %s --check-prefix=INDENT --strict-whitespace
2323

2424
# RUN: llvm-objdump %t.o -d --debug-vars --no-show-raw-insn | \
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
int bar(int x, int y) {
2+
int sum = x + y;
3+
int mul = x * y;
4+
return sum + mul;
5+
}
6+
7+
int foo(int a, int b) {
8+
int result = bar(a, b);
9+
return result;
10+
}

llvm/test/tools/llvm-objdump/X86/debug-inlined-functions.s

Lines changed: 643 additions & 0 deletions
Large diffs are not rendered by default.

llvm/tools/llvm-objdump/ObjdumpOpts.td

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,23 @@ defm prefix_strip
241241
"paths. No effect without --prefix">,
242242
MetaVarName<"prefix">;
243243

244+
def debug_indent_EQ : Joined<["--"], "debug-indent=">,
245+
HelpText<"Distance to indent the source-level variable and inlined function display, "
246+
"relative to the start of the disassembly">;
247+
248+
def debug_inlined_funcs_EQ : Joined<["--"], "debug-inlined-funcs=">,
249+
HelpText<"Print the locations of inlined functions alongside disassembly. "
250+
"Supported formats: ascii, limits-only, and unicode (default)">,
251+
Values<"ascii,limits-only,unicode">;
252+
def : Flag<["--"], "debug-inlined-funcs">, Alias<debug_inlined_funcs_EQ>, AliasArgs<["unicode"]>;
253+
244254
def debug_vars_EQ : Joined<["--"], "debug-vars=">,
245255
HelpText<"Print the locations (in registers or memory) of "
246256
"source-level variables alongside disassembly. "
247257
"Supported formats: ascii, unicode (default)">,
248-
Values<"unicode,ascii">;
258+
Values<"ascii,unicode">;
249259
def : Flag<["--"], "debug-vars">, Alias<debug_vars_EQ>, AliasArgs<["unicode"]>;
250260

251-
def debug_vars_indent_EQ : Joined<["--"], "debug-vars-indent=">,
252-
HelpText<"Distance to indent the source-level variable display, "
253-
"relative to the start of the disassembly">;
254-
255261
def x86_asm_syntax_att : Flag<["--"], "x86-asm-syntax=att">,
256262
HelpText<"Emit AT&T-style disassembly">;
257263

0 commit comments

Comments
 (0)