- Usage
- Run
gdb-multiarchorgdbasrootuser.- e.g.,
gdb-multiarch /PATH/TO/BINARY, thenrun [ARGS].
- e.g.,
- Alternatively,
sudo gdb-multiarch /PATH/TO/BINARY, thenrun [ARGS].
- Run
- Supported architectures
- Debugger (GDB) host (= Debuggee (ELF) host)
- x86 and x64
- Possibly ARM and ARM64
- Debugger (GDB) host (= Debuggee (ELF) host)
- Notes
- The following instructions assume that you are the
rootuser. Addsudocommands as needed. - The instructions also assume that you use
gdb-multiarch. Of course, you can usegdb.
- The following instructions assume that you are the
- Usage
- Run
gdb-multiarch /PATH/TO/BINARY -p PID.
- Run
- Supported architectures
- Debugger (GDB) host (= Debuggee (ELF) host)
- x86 and x64
- Possibly ARM and ARM64
- Debugger (GDB) host (= Debuggee (ELF) host)
- Usage
- Attach from outside of Docker using
gdb-multiarch /PATH/TO/BINARY -p PID.- The
PIDrefers to the process ID visible to the host.
- The
- Attach from outside of Docker using
- Supported architectures
- Debugger (GDB) host (= Debuggee (Docker, ELF) host)
- x86 and x64
- Possibly ARM and ARM64
- Debugger (GDB) host (= Debuggee (Docker, ELF) host)
- Notes
- You can also install and use GEF inside Docker.
- However, the
--privilegedoption is required when runningdocker runordocker exec.
- Usage
- Start
gdbserver localhost:1234 /PATH/TO/BINARY [ARGS]to listen on port0.0.0.0:1234. - Attach using
gdb-multiarch -ex 'target remote <IP address>:1234'.
- Start
- Supported architectures
- Debugger (GDB) host
- x86 and x64
- Possibly ARM and ARM64
- Debugger stub (Gdbserver) host (= Debuggee (ELF) host)
- x86 and x64
- Possibly ARM and ARM64
- Debugger (GDB) host
- Usage
- Start
qemu-systemwith the-soption to listen onlocalhost:1234.- If you want to change the listening port, use the
-gdb tcp::9876option.
- If you want to change the listening port, use the
- Attach using
gdb-multiarch -ex 'target remote localhost:1234'.- Alternatively, use
gdb-multiarch -ex 'set architecture TARGET_ARCH' -ex 'target remote localhost:1234'(for old versions of QEMU).
- Alternatively, use
- Start
- Supported architectures
- Debugger (GDB) host
- x64
- Debugger stub (Qemu-system) host
- x64
- Debuggee (Qemu-system guest)
- x86, x64, ARM and ARM64
- i8086 (16-bit) is supported experimentally.
- Debugger (GDB) host
- Notes
- Most commands should work fine unless
CONFIG_RANDSTRUCT=y. - It works with any version of
qemu-system, but the latest version is recommended. - It is preferable to run
qemu-systemonlocalhost.- If you run
qemu-systemremotely (another host), you can not handle SecureWorld's memory.
- If you run
- For more information, see docs/FAQ.md.
- Most commands should work fine unless
- Usage
- Start
qemu-userwith the-g 1234option to listen onlocalhost:1234. - Attach using
gdb-multiarch /PATH/TO/BINARY -ex 'target remote localhost:1234'.- Alternatively, use
gdb-multiarch -ex 'set architecture TARGET_ARCH' -ex 'target remote localhost:1234'(for old versions of QEMU).
- Alternatively, use
- Start
- Supported architectures
- Debugger (GDB) host
- x64
- Debugger stub (Qemu-user) host
- x64
- Debuggee (ELF)
- See docs/QEMU-USER-SUPPORTED-ARCH.md for details.
- Debugger (GDB) host
- Notes
- It works with any version of
qemu-user, but the latest version is recommended.- From QEMU 8.1 onwards, the
info proc mappingscommand is supported inqemu-user, which significantly speeds up memory map generation. - However, in some architectures (e.g.,
x86_64), this may not be possible, and it will fall back to heuristic detection.
- From QEMU 8.1 onwards, the
- It is preferable to run
qemu-useronlocalhost.- If you run
qemu-userremotely (another host), you can not use memory patching.
- If you run
- It works with any version of
- Usage
- Listen using
pin -appdebug -appdebug_server_port 1234 -t obj-intel64/inscount0.so -- /PATH/TO/BINARY. - Attach using
gdb-multiarch /PATH/TO/BINARY -ex 'target remote localhost:1234'.
- Listen using
- Supported architectures
- Debugger (GDB) host
- x64
- Debugger stub (Intel Pin) host
- x64
- Debuggee (ELF)
- x86 and x64
- Debugger (GDB) host
- Note
- This runs very slowly and is not recommended.
- Usage
- Listen using
sde64 -debug -debug-port 1234 -- /PATH/TO/BINARY. - Attach using
gdb-multiarch /PATH/TO/BINARY -ex 'target remote localhost:1234'.
- Listen using
- Supported architectures
- Debugger (GDB) host
- x64
- Debugger stub (Intel SDE) host
- x64
- Debuggee (ELF)
- x86 and x64
- Debugger (GDB) host
- Note
- This runs very slowly and is not recommended.
- Usage
- Run
qltool run -f /PATH/TO/BINARY --rootfs / --gdb :1234.- Alternatively, write a harness. See here for more information.
- If the target architecture differs from the host architecture, specify the appropriate
rootfsdirectory.
- Attach using
gdb-multiarch /PATH/TO/BINARY -ex 'target remote localhost:1234'.
- Run
- Supported architectures
- Debugger (GDB) host
- x64
- Debugger stub (Qiling framework) host
- x64
- Debuggee (ELF)
- x86, x64, ARM and ARM64
- Debugger (GDB) host
- Notes
- When debugging ARM64 binaries, the flag register is not available, so branch taken/not taken detection may be incorrect.
- This is experimental support, so some commands may not work.
- Usage
- Host OS
- Configure two serial ports as named pipes in both the debugger and debuggee virtual machine settings.
- Vmware example:
- Debugger
- Use named pipe:
\\.\pipe\pipe0(Windows host) //tmp/sock0(Linux host)- Configure as
This end is the client.andThe other end is a virtual machine.
- Configure as
- Use named pipe:
\\.\pipe\pipe1(Windows host) //tmp/sock1(Linux host)- configure as
This end is the client.andThe other end is a virtual machine.
- configure as
- Use named pipe:
- Debuggee
- Use named pipe:
\\.\pipe\pipe0(Windows host) //tmp/sock0(Linux Host)- Configure as
This end is the server.andThe other end is an application.
- Configure as
- Use named pipe:
\\.\pipe\pipe1(Windows host) //tmp/sock1(Linux host)- Configure as
This end is the server.andThe other end is an application.
- Configure as
- Use named pipe:
- Debugger
- Debuggee
- Build the kernel with configurations such as
CONFIG_KGDB=y. Ubuntu supports this by default. - Edit
/etc/default/gruband appendkgdbwait kgdboc=ttyS0,115200 console=ttyS1,115200 nokaslrto the end ofGRUB_CMDLINE_LINUX_DEFAULT. - Then run
update-grub && reboot. - See official documentation for more information.
- Build the kernel with configurations such as
- Debugger
- Attach using
gdb-multiarch -ex 'target remote /dev/ttyS0'. - Connect with
screen /dev/ttyS1 115200for console access.
- Attach using
- Host OS
- Supported architectures
- Debugger (GDB) host
- x64
- Debuggee (debugged kernel)
- x64, ARM64
- Debugger (GDB) host
- Notes
- You need
gdbversion 12.x or later. - This runs very slowly over a serial interface; without a vmlinux with symbols, debugging is effectively impractical.
- The
Ctrl+Cinterrupt does not work; instead, useecho g > /proc/sysrq-triggerin the console. - Unlike qemu-system, some commands are unsupported in KGDB mode because it is still under development.
- You need
- Usage
- Host OS
- Add the following configurations to the
vmxfile.debugStub.listen.guest64 = "TRUE"debugStub.listen.guest64.remote = "TRUE"debugStub.hideBreakpoints = "TRUE"debugStub.port.guest64 = "1234"- See here.
- Start the guest OS normally.
- Add the following configurations to the
- Debugger
- Attach using
gdb-multiarch -ex 'target remote <IP address>:1234'.
- Attach using
- Host OS
- Supported architectures
- Debugger (GDB) host
- x64
- Debuggee (debugged kernel)
- x64
- Debugger (GDB) host
- Notes
- It runs faster than KGDB mode, and
Ctrl+Cinterrupt works, but it is still slow. - Access to physical memory and control registers is possible thanks to the
monitorcommand.
- It runs faster than KGDB mode, and
- Usage
- First, run
rr record /PATH/TO/BINARY. - Then, use
rr replayfor time-travel debugging.
- First, run
- Supported architectures
- Debugger (
rr) host (= Debuggee (ELF) host)- x86 and x64
- Debugger (
- Note
- This is experimental support, so some commands may not work.
- Usage
- Run
winedbg --gdb --no-start /PATH/TO/BINARYand attach usinggdb -ex 'target remote localhost:<port>'.- It is recommended to use the
--no-startoption because pressingCtrl+Cwithout--no-startwill terminategdb.
- It is recommended to use the
- Run
- Supported architectures
- Debugger (GDB) host
- x64
- Debugger stub (
winedbg) host- x64
- Debuggee (PE)
- x86 and x64
- Debugger (GDB) host
- Notes
- You must run
winedbgonlocalhost. - This is experimental support, so some commands may not work.
- You must run
- Usage
- Start as
emulator -avd <AVD_NAME> -no-audio -no-snapshot -qemu -sto listen onlocalhost:1234.- If
-no-audio -no-snapshotare not necessary, you can remove them. - Available
<AVD_NAME>values can be obtained withemulator -list-avds.
- If
- Attach using
gdb-multiarch -ex 'set architecture i386:x86-64' -ex 'target remote localhost:1234'.
- Start as
- Supported architectures
- Debugger (GDB) host
- x64
- Debugger stub (Qemu-system) host
- x64
- Debuggee (Qemu-system guest)
- x64
- Possibly x86, ARM and ARM64
- Debugger (GDB) host
- Notes
- This method sometimes fails.
- For more information, see docs/FAQ.md.
- If an issue occurs, try closing
gdband reconnecting.
- To connect from another machine, specify the IP address.
gdb-multiarch -ex 'set architecture i386:x86-64' -ex 'target remote <Android Studio host machine's IP address>:1234'.
- This method sometimes fails.
- Usage
- Setup
adbsettings.- Run
adb rootif necessary. - Use
adb forward tcp:9999 tcp:9999for port forwarding.
- Run
- Push the statically built
gdbserverto the Android device.adb push gdbserver-static /data/local/tmp.adb shell chmod +x /data/local/tmp/gdbserver-static.
- Start
gdbserver.adb shell /data/local/tmp/gdbserver-static localhost:9999 /PATH/TO/BINARY.
- Attach using
gdb-multiarch 'target remote localhost:9999'.
- Setup
- Supported architectures
- Debugger (GDB) host
- x64
- Debugger stub (Gdbserver) host (= Debuggee (ELF) host)
- x64
- Possibly x86, ARM and ARM64
- Debugger (GDB) host
- Notes
- To connect from another machine, you can forward the port further.
- Run
socat TCP-LISTEN:9998,fork,reuseaddr TCP-CONNECT:localhost:9999on theAndroid Studiohost machine. - Attach using
gdb-multiarch 'target remote <Android Studio host machine's IP address>:9998'from another machine.
- Run
- To connect from another machine, you can forward the port further.