Skip to content

Commit 3f3fde0

Browse files
authored
[lldb] Fix tagged-pointer info address parsing (llvm#134123) (#10409)
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)
1 parent b7248c7 commit 3f3fde0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
10601060
continue;
10611061

10621062
Status error;
1063-
lldb::addr_t arg_addr = OptionArgParser::ToAddress(
1063+
lldb::addr_t arg_addr = OptionArgParser::ToRawAddress(
10641064
&exe_ctx, arg_str, LLDB_INVALID_ADDRESS, &error);
10651065
if (arg_addr == 0 || arg_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
10661066
result.AppendErrorWithFormatv(

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,22 @@ class TestTaggedPointerCommand(TestBase):
88
@no_debug_info_test
99
def test(self):
1010
self.build()
11-
lldbutil.run_to_source_breakpoint(
11+
_, _, thread, _ = lldbutil.run_to_source_breakpoint(
1212
self, "// break here", lldb.SBFileSpec("main.m")
1313
)
1414

15+
n1 = thread.GetSelectedFrame().FindVariable("n1")
16+
self.expect(
17+
f"lang objc tagged-pointer info {n1.addr}",
18+
substrs=[
19+
f"{n1.addr} is tagged",
20+
"payload = 0x0000000000000012",
21+
"value = 0x0000000000000001",
22+
"info bits = 0x0000000000000002",
23+
"class = __NSCFNumber",
24+
],
25+
)
26+
1527
self.expect(
1628
"lang objc tagged-pointer info bogus",
1729
error=True,

0 commit comments

Comments
 (0)