Web lists-archives.com

Re: problem when debug glib source code with gdb




On 24 November 2015 at 02:45, 落痕 <losemyheaven@xxxxxx> wrote:
> Hi,
>   Thanks for your suggestion.
>   I tried, but it doesn't work.

Perhaps you did not set LD_LIBRARY_PATH? On Ubuntu I use these steps:

$ cd ~/packages/gtk/glib-2.46.1
$ CFLAGS=-g ./configure
$ make
$ make install

This will install glib to /usr/local. Now make a test program:

$ cd
$ more test.c
#include <glib.h>

int
main( int argc, char **argv )
{
    GHashTable *table = g_hash_table_new( g_str_hash, g_str_equal );

    return( 0 );
}

Now compile it. You need to make sure pkg-config is seeing your new
home-made glib:

$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ pkg-config glib-2.0 --cflags
-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include

Yes, it is seeing the new one in /usr/local. Now compile:

$ gcc test.c `pkg-config glib-2.0 --cflags --libs`

At run-time it will pick up the system glib library. You need to set
LD_LIBRARY_PATH to make it use your new one.

$ export LD_LIBRARY_PATH=/usr/local/lib
$ ldd a.out | grep glib
    libglib-2.0.so.0 => /usr/local/lib/libglib-2.0.so.0 (0x00007fde5dd6b000)

Now run it.

john@kiwi:~/try$ gdb a.out
Reading symbols from a.out...(no debugging symbols found)...done.
(gdb) break g_hash_table_new
Breakpoint 1 at 0x400620
(gdb) run
Starting program: /home/john/try/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, g_hash_table_new (hash_func=0x7ffff7ab174c <g_str_hash>,
    key_equal_func=0x7ffff7ab170f <g_str_equal>) at ghash.c:674
674      return g_hash_table_new_full (hash_func, key_equal_func, NULL, NULL);
(gdb)

John
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list