Skip to content
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 @@ -92,6 +92,8 @@ A complete list of currently supported format string variables is listed below:
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``function.name-without-args`` | The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``function.mangled-name`` | The mangled name of the current function or symbol. |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``function.pc-offset`` | The program counter offset within the current function or symbol |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``function.addr-offset`` | The offset in bytes of the current function, formatted as " + dddd" |
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 @@ -85,6 +85,7 @@ class FormatEntity {
FunctionName,
FunctionNameWithArgs,
FunctionNameNoArgs,
FunctionMangledName,
FunctionAddrOffset,
FunctionAddrOffsetConcrete,
FunctionLineOffset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def nsexception_data_formatter_commands(self):
'frame variable except0 except1 except2 except3',
substrs=[
'(NSException *) except0 = ',
'name: @"TheGuyWhoHasNoName" - reason: @"cuz it\'s funny"',
'@"First"',
'(NSException *) except1 = ',
'name: @"TheGuyWhoHasNoName~1" - reason: @"cuz it\'s funny"',
'@"Second"',
'(NSException *) except2 = ',
'name: @"TheGuyWhoHasNoName`2" - reason: @"cuz it\'s funny"',
' @"Third"',
'(NSException *) except3 = ',
'name: @"TheGuyWhoHasNoName/3" - reason: @"cuz it\'s funny"'
' @"Fourth"'
])
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,10 @@ int main (int argc, const char * argv[])
nsurl0 = [bundle bundleURL];
}

NSException* except0 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName" reason:@"cuz it's funny" userInfo:nil];
NSException* except1 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName~1" reason:@"cuz it's funny" userInfo:nil];
NSException* except2 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2" reason:@"cuz it's funny" userInfo:nil];
NSException* except3 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3" reason:@"cuz it's funny" userInfo:nil];
NSException* except0 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName" reason:@"First" userInfo:nil];
NSException* except1 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName~1" reason:@"Second" userInfo:nil];
NSException* except2 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2" reason:@"Third" userInfo:nil];
NSException* except3 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3" reason:@"Fourth" userInfo:nil];

NSURL *nsurl = [[NSURL alloc] initWithString:@"http://www.foo.bar"];
NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_objc_exceptions_at_throw(self):

self.expect('thread exception', substrs=[
'(NSException *) exception = ',
'name: "ThrownException" - reason: "SomeReason"',
'"SomeReason"',
])

target = self.dbg.GetSelectedTarget()
Expand Down Expand Up @@ -63,7 +63,7 @@ def test_objc_exceptions_at_throw(self):
'frame variable e1',
substrs=[
'(NSException *) e1 = ',
'name: "ExceptionName" - reason: "SomeReason"'
'"SomeReason"'
])

self.expect(
Expand All @@ -79,7 +79,7 @@ def test_objc_exceptions_at_throw(self):
e1 = frame.FindVariable("e1")
self.assertTrue(e1)
self.assertEqual(e1.type.name, "NSException *")
self.assertEqual(e1.GetSummary(), 'name: "ExceptionName" - reason: "SomeReason"')
self.assertEqual(e1.GetSummary(), '"SomeReason"')
self.assertEqual(e1.GetChildMemberWithName("name").description, "ExceptionName")
self.assertEqual(e1.GetChildMemberWithName("reason").description, "SomeReason")
userInfo = e1.GetChildMemberWithName("userInfo").dynamic
Expand All @@ -92,7 +92,7 @@ def test_objc_exceptions_at_throw(self):
'frame variable e2',
substrs=[
'(NSException *) e2 = ',
'name: "ThrownException" - reason: "SomeReason"'
'"SomeReason"'
])

self.expect(
Expand All @@ -108,7 +108,7 @@ def test_objc_exceptions_at_throw(self):
e2 = frame.FindVariable("e2")
self.assertTrue(e2)
self.assertEqual(e2.type.name, "NSException *")
self.assertEqual(e2.GetSummary(), 'name: "ThrownException" - reason: "SomeReason"')
self.assertEqual(e2.GetSummary(), '"SomeReason"')
self.assertEqual(e2.GetChildMemberWithName("name").description, "ThrownException")
self.assertEqual(e2.GetChildMemberWithName("reason").description, "SomeReason")
userInfo = e2.GetChildMemberWithName("userInfo").dynamic
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_objc_exceptions_at_abort(self):

self.expect('thread exception', substrs=[
'(NSException *) exception = ',
'name: "ThrownException" - reason: "SomeReason"',
'"SomeReason"',
'libobjc.A.dylib`objc_exception_throw',
'a.out`foo', 'at main.mm:24',
'a.out`rethrow', 'at main.mm:35',
Expand Down
27 changes: 27 additions & 0 deletions lldb/source/Core/FormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ static FormatEntity::Entry::Definition g_function_child_entries[] = {
ENTRY("name", FunctionName),
ENTRY("name-without-args", FunctionNameNoArgs),
ENTRY("name-with-args", FunctionNameWithArgs),
ENTRY("mangled-name", FunctionMangledName),
ENTRY("addr-offset", FunctionAddrOffset),
ENTRY("concrete-only-addr-offset-no-padding", FunctionAddrOffsetConcrete),
ENTRY("line-offset", FunctionLineOffset),
Expand Down Expand Up @@ -351,6 +352,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) {
ENUM_TO_CSTR(FunctionName);
ENUM_TO_CSTR(FunctionNameWithArgs);
ENUM_TO_CSTR(FunctionNameNoArgs);
ENUM_TO_CSTR(FunctionMangledName);
ENUM_TO_CSTR(FunctionAddrOffset);
ENUM_TO_CSTR(FunctionAddrOffsetConcrete);
ENUM_TO_CSTR(FunctionLineOffset);
Expand Down Expand Up @@ -1744,6 +1746,31 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
}
return false;

case Entry::Type::FunctionMangledName: {
const char *name = nullptr;
if (sc->symbol)
name = sc->symbol->GetMangled()
.GetName(sc->symbol->GetLanguage(), Mangled::ePreferMangled)
.AsCString();
else if (sc->function)
name = sc->function->GetMangled()
.GetName(sc->symbol->GetLanguage(), Mangled::ePreferMangled)
.AsCString();

if (!name)
return false;
s.PutCString(name);

if (Block *inline_block = sc->block->GetContainingInlinedBlock()) {
if (const InlineFunctionInfo *inline_info =
sc->block->GetInlinedFunctionInfo()) {
s.PutCString(" [inlined] ");
inline_info->GetName(sc->function->GetLanguage()).Dump(&s);
}
}
return true;
}

case Entry::Type::FunctionAddrOffset:
if (addr) {
if (DumpAddressOffsetFromFunction(s, sc, exe_ctx, *addr, false, false,
Expand Down
16 changes: 7 additions & 9 deletions lldb/source/Plugins/Language/ObjC/NSException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,19 @@ static bool ExtractFields(ValueObject &valobj, ValueObjectSP *name_sp,

bool lldb_private::formatters::NSException_SummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
lldb::ValueObjectSP name_sp;
lldb::ValueObjectSP reason_sp;
if (!ExtractFields(valobj, &name_sp, &reason_sp, nullptr, nullptr))
if (!ExtractFields(valobj, nullptr, &reason_sp, nullptr, nullptr))
return false;

if (!name_sp || !reason_sp)
if (!reason_sp) {
stream.Printf("No reason");
return false;
}

StreamString name_str_summary;
StreamString reason_str_summary;
if (NSStringSummaryProvider(*name_sp, name_str_summary, options) &&
NSStringSummaryProvider(*reason_sp, reason_str_summary, options) &&
!name_str_summary.Empty() && !reason_str_summary.Empty()) {
stream.Printf("name: %s - reason: %s", name_str_summary.GetData(),
reason_str_summary.GetData());
if (NSStringSummaryProvider(*reason_sp, reason_str_summary, options) &&
!reason_str_summary.Empty()) {
stream.Printf("%s", reason_str_summary.GetData());
return true;
} else
return false;
Expand Down
15 changes: 15 additions & 0 deletions lldb/test/Shell/Settings/Inputs/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class MyClass {
public:
MyClass() {}
void foo();
};

void MyClass::foo() {
return; // Set break point at this line.
}

int main() {
MyClass mc;
mc.foo();
return 0;
}
12 changes: 12 additions & 0 deletions lldb/test/Shell/Settings/TestFrameFormatMangling.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# UNSUPPORTED: system-windows
# RUN: %clangxx_host -g -O0 %S/Inputs/main.cpp -o %t.out
# RUN: %lldb -b -s %s %t.out | FileCheck %s
br set -p "Set break"
run
frame info
# CHECK: frame #0: {{.*}}MyClass::foo(
set set frame-format "frame #${frame.index}: {${function.mangled-name}}\n"
frame info
# CHECK: frame #0: _ZN7MyClass3fooEv
c
q