unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Loading debug symbols for load-foreign-library
@ 2024-09-11 22:15 Artyom Bologov
  2024-09-12  4:28 ` tomas
  0 siblings, 1 reply; 2+ messages in thread
From: Artyom Bologov @ 2024-09-11 22:15 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 1141 bytes --]

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.


[-- Attachment #2: GSL bindings executable that works with symbols --]
[-- Type: text/plain, Size: 1281 bytes --]

#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(""); */
}

[-- Attachment #3: Type: text/plain, Size: 53 bytes --]


Thanks a lot,
-- 
Artyom Bologov
https://aartaka.me

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Loading debug symbols for load-foreign-library
  2024-09-11 22:15 Loading debug symbols for load-foreign-library Artyom Bologov
@ 2024-09-12  4:28 ` tomas
  0 siblings, 0 replies; 2+ messages in thread
From: tomas @ 2024-09-12  4:28 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]

On Thu, Sep 12, 2024 at 02:15:48AM +0400, Artyom Bologov wrote:
> 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?

AFAIK, gdb "just" has to find the .so in question (provided that this
has debug symbols, of course).

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-12  4:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-11 22:15 Loading debug symbols for load-foreign-library Artyom Bologov
2024-09-12  4:28 ` tomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).