[Lldb-commits] [lldb] 93d3775 - [lldb] Fix tagged-pointer info address parsing (#134123)

via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 2 15:17:01 PDT 2025


Author: Dave Lee
Date: 2025-04-02T15:16:58-07:00
New Revision: 93d3775da8810e1542873b1cdcec2ea142704561

URL: https://github.com/llvm/llvm-project/commit/93d3775da8810e1542873b1cdcec2ea142704561
DIFF: https://github.com/llvm/llvm-project/commit/93d3775da8810e1542873b1cdcec2ea142704561.diff

LOG: [lldb] Fix tagged-pointer info address parsing (#134123)

Change `objc tagged-pointer info` to call
`OptionArgParser::ToRawAddress`.

Previously `ToAddress` was used, but it calls `FixCodeAddress`, which
can erroneously mutate the bits of a tagged pointer.

Added: 
    

Modified: 
    lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
    lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index c91a29ace1f68..2338367302387 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1047,7 +1047,7 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
         continue;
 
       Status error;
-      lldb::addr_t arg_addr = OptionArgParser::ToAddress(
+      lldb::addr_t arg_addr = OptionArgParser::ToRawAddress(
           &exe_ctx, arg_str, LLDB_INVALID_ADDRESS, &error);
       if (arg_addr == 0 || arg_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
         result.AppendErrorWithFormatv(

diff  --git a/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py b/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
index d2519359c783b..f2f6026642d20 100644
--- a/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
+++ b/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
@@ -8,10 +8,22 @@ class TestTaggedPointerCommand(TestBase):
     @no_debug_info_test
     def test(self):
         self.build()
-        lldbutil.run_to_source_breakpoint(
+        _, _, thread, _ = lldbutil.run_to_source_breakpoint(
             self, "// break here", lldb.SBFileSpec("main.m")
         )
 
+        n1 = thread.GetSelectedFrame().FindVariable("n1")
+        self.expect(
+            f"lang objc tagged-pointer info {n1.addr}",
+            substrs=[
+                f"{n1.addr} is tagged",
+                "payload = 0x0000000000000012",
+                "value = 0x0000000000000001",
+                "info bits = 0x0000000000000002",
+                "class = __NSCFNumber",
+            ],
+        )
+
         self.expect(
             "lang objc tagged-pointer info bogus",
             error=True,


        


More information about the lldb-commits mailing list