Skip to content

Commit f9e6be5

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.
1 parent 0ef7ad3 commit f9e6be5

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
@@ -976,17 +976,16 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
976976
lldb::addr_t arg_addr = OptionArgParser::ToAddress(
977977
&exe_ctx, arg_str, LLDB_INVALID_ADDRESS, &error);
978978
if (arg_addr == 0 || arg_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
979-
result.AppendErrorWithFormat(
980-
"could not convert '%s' to a valid address\n", arg_str);
979+
result.AppendErrorWithFormatv(
980+
"could not convert '{0}' to a valid address\n", arg_str);
981981
result.SetStatus(lldb::eReturnStatusFailed);
982982
return false;
983983
}
984984

985985
auto descriptor_sp = tagged_ptr_vendor->GetClassDescriptor(arg_addr);
986986
if (!descriptor_sp) {
987-
result.AppendErrorWithFormat(
988-
"could not get class descriptor for 0x%" PRIx64 "\n",
989-
(uint64_t)arg_addr);
987+
result.AppendErrorWithFormatv(
988+
"could not get class descriptor for {0:x}\n", arg_addr);
990989
result.SetStatus(lldb::eReturnStatusFailed);
991990
return false;
992991
}
@@ -996,14 +995,16 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
996995
uint64_t payload = 0;
997996
if (descriptor_sp->GetTaggedPointerInfo(&info_bits, &value_bits,
998997
&payload)) {
999-
result.GetOutputStream().Printf(
1000-
"0x%" PRIx64 " is tagged.\n\tpayload = 0x%" PRIx64
1001-
"\n\tvalue = 0x%" PRIx64 "\n\tinfo bits = 0x%" PRIx64
1002-
"\n\tclass = %s\n",
1003-
(uint64_t)arg_addr, payload, value_bits, info_bits,
998+
result.GetOutputStream().Format(
999+
"{0:x} is tagged\n"
1000+
"\tpayload = {1:x}\n"
1001+
"\tvalue = {2:x}\n"
1002+
"\tinfo bits = {3:x}\n"
1003+
"\tclass = {4}\n",
1004+
arg_addr, payload, value_bits, info_bits,
10041005
descriptor_sp->GetClassName().AsCString("<unknown>"));
10051006
} else {
1006-
result.GetOutputStream().Printf("0x%" PRIx64 " is not tagged.\n",
1007+
result.GetOutputStream().Format("{0:x16} is not tagged\n",
10071008
(uint64_t)arg_addr);
10081009
}
10091010
}

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)