Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Using the gdb server to debug harvey processes

Graham MacDonald edited this page Mar 26, 2017 · 8 revisions

Introduction

You can debug processes running harvey using gdb, remotely.

As an example, let's run the command dd and attach to it.

Running in qemu

The GO9PTERM and GO9PCPU scripts in the util folder both specify the -s option. This is shorthand for -gdb tcp::1234 and will allow us to connect from the host to the guest via port 1234.

  1. On the guest (harvey):

    1. Open 2 rio windows
    2. In one, run dd
    3. In the other run ps to get the process ID...
    4. Next, run gdbserver -p <processid>
  2. On the host:

    1. Run gdb amd64/bin/dd
    2. Ensure the architecture is set to i386:x86-64. You can check with show architecture and set with set architecture i386:x86-64. (You may not need this step).
    3. In gdb, enter target remote localhost:1666
    4. At this point you should have connected. To continue executing, enter c.
  3. On the guest again:

    1. 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 Development

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 before target remote....
  • Or enable gdbserver logging by creating the file sys/log/gdbserver.