From Gambit wiki
Gambit features an internal source debugger, see the User Documentation.
Also, Gambit software can be debugged through GDB . If your program would perform crashes such as segmentation faults,
Tracking down segmentation faults
Compiling Gambit for debugging purposes
Download the latest Gambit sourcecode.
Unpack it, usually you do that through executing tar xvfz gambc-v4_X_X.tgz in your shell.
- Run the configure script. It is normally compiled with --enable-single-host flipped on. If you want Gambit to dump internal messages to the file "console" in the current directory, also pass the --enable-debug parameter. To see all options, run ./configure --help.
- Edit the file makefile using your favourite editor. There are at least two rows that contain the sequence -O1 (i.e. dash O one), in the current version that's the two rows starting with FLAGS_OBJ and FLAGS_DYN. Replace -O1 with -g -O0 . The -g option will make your C compiler include debugging symbols on compilation, and the -O0 will force it not to do any optimizations on the assembly/binary code it generates, thus the mapping of rows of C/C++ code into memory addresses during program execution will be the most precise your C/C++ compiler is capable of generating.
- Compile Gambit through typing make
- If you want this Gambit to replace your current installation, run make install
Running compile-file with debuggnig options flipped on
Run Gambit in GDB
From your shell, run
GDB will start. If you want to pass gsc argument, type
set args=[the arguments]
set args=-e "(display \"test\n\")" -
To start Gambit witihn GDB, type run.
If your Gambit application crashes, you will get a prompt in GDB indicating so. To get a backtrace of the stack of your program, type bt . The backtrace should also be interesting for anyone who would assist you in finding the reason to the crash.
To quit, type quit.