Skip to content

Interactive simulation with GDB

Konstantin (Vyacheslav) Kompan edited this page Sep 7, 2018 · 19 revisions

Introduction

Build

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

git clone https://github.com/MIPT-ILab/mipt-sim-gdb
cd mipt-sim-gdb
git submodule init
git submodule update
./configure --target=mips

If you are confused how to work with git submodules, you may have a look at this. Then, you have to build libsim.a, which contains MIPT-MIPS simulator and GDB interfaces and linked to GDB:

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

You may check if libsim.a exists in mipt-mips/gdb/bin. After that, you can build GDB:

cd ../../
make

First build may take long time, because external libraries are being built. Next time you may call make from gdb/ directory and it would only re-link files. Finally, you should have gdb executable in gdb/ directory.

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

Clone this wiki locally