diff options
author | Michael Buch <michaelbuch12@gmail.com> | 2025-04-13 23:21:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-13 23:21:52 +0100 |
commit | 1e153b782ea3054c02dd0016314fca11a5d781da (patch) | |
tree | cf1904fd7169c1384b669c972b350bf7d7d1741c /lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp | |
parent | 5710759eb390c0d5274c2a4d43967282d7df1993 (diff) | |
download | llvm-1e153b782ea3054c02dd0016314fca11a5d781da.zip llvm-1e153b782ea3054c02dd0016314fca11a5d781da.tar.gz llvm-1e153b782ea3054c02dd0016314fca11a5d781da.tar.bz2 |
[lldb][Format] Display only the inlined frame name in backtraces if available (#135343)
When a frame is inlined, LLDB will display its name in backtraces as
follows:
```
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.3
* frame #0: 0x0000000100000398 a.out`func() [inlined] baz(x=10) at inline.cpp:1:42
frame #1: 0x0000000100000398 a.out`func() [inlined] bar() at inline.cpp:2:37
frame #2: 0x0000000100000398 a.out`func() at inline.cpp:4:15
frame #3: 0x00000001000003c0 a.out`main at inline.cpp:7:5
frame #4: 0x000000026eb29ab8 dyld`start + 6812
```
The longer the names get the more confusing this gets because the first
function name that appears is the parent frame. My assumption (which may
need some more surveying) is that for the majority of cases we only care
about the actual frame name (not the parent). So this patch removes all
the special logic that prints the parent frame.
Another quirk of the current format is that the inlined frame name does
not abide by the `${function.name-XXX}` format variables. We always just
print the raw demangled name. With this patch, we would format the
inlined frame name according to the `frame-format` setting (see the
test-cases).
If we really want to have the `parentFrame [inlined] inlinedFrame`
format, we could expose it through a new `frame-format` variable (e..g.,
`${function.inlined-at-name}` and let the user decide where to place
things.
Diffstat (limited to 'lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp')
-rw-r--r-- | lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 8c05f09..9bd48ec 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1707,22 +1707,6 @@ static VariableListSP GetFunctionVariableList(const SymbolContext &sc) { return sc.function->GetBlock(true).GetBlockVariableList(true); } -static char const *GetInlinedFunctionName(const SymbolContext &sc) { - if (!sc.block) - return nullptr; - - const Block *inline_block = sc.block->GetContainingInlinedBlock(); - if (!inline_block) - return nullptr; - - const InlineFunctionInfo *inline_info = - inline_block->GetInlinedFunctionInfo(); - if (!inline_info) - return nullptr; - - return inline_info->GetName().AsCString(nullptr); -} - static bool PrintFunctionNameWithArgs(Stream &s, const ExecutionContext *exe_ctx, const SymbolContext &sc) { @@ -1731,16 +1715,11 @@ static bool PrintFunctionNameWithArgs(Stream &s, ExecutionContextScope *exe_scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr; - const char *cstr = sc.function->GetName().AsCString(nullptr); + const char *cstr = sc.GetPossiblyInlinedFunctionName( + Mangled::NamePreference::ePreferDemangled); if (!cstr) return false; - if (const char *inlined_name = GetInlinedFunctionName(sc)) { - s.PutCString(cstr); - s.PutCString(" [inlined] "); - cstr = inlined_name; - } - VariableList args; if (auto variable_list_sp = GetFunctionVariableList(sc)) variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, |