Debugging Issues with GDB on ARM Macs in Intel Docker Containers

When running GDB inside an Intel-based Docker container on Apple Silicon Macs, you may encounter the following error:

1
2
3
4
warning: linux_ptrace_test_ret_to_nx: Cannot PTRACE_GETREGS: Input/output error
warning: linux_ptrace_test_ret_to_nx: PC 0x1 is neither near return address 0x7ffffffc7000 nor is the return instruction 0x5555558faf61!
Couldn't get CS register: Input/output error.
Exception occurred: Error: Couldn't get registers: Input/output error. (<class 'gdb.error'>)

This issue arises because GDB relies on ptrace system calls to inspect and control the execution of programs. However, when running an Intel-based Docker container on an ARM-based Mac, the emulation layer (e.g., QEMU) may not fully support all ptrace operations, leading to these errors.

Workarounds

  1. Run GDB on a Native Intel Machine
    If you have access to an Intel-based machine, run your debugging tasks there to avoid emulation-related issues.

  2. Monitor Updates
    Keep an eye on updates to QEMU, Docker, and GDB, as improvements in these tools may eventually resolve the issue.

For further discussion, see the related GitHub thread: Orbstack Discussion #27.

If none of these solutions work for your scenario, please contact the ABE Teaching Team for additional assistance.