Skip to content

Commit 91c4418

Browse files
committed
[llvm-objdump] Add inlined function display support
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 line that only prints a line for the start and end of an inlined function without line-drawing characters.
1 parent a97f734 commit 91c4418

File tree

10 files changed

+944
-74
lines changed

10 files changed

+944
-74
lines changed

llvm/docs/CommandGuide/llvm-objdump.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,23 @@ OPTIONS
147147
and at least one server URL was provided by the environment variable
148148
``DEBUGINFOD_URLS``.
149149

150-
.. option:: --debug-vars=<format>
150+
.. option:: --debug-indent=<width>
151+
152+
Distance to indent the source-level variable or inlined function display,
153+
relative to the start of the disassembly. Defaults to 52 characters.
154+
155+
.. option:: --debug-inlined-funcs[=<format>]
156+
157+
Print the locations of inlined functions alongside disassembly.
158+
``format`` may be ``unicode``, ``ascii`` or ``line``, defaulting to
159+
``unicode`` if omitted.
160+
161+
.. option:: --debug-vars[=<format>]
151162

152163
Print the locations (in registers or memory) of source-level variables
153164
alongside disassembly. ``format`` may be ``unicode`` or ``ascii``, defaulting
154165
to ``unicode`` if omitted.
155166

156-
.. option:: --debug-vars-indent=<width>
157-
158-
Distance to indent the source-level variable display, relative to the start
159-
of the disassembly. Defaults to 52 characters.
160-
161167
.. option:: -j, --section=<section1[,section2,...]>
162168

163169
Perform commands on the specified sections only. For Mach-O use

llvm/docs/ReleaseNotes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ Changes to the LLVM tools
204204
* llvm-strip now supports continuing to process files on encountering an error.
205205
* In llvm-objcopy/llvm-strip's ELF port, `--discard-locals` and `--discard-all` now allow and preserve symbols referenced by relocations.
206206
([#47468](https://github.com/llvm/llvm-project/issues/47468))
207+
* llvm-objdump now supports the `--debug-inlined-funcs` flag that prints the
208+
locations of inlined functions alongside disassembly. It also renames
209+
`--debug-vars-indent` flag to `--debug-indent`.
210+
207211

208212
Changes to LLDB
209213
---------------------------------

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-function.s

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

llvm/tools/llvm-objdump/ObjdumpOpts.td

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,13 @@ def debug_vars_EQ : Joined<["--"], "debug-vars=">,
248248
Values<"unicode,ascii">;
249249
def : Flag<["--"], "debug-vars">, Alias<debug_vars_EQ>, AliasArgs<["unicode"]>;
250250

251-
def debug_vars_indent_EQ : Joined<["--"], "debug-vars-indent=">,
251+
def debug_inlined_funcs_EQ : Joined<["--"], "debug-inlined-funcs=">,
252+
HelpText<"Print the locations of inlined functions alongside disassembly. "
253+
"Supported formats: ascii, unicode (default) and line">,
254+
Values<"unicode,ascii,line">;
255+
def : Flag<["--"], "debug-inlined-funcs">, Alias<debug_inlined_funcs_EQ>, AliasArgs<["unicode"]>;
256+
257+
def debug_indent_EQ : Joined<["--"], "debug-indent=">,
252258
HelpText<"Distance to indent the source-level variable display, "
253259
"relative to the start of the disassembly">;
254260

0 commit comments

Comments
 (0)