Loading debug symbols for load-foreign-library

Artyom Bologov <[email protected]>
Newsgroups gmane.lisp.guile.user
Message-ID <[email protected]>
Hi y'all,

I'm working on a Guile-based tool (https://github.com/aartaka/mgamma)
reliant on (system foreign-library) FFI. So I'm doing multiple
load-foreign-library for the libraries used. But when I need to debug
the code at the intersection of Guile and these libraries in GDB, I
can't get debug symbols.

I'm on Guix, which complicates things a bit. I've followed the
instructions for GDB setup from
https://guix.gnu.org/manual/en/html_node/Separate-Debug-Info.html It
makes C programs I compile debuggable with all the symbols present. But
it doesn't propagate to Guile somewhy, even though I'm loading the same
libraries C programs are linked against.

The only thing that differs between C and Guile seems to be dlopen/dlsym
used in Guile instead of linking libraries into the binary C compiler
does. Might this be the reason? How do I fix that and get my debug
symbols, if anyhow?

See
https://github.com/aartaka/guile-gsl/blob/608200e604fe910fc7cd9e23675fe739d62990fd/modules/gsl/core.scm#L14
for an example of how I'm binding libraries on Guile side, and the
attached file for the C program that ends up with debug symbols in GDB.


Thanks a lot,
-- 
Artyom Bologov
https://aartaka.me
gsl.c (text/plain, 1.3 KB)
#include <stdio.h>
#include "gsl/gsl_vector.h"
#include "gsl/gsl_matrix.h"
#include "gsl/gsl_eigen.h"

int main (void)
{
        double G[284*284] = {0};
        char buf[5000];
        FILE *f = fopen("g.txt", "read");
        for (int i = 0; i < 284; ++i)
                for (int j = 0; j < 284; ++j)
                        G[i*284 + j] = (fscanf(f, "%s", buf),
                                        atof(buf));
        gsl_matrix_view g = gsl_matrix_view_array(G, 284, 284);
        gsl_vector *eval = gsl_vector_alloc(284);
        gsl_matrix *evec = gsl_matrix_alloc(284, 284);
        gsl_eigen_symmv_workspace *workspace = gsl_eigen_symmv_alloc(284);
        gsl_eigen_symmv(&g.matrix, eval, evec, workspace);
        gsl_eigen_symmv_sort(eval, evec, GSL_EIGEN_SORT_VAL_ASC);
        for (int i = 283; i > 240; --i)
                printf("%f ", gsl_vector_get(eval, i));
        puts("");
        for (int i = 283; i > 240; --i)
                printf("%f ", gsl_matrix_get(evec, 0, i));
        puts("");
        /* for (int i = 0; i < 30; ++i) */
        /*         printf("%f ", gsl_vector_get(eval, i)); */
        /* puts(""); */
        /* for (int i = 0; i < 30; ++i) */
        /*         printf("%f ", gsl_matrix_get(evec, 0, i)); */
        /* puts(""); */
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.