GDB Server Capability
The Debugger Capability does not directly target the debugging of the simulator, but the debugging of the simulated program. This allows to plug a real debugger to the simulated binary, to run it step by step for example.
Description
The GNU Debugger allows you to see what is going on `inside’ another program while it executes – or what another program was doing at the moment it crashed.
GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:
- Start your program, specifying anything that might affect its behavior.
- Make your program stop on specified conditions.
- Examine what has happened, when your program has stopped.
- Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.
What the GNU Debugger Capability propose is to be able to run gdb on the program simualted in the simulator pitoling it through a GDB server launched on the native host.
This GDB will affect the target architecture modifying for instance the values corresponding to the register bank from the CPU module, or the values stored in the various memory modules.
See the gdb manual for more details on the GDB Server functionality.
Interface
Plugging the debugger to your simulator
First, you need to add the dedicated includes / using in your file header.
#include <plugins/debug/gdb_server.hh> using full_system::plugins::debug::GDBServer;
Next, you need to instantiate and parameterize the GDB server capability:
GDBServer<address_t> gdb_server("gdb-server"); gdb_server["tcp-port"] = 3111; gdb_server["architecture-description-filename"] = "gdb_powerpc.xml";
Last, you need to connect the debugger to the main processor:
cpu.cpu_emulator->debugger >> gdb_server->exp;
Finaly, start the simulator, it will hang on, waiting for the gdb server to connect and to send commands. Use the GDB Server as usual.