-
Notifications
You must be signed in to change notification settings - Fork 141
Interactive simulation with GDB
GDB provides a lot of facilities to control execution in interactive mode: read and write memory, fetch and store register values, redirect execution flow. However, "bare metal" is not the only option — simulators can be controlled as well, and MIPT-MIPS is not an exception. Instead of writing our own driver of interactive simulation, we are fully utilizing GDB, obtaining its well-know CLI interfaces and GUI frontends.
Firstly, you have to get GDB 8.3 sources and build MIPS GDB:
cd /path/to/gdb/sources
./configure --target=mipsel-unknown-linux
make
NB: target must match the target of binutils/gcc you use to build binaries! |
---|
First build may take long time, because external libraries are being built. Additionally, you have libsim.a
built with default simulator (not MIPT-MIPS). You have to build libsim.a
, which contains MIPT-MIPS simulator and GDB interfaces and linked to GDB, from our repository
mkdir mipt-mips/cmake-build
cd mipt-mips/cmake-build
cmake ../simulator -DGDB_SRC_PATH=/path/to/gdb/sources
make
After that, you may link GDB with MIPT-MIPS and get gdb
executable in gdb/
directory
cd /path/to/gdb/sources/gdb
make gdb
Unlike usual debugging with GDB, some additional steps are required to use the simulator. So, you launch GDB with some executable file:
./gdb -q /path/to/file
target sim [simulator-args]
load
target sim
tells GDB that we are going to execute program via built-in simulator (in our case it's MIPT-MIPS). You may pass arguments to simulator as well if needed. load
loads program to simulator memory. If target sim
fails with "Undefined target command: sim", make sure you are running the GDB you built with simulator, not the system installed one.
Workflow is perfectly described in this manual for the case of ARM simulation; however, there is no much difference for the MIPS case.
MIPT-V / MIPT-MIPS — Cycle-accurate pre-silicon simulation.