Skip to content

[lldb][Format] Fix missing inlined function names in frame formatting. #78494

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 3 commits into from
Jan 18, 2024
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
38 changes: 17 additions & 21 deletions lldb/source/Core/FormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,19 @@ static void PrettyPrintFunctionNameWithArgs(Stream &out_stream,
out_stream.PutChar(')');
}

static void FormatInlinedBlock(Stream &out_stream, Block *block) {
if (!block)
return;
Block *inline_block = block->GetContainingInlinedBlock();
if (inline_block) {
if (const InlineFunctionInfo *inline_info =
inline_block->GetInlinedFunctionInfo()) {
out_stream.PutCString(" [inlined] ");
inline_info->GetName().Dump(&out_stream);
}
}
}

bool FormatEntity::FormatStringRef(const llvm::StringRef &format_str, Stream &s,
const SymbolContext *sc,
const ExecutionContext *exe_ctx,
Expand Down Expand Up @@ -1592,18 +1605,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,

if (name) {
s.PutCString(name);

if (sc->block) {
Block *inline_block = sc->block->GetContainingInlinedBlock();
if (inline_block) {
const InlineFunctionInfo *inline_info =
sc->block->GetInlinedFunctionInfo();
if (inline_info) {
s.PutCString(" [inlined] ");
inline_info->GetName().Dump(&s);
}
}
}
FormatInlinedBlock(s, sc->block);
return true;
}
}
Expand Down Expand Up @@ -1638,6 +1640,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
name = sc->symbol->GetNameNoArguments();
if (name) {
s.PutCString(name.GetCString());
FormatInlinedBlock(s, sc->block);
return true;
}
}
Expand Down Expand Up @@ -1678,7 +1681,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,

if (inline_block) {
get_function_vars = false;
inline_info = sc->block->GetInlinedFunctionInfo();
inline_info = inline_block->GetInlinedFunctionInfo();
if (inline_info)
variable_list_sp = inline_block->GetBlockVariableList(true);
}
Expand Down Expand Up @@ -1733,14 +1736,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
if (!name)
return false;
s.PutCString(name);

if (sc->block && sc->block->GetContainingInlinedBlock()) {
if (const InlineFunctionInfo *inline_info =
sc->block->GetInlinedFunctionInfo()) {
s.PutCString(" [inlined] ");
inline_info->GetName().Dump(&s);
}
}
FormatInlinedBlock(s, sc->block);
return true;
}
case Entry::Type::FunctionAddrOffset:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(

if (inline_block) {
get_function_vars = false;
inline_info = sc->block->GetInlinedFunctionInfo();
inline_info = inline_block->GetInlinedFunctionInfo();
if (inline_info)
variable_list_sp = inline_block->GetBlockVariableList(true);
}
Expand Down
8 changes: 7 additions & 1 deletion lldb/test/Shell/Settings/Inputs/names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ int anon_bar() { return 1; }
auto anon_lambda = [] {};
} // namespace

__attribute__((always_inline)) int inlined_foo(const char *str) {
if (bool b = bar())
return 1;
return 2;
}

int main() {
ns::foo<decltype(bar)>(bar);
ns::foo<decltype(bar)>("bar");
Expand All @@ -37,6 +43,6 @@ int main() {
f.foo(anon_bar);
f.operator<< <(2 > 1)>(0);
f.returns_func_ptr<int>(detail::Quux<int>{});

inlined_foo("bar");
return 0;
}
55 changes: 55 additions & 0 deletions lldb/test/Shell/Settings/TestFrameFormatName.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# UNSUPPORTED: system-windows
# Test different name formats.

# RUN: %build %S/Inputs/names.cpp --std c++17 -o %t.out
# RUN: split-file %s %t

#--- name_with_args.input
# RUN: %lldb -b -s %t/name_with_args.input %t.out | FileCheck %s --check-prefix=NAME_WITH_ARGS
settings set -f frame-format "frame ${function.name-with-args}\n"
break set -n foo
break set -n operator<<
break set -n returns_func_ptr
break set -n inlined_foo
run
# NAME_WITH_ARGS: frame int ns::foo<int ()>(t={{.*}})
c
# NAME_WITH_ARGS: frame int ns::foo<int ()>(str="bar")
c
# NAME_WITH_ARGS: frame int ns::foo<(anonymous namespace)::$_0>(t=(anonymous namespace)::(unnamed class) @ {{.*}})
c
# NAME_WITH_ARGS: frame int ns::foo<int (*)()>(t=({{.*}}`(anonymous namespace)::anon_bar() at {{.*}}))
c
# NAME_WITH_ARGS: frame int ns::foo<void (Foo::*)(int (*)(int)) const noexcept>(str="method")
c
# NAME_WITH_ARGS: frame ns::returns_func_ptr<int>((null)={{.*}})
c
# NAME_WITH_ARGS: frame void Foo::foo<int (*)()>(this={{.*}}, arg=({{.*}}`(anonymous namespace)::anon_bar() at {{.*}}))
c
# NAME_WITH_ARGS: frame void Foo::operator<<<1>(this={{.*}}, (null)=0)
c
# NAME_WITH_ARGS: frame Foo::returns_func_ptr<int>(this={{.*}}, (null)={{.*}})
c
# NAME_WITH_ARGS: frame main [inlined] inlined_foo(str="bar")
q

#--- name.input
# RUN: %lldb -b -s %t/name.input %t.out | FileCheck %s --check-prefix=NAME
settings set -f frame-format "frame ${function.name}\n"
break set -n inlined_foo
run
# NAME: frame main [inlined] inlined_foo(char const*)

#--- name_without_args.input
# RUN: %lldb -b -s %t/name_without_args.input %t.out | FileCheck %s --check-prefix=NAME_WITHOUT_ARGS
settings set -f frame-format "frame ${function.name-without-args}\n"
break set -n inlined_foo
run
# NAME_WITHOUT_ARGS: frame main [inlined] inlined_foo(char const*)

#--- mangled_name.input
# RUN: %lldb -b -s %t/mangled_name.input %t.out | FileCheck %s --check-prefix=MANGLED_NAME
settings set -f frame-format "frame ${function.mangled-name}\n"
break set -n inlined_foo
run
# MANGLED_NAME: frame main [inlined] inlined_foo(char const*)
26 changes: 0 additions & 26 deletions lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test

This file was deleted.