Skip to content

[lldb][Format] Add [inlined] marker to names of inlined frames (#142952) #10789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lldb/docs/use/formatting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ A complete list of currently supported format string variables is listed below:
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``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) |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``function.is-inlined`` | Will evaluate to true if this function was inlined |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``line.file.basename`` | The line table entry basename to the file for the current line entry in the current frame. |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``line.file.fullpath`` | The line table entry fullpath to the file for the current line entry in the current frame. |
Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/Core/FormatEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct Entry {
FunctionInitial,
FunctionChanged,
FunctionIsOptimized,
FunctionIsInlined,
LineEntryFile,
LineEntryLineNumber,
LineEntryColumn,
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Core/CoreProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ let Definition = "debugger" in {
Desc<"The default disassembly format string to use when disassembling instruction sequences.">;
def FrameFormat: Property<"frame-format", "FormatEntity">,
Global,
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">,
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">,
Desc<"The default frame format string to use when displaying stack frame information for threads.">;
def NotiftVoid: Property<"notify-void", "Boolean">,
Global,
Expand Down Expand Up @@ -268,7 +268,7 @@ let Definition = "debugger" in {
Desc<"If true, LLDB will automatically escape non-printable and escape characters when formatting strings.">;
def FrameFormatUnique: Property<"frame-format-unique", "FormatEntity">,
Global,
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">,
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">,
Desc<"The default frame format string to use when displaying stack frame information for threads from thread backtrace unique.">;
def ShowAutosuggestion: Property<"show-autosuggestion", "Boolean">,
Global,
Expand Down
6 changes: 6 additions & 0 deletions lldb/source/Core/FormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ constexpr Definition g_function_child_entries[] = {
Definition("initial-function", EntryType::FunctionInitial),
Definition("changed", EntryType::FunctionChanged),
Definition("is-optimized", EntryType::FunctionIsOptimized),
Definition("is-inlined", EntryType::FunctionIsInlined),
Definition("prefix", EntryType::FunctionPrefix),
Definition("scope", EntryType::FunctionScope),
Definition("basename", EntryType::FunctionBasename),
Expand Down Expand Up @@ -402,6 +403,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) {
ENUM_TO_CSTR(FunctionInitial);
ENUM_TO_CSTR(FunctionChanged);
ENUM_TO_CSTR(FunctionIsOptimized);
ENUM_TO_CSTR(FunctionIsInlined);
ENUM_TO_CSTR(LineEntryFile);
ENUM_TO_CSTR(LineEntryLineNumber);
ENUM_TO_CSTR(LineEntryColumn);
Expand Down Expand Up @@ -1936,6 +1938,10 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
return is_optimized;
}

case Entry::Type::FunctionIsInlined: {
return sc && sc->block && sc->block->GetInlinedFunctionInfo();
}

case Entry::Type::FunctionInitial:
return initial_function;

Expand Down
36 changes: 36 additions & 0 deletions lldb/test/Shell/Settings/TestFrameFunctionInlined.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# UNSUPPORTED: system-windows

# Test the ${function.is-inlined} frame-format variable.

# RUN: split-file %s %t
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
# RUN: | FileCheck %s

#--- main.cpp

void regular();

[[clang::always_inline]] void inlined1() {
regular();
}
void regular() {inlined1();}
[[clang::always_inline]] void inlined2() {regular();}

int main() {
inlined2();
return 0;
}

#--- commands.input

settings set frame-format "frame '${function.name}{${function.is-inlined} (Inlined)}'\n"
breakpoint set -n inlined1
run
bt

# CHECK: (lldb) bt
# CHECK: frame 'inlined1() (Inlined)'
# CHECK-NEXT: frame 'regular()'
# CHECK-NEXT: frame 'inlined2() (Inlined)'
# CHECK-NEXT: frame 'main'
1 change: 1 addition & 0 deletions lldb/unittests/Core/FormatEntityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ constexpr llvm::StringRef lookupStrings[] = {
"${function.initial-function}",
"${function.changed}",
"${function.is-optimized}",
"${function.is-inlined}",
"${line.file.basename}",
"${line.file.dirname}",
"${line.file.fullpath}",
Expand Down