Chapter 5: Expression - `error: cannot find '$R1' in scope`

I’m trying to use the allocated variables given after p self ($R1 for instance), but after resuming the process and then pausing it again, I cannot access to $R1.

(lldb) p self
(Signals.MainContainerViewController) $R1 = 0x000000012ba19dc0 {
...

(lldb) po $R1
<Signals.MainContainerViewController: 0x12ba19dc0>

(lldb) c
Process 88944 resuming
(lldb) expression -O -l swift -- $R1
warning: Module "/usr/lib/system/libsystem_kernel.dylib" uses triple "arm64-apple-macosx13.4.0", which is not compatible with the target triple "arm64-apple-ios16.0.0-simulator". Enabling per-module Swift scratch context.
error: expression failed to parse:
error: <EXPR>:3:1: error: cannot find '$R1' in scope
$R1
^~~

(lldb) 

Does someone have an idea?

  • macOS: 13.4.1 (22F82)
  • Xcode Version 14.3.1

I tried outside of Xcode, attaching the debugger to the Notes app

(lldb) b -[NSView hitTest:]
Breakpoint 1: where = AppKit`-[NSView hitTest:], address = 0x0000000183857e18

(lldb) process launch -e /dev/null --
Process 4125 launched: '/System/Applications/Notes.app/Contents/MacOS/Notes' (arm64e)
Process 4125 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x000000018c093e18 AppKit` -[NSView hitTest:]
AppKit`-[NSView hitTest:]:
->  0x18c093e18 <+0>:  pacibsp
    0x18c093e1c <+4>:  sub    sp, sp, #0x70
    0x18c093e20 <+8>:  stp    x24, x23, [sp, #0x30]
    0x18c093e24 <+12>: stp    x22, x21, [sp, #0x40]
    0x18c093e28 <+16>: stp    x20, x19, [sp, #0x50]
    0x18c093e2c <+20>: stp    x29, x30, [sp, #0x60]
    0x18c093e30 <+24>: add    x29, sp, #0x60
    0x18c093e34 <+28>: mov    x19, x0
Target 0: (Notes) stopped.

(lldb) p $arg1
(unsigned long) $2 = 4312972736
(lldb) po $2
<NSTitlebarContainerView: 0x10112bdc0>

(lldb) c
Process 4125 resuming
-- later 
Process 4125 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x000000018c093e18 AppKit` -[NSView hitTest:]
AppKit`-[NSView hitTest:]:
->  0x18c093e18 <+0>:  pacibsp
    0x18c093e1c <+4>:  sub    sp, sp, #0x70
    0x18c093e20 <+8>:  stp    x24, x23, [sp, #0x30]
    0x18c093e24 <+12>: stp    x22, x21, [sp, #0x40]
    0x18c093e28 <+16>: stp    x20, x19, [sp, #0x50]
    0x18c093e2c <+20>: stp    x29, x30, [sp, #0x60]
    0x18c093e30 <+24>: add    x29, sp, #0x60
    0x18c093e34 <+28>: mov    x19, x0
Target 0: (Notes) stopped.
(lldb) po $2
<NSTitlebarContainerView: 0x10112bdc0>
(lldb) c

-- later, after pausing --

(lldb) po $2
<NSTitlebarContainerView: 0x10112bdc0>

This topic was automatically closed after 166 days. New replies are no longer allowed.