Skip to content

Commit 3a3a862

Browse files
committed
[lldb] Update tagged pointer command output and test.
- Use formatv to print the addresses. - Add check for 0x0 which is treated as an invalid address. - Use a an address that's less likely to be interpreted as a real tagged pointer. (cherry picked from commit f9e6be5)
1 parent 03844d1 commit 3a3a862

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -983,17 +983,16 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
983983
lldb::addr_t arg_addr = OptionArgParser::ToAddress(
984984
&exe_ctx, arg_str, LLDB_INVALID_ADDRESS, &error);
985985
if (arg_addr == 0 || arg_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
986-
result.AppendErrorWithFormat(
987-
"could not convert '%s' to a valid address\n", arg_str);
986+
result.AppendErrorWithFormatv(
987+
"could not convert '{0}' to a valid address\n", arg_str);
988988
result.SetStatus(lldb::eReturnStatusFailed);
989989
return false;
990990
}
991991

992992
auto descriptor_sp = tagged_ptr_vendor->GetClassDescriptor(arg_addr);
993993
if (!descriptor_sp) {
994-
result.AppendErrorWithFormat(
995-
"could not get class descriptor for 0x%" PRIx64 "\n",
996-
(uint64_t)arg_addr);
994+
result.AppendErrorWithFormatv(
995+
"could not get class descriptor for {0:x}\n", arg_addr);
997996
result.SetStatus(lldb::eReturnStatusFailed);
998997
return false;
999998
}
@@ -1003,14 +1002,16 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
10031002
uint64_t payload = 0;
10041003
if (descriptor_sp->GetTaggedPointerInfo(&info_bits, &value_bits,
10051004
&payload)) {
1006-
result.GetOutputStream().Printf(
1007-
"0x%" PRIx64 " is tagged.\n\tpayload = 0x%" PRIx64
1008-
"\n\tvalue = 0x%" PRIx64 "\n\tinfo bits = 0x%" PRIx64
1009-
"\n\tclass = %s\n",
1010-
(uint64_t)arg_addr, payload, value_bits, info_bits,
1005+
result.GetOutputStream().Format(
1006+
"{0:x} is tagged\n"
1007+
"\tpayload = {1:x}\n"
1008+
"\tvalue = {2:x}\n"
1009+
"\tinfo bits = {3:x}\n"
1010+
"\tclass = {4}\n",
1011+
arg_addr, payload, value_bits, info_bits,
10111012
descriptor_sp->GetClassName().AsCString("<unknown>"));
10121013
} else {
1013-
result.GetOutputStream().Printf("0x%" PRIx64 " is not tagged.\n",
1014+
result.GetOutputStream().Format("{0:x16} is not tagged\n",
10141015
(uint64_t)arg_addr);
10151016
}
10161017
}

lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def test(self):
1515
self.expect("lang objc tagged-pointer info bogus", error=True,
1616
patterns=["could not convert 'bogus' to a valid address"])
1717

18-
self.expect("lang objc tagged-pointer info 0x1", error=True,
19-
patterns=["could not get class descriptor for 0x1"])
18+
self.expect("lang objc tagged-pointer info 0x0", error=True,
19+
patterns=["could not convert '0x0' to a valid address"])
2020

21+
self.expect("lang objc tagged-pointer info 0xffffffff", error=True,
22+
patterns=["could not get class descriptor for 0xffffffff"])

0 commit comments

Comments
 (0)