0

I have previously used lldb to print structures like NSRect or NSSize of 3rd party processes without issues. But I am struggling in modern versions of Xcode to inspect them. Namely since the introduction of Xcode 15 and dwim-print I am struggling with printing structures. I want to state everything works on binaries that were compiled by me. However if I attach to another processes such as PhotoBoot.app (SIP disabled) I cannot even print frame on NSWindow. Yet it is nicely shown by Xcode view hierarchy.

(lldb) e @import AppKit
(lldb) po (NSRect)[[[NSApp windows] firstObject] frame]
error: <user expression 16>:1:9: attempt to use a deleted function
1 | (NSRect)[[[NSApp windows] firstObject] frame]
|         ^
note: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCGTypes.h:77:13: destructor of 'CGRect' is implicitly deleted because field 'origin' has no destructor
   77 |     CGPoint origin;
|           

lldb

I have found workarounds but I am confused on how to use dwim-print

Wrapping it in NSValue (boxable)

(lldb) po [[(NSWindow*)0x13c606800 valueForKey:@"frame"] description]
NSRect: {{434, 480}, {692, 550}}

Manually finding offset of CGRect structure within NSWindow class

(lldb) p (ptrdiff_t)ivar_getOffset((struct Ivar *)class_getInstanceVariable([NSWindow class], "_frame"))
(ptrdiff_t) 224
(lldb) p (CGRect *)(0x13c606800 + 224)
(CGRect *) (origin = (x = 434, y = 480), size = (width = 692, height = 550))

Please do not suggest NSStringFromRect or casting to NSWindow as it doesn't work as well. I repeat everything works if I run my own app (doesn't work in 3rd party apps.)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.