issues met when debugging an x86_64 emulation process at the arm64 instruction-level
See original GitHub issueWhen we follow https://ffri.github.io/ProjectChampollion/appendix/ to debug at arm64 instruction-level debug, there are many strange issues, such as:
- If a watchpoint is set, rosetta runtime will fail with “rosetta error: failed to allocate vm space for aot”. An example session follows:
lisa@jjl bt % lldb -- ./runner ./float
(lldb) target create "./runner"
Current executable set to '/Users/lisa/bt/runner' (arm64).
(lldb) settings set -- target.run-args "./float"
(lldb) r
Process 9182 launched: '/Users/lisa/bt/runner' (arm64)
Process 9182 stopped
* thread #2, stop reason = exec
frame #0: 0x00007ffdfffbc3ec runtime`_mh_execute_header + 17388
runtime`_mh_execute_header:
-> 0x7ffdfffbc3ec <+17388>: mov x19, sp
0x7ffdfffbc3f0 <+17392>: and sp, x19, #0xfffffffffffffff0
0x7ffdfffbc3f4 <+17396>: mov x29, sp
0x7ffdfffbc3f8 <+17400>: ldr x20, [x19, #0x20]
Target 0: (runtime) stopped.
(lldb) watchpoint set expression 0x7ffdfffbc3f0 ====> set a watchpoint that won't hit
Watchpoint created: Watchpoint 1: addr = 0x7ffdfffbc3f0 size = 8 state = enabled ...
new value: -7998388550590730625
(lldb) c
Process 9182 resuming
rosetta error: failed to allocate vm space for aot =========> will cause such failure
Process 9182 stopped
* thread #2, stop reason = signal SIGTRAP
frame #0: 0x00007ffdfffd4d38 runtime`_mh_execute_header + 118072
runtime`_mh_execute_header:
-> 0x7ffdfffd4d38 <+118072>: brk #0x1
0x7ffdfffd4d3c <+118076>: stp x20, x19, [sp, #-0x20]!
0x7ffdfffd4d40 <+118080>: stp x29, x30, [sp, #0x10]
0x7ffdfffd4d44 <+118084>: add x29, sp, #0x10 ; =0x10
Target 0: (runtime) stopped.
(lldb)
- command might struck. e.g.
isa@jjl bt % lldb -- ./runner ./lazy ===> lazy has a dead loop in main()
(lldb) target create "./runner"
Current executable set to '/Users/lisa/bt/runner' (arm64).
(lldb) settings set -- target.run-args "./lazy"
(lldb) r
Process 9235 launched: '/Users/lisa/bt/runner' (arm64)
Process 9235 stopped
* thread #2, stop reason = exec
frame #0: 0x00007ffdfffbc3ec runtime`_mh_execute_header + 17388
runtime`_mh_execute_header:
-> 0x7ffdfffbc3ec <+17388>: mov x19, sp
0x7ffdfffbc3f0 <+17392>: and sp, x19, #0xfffffffffffffff0
0x7ffdfffbc3f4 <+17396>: mov x29, sp
0x7ffdfffbc3f8 <+17400>: ldr x20, [x19, #0x20]
Target 0: (runtime) stopped.
(lldb) c
Process 9235 resuming
Process 9235 stopped ====> type ctrl+c to stop in the main function of lazy
* thread #2, stop reason = signal SIGSTOP
frame #0: 0x0000000100011018
-> 0x100011018: ldur w0, [x5, #-0x8]
0x10001101c: cmp w0, #0x0 ; =0x0
0x100011020: b.eq 0x100011028
0x100011024: b 0x100011018
Target 0: (runtime) stopped.
(lldb) si ========> stuck here
and so on.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Problem when trying to debug with lldb on new arm64 M1
I initially obtained this error: error: process exited with status -1 (developer mode is not enabled on this machine and this is a...
Read more >Appendix - Project Champollion
In Appendix, I will give you some tips for analyzing Rosetta 2. Debugging an x86_64 emulation process at the arm64 instruction-level¶. When analyzing...
Read more >Testing R on Emulated Platforms - The R Blog
Recently I wanted to test R on 64-bit ARM (Aarch64) and on Power. It turned out easy in QEMU, an instruction-level emulator, running...
Read more >Challenges in Firmware Re-Hosting, Emulation, and Analysis
Over time, manufacturers started creating hardware emulators to allow software development before the hardware production; decreasing product development time.
Read more >Troubleshoot known issues with Android Emulator
Check for adequate disk space · Antivirus software · HAXM on unsupported versions of macOS · Android Emulator runs slowly after an update...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh, I was mostly commenting in general terms–basically, recommending you use commands like
register read
and such that don’t evaluate expressions. Unfortunately thewatchpoint
command does, so I wasn’t able to use it directly. There’s a Python API, but:…it seems to broken with the version of LLDB that’s in Xcode. One built from source seems to work, but you’ll run into issues once Rosetta sets up its exception server I believe, the same as breakpoints.
My understanding of this issue is that LLDB creates mappings in the target process when trying to evaluate an expression, which makes Rosetta upset (you’ll see similar behavior if you use the
expression
command). I’ve had luck using the “lower-level” commands that directly read registers and take addresses.