Skip to content

Commit 68b08e5

Browse files
committed
[lldb] Improve 'lang objc tagged-pointer info' command
Don't try to get a class descriptor for a pointer that doesn't look like a tagged pointer. Also print addresses as fixed-width hex and update the test. (cherry picked from commit 10eb32f)
1 parent 3a3a862 commit 68b08e5

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -989,10 +989,15 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
989989
return false;
990990
}
991991

992+
if (!tagged_ptr_vendor->IsPossibleTaggedPointer(arg_addr)) {
993+
result.GetOutputStream().Format("{0:x16} is not tagged\n", arg_addr);
994+
continue;
995+
}
996+
992997
auto descriptor_sp = tagged_ptr_vendor->GetClassDescriptor(arg_addr);
993998
if (!descriptor_sp) {
994999
result.AppendErrorWithFormatv(
995-
"could not get class descriptor for {0:x}\n", arg_addr);
1000+
"could not get class descriptor for {0:x16}\n", arg_addr);
9961001
result.SetStatus(lldb::eReturnStatusFailed);
9971002
return false;
9981003
}
@@ -1004,15 +1009,14 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
10041009
&payload)) {
10051010
result.GetOutputStream().Format(
10061011
"{0:x} is tagged\n"
1007-
"\tpayload = {1:x}\n"
1008-
"\tvalue = {2:x}\n"
1009-
"\tinfo bits = {3:x}\n"
1012+
"\tpayload = {1:x16}\n"
1013+
"\tvalue = {2:x16}\n"
1014+
"\tinfo bits = {3:x16}\n"
10101015
"\tclass = {4}\n",
10111016
arg_addr, payload, value_bits, info_bits,
10121017
descriptor_sp->GetClassName().AsCString("<unknown>"));
10131018
} else {
1014-
result.GetOutputStream().Format("{0:x16} is not tagged\n",
1015-
(uint64_t)arg_addr);
1019+
result.GetOutputStream().Format("{0:x16} is not tagged\n", arg_addr);
10161020
}
10171021
}
10181022

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class TestTaggedPointerCommand(TestBase):
88

99
mydir = TestBase.compute_mydir(__file__)
1010

11+
@no_debug_info_test
1112
def test(self):
1213
self.build()
1314
lldbutil.run_to_source_breakpoint(self,"// break here", lldb.SBFileSpec("main.m"))
@@ -18,5 +19,5 @@ def test(self):
1819
self.expect("lang objc tagged-pointer info 0x0", error=True,
1920
patterns=["could not convert '0x0' to a valid address"])
2021

21-
self.expect("lang objc tagged-pointer info 0xffffffff", error=True,
22-
patterns=["could not get class descriptor for 0xffffffff"])
22+
self.expect("lang objc tagged-pointer info 0x00000001",
23+
patterns=["0x0000000000000001 is not tagged"])
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#import <Foundation/Foundation.h>
22
int main() {
33
id n1 = [NSNumber numberWithInt:1];
4-
printf("%x", n1); // break here
4+
printf("%x\n", n1); // break here
55
return 0;
66
}

0 commit comments

Comments
 (0)