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.
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:
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.
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.