Skip to content

Conversation

@kastiglione
Copy link
Contributor

@kastiglione kastiglione commented Apr 2, 2025

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.

@llvmbot
Copy link
Member

llvmbot commented Apr 2, 2025

@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/134123.diff

2 Files Affected:

  • (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (+1-1)
  • (modified) lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py (+14-1)
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..9326d50b743d2 100644
--- a/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
+++ b/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
@@ -8,10 +8,23 @@ 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")
+        # breakpoint()
+        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,

@kastiglione kastiglione merged commit 93d3775 into llvm:main Apr 2, 2025
10 checks passed
@kastiglione kastiglione deleted the lldb-Fix-tagged-pointer-info-address-parsing branch April 2, 2025 22:17
kastiglione added a commit to swiftlang/llvm-project that referenced this pull request Apr 2, 2025
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.

(cherry picked from commit 93d3775)
kastiglione added a commit to swiftlang/llvm-project that referenced this pull request Apr 3, 2025
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.

(cherry picked from commit 93d3775)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants