Skip to content

Commit 5a91892

Browse files
authored
[lldb][Format] Add [inlined] marker to names of inlined frames (llvm#142952)
This was removed in llvm#135343 in favour of making it a format variable, which we do here. This follows the precedent of the `[opt]` and `[artificial]` markers. Before: ``` thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2 * frame #0: 0x000000010000037c a.out`inlined1() at inline.cpp:4:3 frame #1: 0x000000010000037c a.out`regular() at inline.cpp:6:17 frame #2: 0x00000001000003b8 a.out`inlined2() at inline.cpp:7:43 frame #3: 0x00000001000003b4 a.out`main at inline.cpp:10:3 frame #4: 0x0000000186345be4 dyld`start + 7040 ``` After (note the `[inlined]` markers): ``` thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2 * frame #0: 0x000000010000037c a.out`inlined1() at inline.cpp:4:3 [inlined] frame #1: 0x000000010000037c a.out`regular() at inline.cpp:6:17 frame #2: 0x00000001000003b8 a.out`inlined2() at inline.cpp:7:43 [inlined] frame #3: 0x00000001000003b4 a.out`main at inline.cpp:10:3 frame #4: 0x0000000186345be4 dyld`start + 7040 ``` rdar://152642178
1 parent 1463da8 commit 5a91892

File tree

6 files changed

+46
-2
lines changed

6 files changed

+46
-2
lines changed

lldb/docs/use/formatting.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ A complete list of currently supported format string variables is listed below:
122122
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
123123
| ``function.initial-function`` | Will evaluate to true if this is the start of the first function, as opposed to a change of functions (may be used in ``disassembly-format`` to print the function name for the first function being disassembled) |
124124
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
125+
| ``function.is-inlined`` | Will evaluate to true if this function was inlined |
126+
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
125127
| ``line.file.basename`` | The line table entry basename to the file for the current line entry in the current frame. |
126128
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
127129
| ``line.file.fullpath`` | The line table entry fullpath to the file for the current line entry in the current frame. |

lldb/include/lldb/Core/FormatEntity.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct Entry {
104104
FunctionInitial,
105105
FunctionChanged,
106106
FunctionIsOptimized,
107+
FunctionIsInlined,
107108
LineEntryFile,
108109
LineEntryLineNumber,
109110
LineEntryColumn,

lldb/source/Core/CoreProperties.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ let Definition = "debugger" in {
5959
Desc<"The default disassembly format string to use when disassembling instruction sequences.">;
6060
def FrameFormat: Property<"frame-format", "FormatEntity">,
6161
Global,
62-
DefaultStringValue<"frame #${frame.index}: ${ansi.fg.cyan}${frame.pc}${ansi.normal}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\\\\n">,
62+
DefaultStringValue<"frame #${frame.index}: ${ansi.fg.cyan}${frame.pc}${ansi.normal}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${function.is-inlined} [inlined]}{${frame.is-artificial} [artificial]}\\\\n">,
6363
Desc<"The default frame format string to use when displaying stack frame information for threads.">;
6464
def NotiftVoid: Property<"notify-void", "Boolean">,
6565
Global,
@@ -217,7 +217,7 @@ let Definition = "debugger" in {
217217
Desc<"If true, LLDB will automatically escape non-printable and escape characters when formatting strings.">;
218218
def FrameFormatUnique: Property<"frame-format-unique", "FormatEntity">,
219219
Global,
220-
DefaultStringValue<"frame #${frame.index}: ${ansi.fg.cyan}${frame.pc}${ansi.normal}{ ${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\\\\n">,
220+
DefaultStringValue<"frame #${frame.index}: ${ansi.fg.cyan}${frame.pc}${ansi.normal}{ ${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${function.is-inlined} [inlined]}{${frame.is-artificial} [artificial]}\\\\n">,
221221
Desc<"The default frame format string to use when displaying stack frame information for threads from thread backtrace unique.">;
222222
def ShowAutosuggestion: Property<"show-autosuggestion", "Boolean">,
223223
Global,

lldb/source/Core/FormatEntity.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ constexpr Definition g_function_child_entries[] = {
124124
Definition("initial-function", EntryType::FunctionInitial),
125125
Definition("changed", EntryType::FunctionChanged),
126126
Definition("is-optimized", EntryType::FunctionIsOptimized),
127+
Definition("is-inlined", EntryType::FunctionIsInlined),
127128
Definition("prefix", EntryType::FunctionPrefix),
128129
Definition("scope", EntryType::FunctionScope),
129130
Definition("basename", EntryType::FunctionBasename),
@@ -402,6 +403,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) {
402403
ENUM_TO_CSTR(FunctionInitial);
403404
ENUM_TO_CSTR(FunctionChanged);
404405
ENUM_TO_CSTR(FunctionIsOptimized);
406+
ENUM_TO_CSTR(FunctionIsInlined);
405407
ENUM_TO_CSTR(LineEntryFile);
406408
ENUM_TO_CSTR(LineEntryLineNumber);
407409
ENUM_TO_CSTR(LineEntryColumn);
@@ -1928,6 +1930,10 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
19281930
return is_optimized;
19291931
}
19301932

1933+
case Entry::Type::FunctionIsInlined: {
1934+
return sc && sc->block && sc->block->GetInlinedFunctionInfo();
1935+
}
1936+
19311937
case Entry::Type::FunctionInitial:
19321938
return initial_function;
19331939

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Test the ${function.is-inlined} frame-format variable.
2+
3+
# RUN: split-file %s %t
4+
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
5+
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
6+
# RUN: | FileCheck %s
7+
8+
#--- main.cpp
9+
10+
void regular();
11+
12+
[[clang::always_inline]] void inlined1() {
13+
regular();
14+
}
15+
void regular() {inlined1();}
16+
[[clang::always_inline]] void inlined2() {regular();}
17+
18+
int main() {
19+
inlined2();
20+
return 0;
21+
}
22+
23+
#--- commands.input
24+
25+
settings set frame-format "frame '${function.name}{${function.is-inlined} (Inlined)}'\n"
26+
breakpoint set -n inlined1
27+
run
28+
bt
29+
30+
# CHECK: (lldb) bt
31+
# CHECK: frame 'inlined1() (Inlined)'
32+
# CHECK-NEXT: frame 'regular()'
33+
# CHECK-NEXT: frame 'inlined2() (Inlined)'
34+
# CHECK-NEXT: frame 'main'

lldb/unittests/Core/FormatEntityTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ constexpr llvm::StringRef lookupStrings[] = {
129129
"${function.initial-function}",
130130
"${function.changed}",
131131
"${function.is-optimized}",
132+
"${function.is-inlined}",
132133
"${line.file.basename}",
133134
"${line.file.dirname}",
134135
"${line.file.fullpath}",

0 commit comments

Comments
 (0)