This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Using the gdb server to debug harvey processes
ron minnich edited this page Mar 28, 2017
·
8 revisions
You can debug processes running harvey using gdb, remotely. This is not working well yet, and we need help. Hint, hint.
gdbserver currently defaults to port 1666. If you are running our QEMU script they forward that port. If you are running qemu on your own, be sure to forward that port. See the scripts to see how that's done.
As an example, let's run the command dd
and attach to it.
-
On the guest (harvey):
- Open 2 rio windows
- In one, run
dd
- In the other run
ps
to get the process ID... - Next, run
gdbserver -p <processid>
You can optionally add '-d' and gdbserver will print debugging messages.
-
On the host:
- Run
gdb amd64/bin/dd
- Ensure the architecture is set to
i386:x86-64
. You can check withshow architecture
and set withset architecture i386:x86-64
. (You probably don't need this step but at least show it to make sure). - In gdb, enter
target remote localhost:1666
- At this point you should have connected. To continue executing, enter
c
.
- Run
-
On the guest again:
- Hit return in the dd window. This allows the gdbserver to get control, since dd will run and do a system call.
- Now you can debug. Interact with the application, e.g. in the window running dd, hit return. Add breakpoints from the gdb command line, etc.
gdbserver is still under development. It's missing lots of features, and has bugs. It's very useful to be able to see the packets going between the gdb client and gdbserver. You can see this in two ways.
- Either turn on debug info in gdb, which will show all packets, by entering
set debug remote 1
beforetarget remote...
. - And/or enable gdbserver logging by creating the file
sys/log/gdbserver
.