Email or username:

Password:

Forgot your password?
Grigory Shepelev

Trying to figure out how to work with #guile #scheme in #gdb (gnu debugger) today for the most part of the day. Investigating sigsegv error in the scheme project of mine. Found no examples.

As far as I've got #gdb has integration with guile but it only allows to extend itself with guile, not call guile programs with ease and repl inside gdb... Maybe I am wrong. Continue research.

9 comments
Ramin Honary
> "Trying to figure out how to work with #guile #scheme in #gdb (gnu debugger) today for the most part of the day. Investigating sigsegv error in the scheme project of mine. Found no examples."

@shegeley you should probably install the developer build of Guile, something like "guile-3.0-dev" in the Debian (and derivative) Linux repositories.

Then what I do is actually run the whole Guile interpreter in GDB. Here is a script I use, I call it "gdb-guile.sh":

#! /bin/sh
gdb \
  -ex 'handle SIGXCPU nostop' \
  -ex 'handle SIGPWR nostop' \
  -ex 'run' \
  --args \
    guile "${@}";

To run it, I simply type

./gdb-guile.sh my-program.scm --args=to --my=program

If you use Emacs and Geiser, you can try setting the "geiser-guile-binary" variable to the full path of "gdb-guile.sh", I ususally set it in my ".dir-locals.el".

> "Trying to figure out how to work with #guile #scheme in #gdb (gnu debugger) today for the most part of the day. Investigating sigsegv error in the scheme project of mine. Found no examples."

@shegeley you should probably install the developer build of Guile, something like "guile-3.0-dev" in the Debian (and derivative) Linux repositories.

Grigory Shepelev

@ramin_hal9001 thanks a lot. will try today or tomorrow morning

Grigory Shepelev

@ramin_hal9001 I wonder if I can do that with guile-ares?

I'd like to plug something like:

-- args \
guile -L ./src -e "((@ (nrepl\ server) run-nrepl-server) #:port 7888)" (if that's a good idea)
but it expects file.

Grigory Shepelev

@ramin_hal9001 and how do you "switch" between gdb and guile when it's running in ddb?

Grigory Shepelev

@ramin_hal9001 I don't understand why it won't load symbols

Ramin Honary
> "I don't understand why it won't load symbols"

@shegeley do you mean GDB will not load the debugging symbols for your C program? I assume your are building a dynamically linked library with the GCC "-fPIC -shared" options?

So I don't think ".so" files contain debug symbols unless you also pass the "-ggdb" option. I can't remember well, but I think it is something like:

gcc -fPIC -shared -ggdb my-library.c -o my-library.so

Here is the relevant section of the GCC manual.

Grigory Shepelev

@ramin_hal9001 no. i mean how to I run gcc with guile script and get symbols for it in a sigsegv backtrace

Ramin Honary
> "i mean how to I run gcc with guile script and get symbols for it in a sigsegv backtrace"

@shegeley you should make sure that the ".so" files being loaded by Guile have their debugging symbols available. If for example you are linking against "libgtk-3.so" and the crash occurs in this file, the symbol table is probably not available unless you install those from your package manager, or build the whole Gtk3 library yourself with the "-g" flag included in your "CC_FLAGS" environment setting when running the "./configure" autoconf script for Gtk.

I am pretty sure you can accomplish this with the Guix package manager, but I am not sure exactly how.

> "i mean how to I run gcc with guile script and get symbols for it in a sigsegv backtrace"

@shegeley you should make sure that the ".so" files being loaded by Guile have their debugging symbols available. If for example you are linking against "libgtk-3.so" and the crash occurs in this file, the symbol table is probably not available unless you install those from your package manager, or build the whole Gtk3 library yourself with the "-g" flag included in your "CC_FLAGS" environment setting when running the "

Justice for Sepulveda Martinez

@shegeley new reply to a couple weeks old post, but .....depending on what you want to do you can run more or less full guile programs under GDB's extension system, however there are parts, for example calling DISPLAY that don't work. Multithreading is difficult. Any TUI libraries are non-starters (that I know!) like using guile-ncurses. I've got a guile extension that I've been on and off working on for several years now, and have run up against a number of limitations in the API, but I've still found it to be quite useful. Here's a link to the only other guile extension I know of, indeed the only guile extension published out in the wild, I thankfully forked it before it was taken private again github.com/dtpeters/gheap-jema
You might reach out to the author and see what his experiences were, I'd be very curious to hear what he says if you are able to make that connection.

@shegeley new reply to a couple weeks old post, but .....depending on what you want to do you can run more or less full guile programs under GDB's extension system, however there are parts, for example calling DISPLAY that don't work. Multithreading is difficult. Any TUI libraries are non-starters (that I know!) like using guile-ncurses. I've got a guile extension that I've been on and off working on for several years now, and have run up against a number of limitations in the API, but I've still...

Go Up