Skip to content

Interactive simulation with GDB

Pavel I. Kryukov edited this page Jan 12, 2019 · 19 revisions

Introduction

Build

Firstly, you have to get our GDB fork with submodule and configure it:

git clone --recursive https://github.com/MIPT-ILab/mipt-sim-gdb
cd mipt-sim-gdb
./configure --target=mips
make

First build may take long time, because external libraries are being built. Additionally, you have no libsim.a built in MIPT-MIPS, so linkage would fail. You have to build libsim.a, which contains MIPT-MIPS simulator and GDB interfaces and linked to GDB, from our submodule:

mkdir mipt-mips/cmake-build
cd mipt-mips/cmake-build
cmake ../simulator
make

If you are confused how to work with git submodules, you may have a look at this. After that, you may continue GDB build and get gdb executable in gdb/ directory

cd ../..
make

Run

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. To be continued

Clone this wiki locally