[Lldb-commits] [lldb] 10eb32f - [lldb] Improve 'lang objc tagged-pointer info' command
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 5 13:19:07 PDT 2021
Author: Jonas Devlieghere
Date: 2021-11-05T13:19:00-07:00
New Revision: 10eb32f45d40e180a229590f57dd0a61f97f1bc9
URL: https://github.com/llvm/llvm-project/commit/10eb32f45d40e180a229590f57dd0a61f97f1bc9
DIFF: https://github.com/llvm/llvm-project/commit/10eb32f45d40e180a229590f57dd0a61f97f1bc9.diff
LOG: [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.
Added:
Modified:
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
lldb/test/API/lang/objc/tagged-pointer/main.m
Removed:
################################################################################
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 2cc05f4234fa7..bd6b6335ca8c9 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -982,10 +982,15 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
return false;
}
+ if (!tagged_ptr_vendor->IsPossibleTaggedPointer(arg_addr)) {
+ result.GetOutputStream().Format("{0:x16} is not tagged\n", arg_addr);
+ continue;
+ }
+
auto descriptor_sp = tagged_ptr_vendor->GetClassDescriptor(arg_addr);
if (!descriptor_sp) {
result.AppendErrorWithFormatv(
- "could not get class descriptor for {0:x}\n", arg_addr);
+ "could not get class descriptor for {0:x16}\n", arg_addr);
result.SetStatus(lldb::eReturnStatusFailed);
return false;
}
@@ -997,15 +1002,14 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
&payload)) {
result.GetOutputStream().Format(
"{0:x} is tagged\n"
- "\tpayload = {1:x}\n"
- "\tvalue = {2:x}\n"
- "\tinfo bits = {3:x}\n"
+ "\tpayload = {1:x16}\n"
+ "\tvalue = {2:x16}\n"
+ "\tinfo bits = {3:x16}\n"
"\tclass = {4}\n",
arg_addr, payload, value_bits, info_bits,
descriptor_sp->GetClassName().AsCString("<unknown>"));
} else {
- result.GetOutputStream().Format("{0:x16} is not tagged\n",
- (uint64_t)arg_addr);
+ result.GetOutputStream().Format("{0:x16} is not tagged\n", arg_addr);
}
}
diff --git a/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py b/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
index fbe9de7ecf80e..4c70b53ca4b28 100644
--- a/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
+++ b/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
@@ -8,6 +8,7 @@ class TestTaggedPointerCommand(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ @no_debug_info_test
def test(self):
self.build()
lldbutil.run_to_source_breakpoint(self,"// break here", lldb.SBFileSpec("main.m"))
@@ -18,5 +19,5 @@ def test(self):
self.expect("lang objc tagged-pointer info 0x0", error=True,
patterns=["could not convert '0x0' to a valid address"])
- self.expect("lang objc tagged-pointer info 0xffffffff", error=True,
- patterns=["could not get class descriptor for 0xffffffff"])
+ self.expect("lang objc tagged-pointer info 0x00000001",
+ patterns=["0x0000000000000001 is not tagged"])
diff --git a/lldb/test/API/lang/objc/tagged-pointer/main.m b/lldb/test/API/lang/objc/tagged-pointer/main.m
index 4d2ccf5120042..11a9781482f11 100644
--- a/lldb/test/API/lang/objc/tagged-pointer/main.m
+++ b/lldb/test/API/lang/objc/tagged-pointer/main.m
@@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
int main() {
id n1 = [NSNumber numberWithInt:1];
- printf("%x", n1); // break here
+ printf("%x\n", n1); // break here
return 0;
}
More information about the lldb-commits
mailing list