gdb and cint

From: Maxim Nikulin <nikulin_at_gorodok.net>
Date: Thu, 01 Jun 2006 23:31:14 +0700


Hi,

I'm afraid that in the discussion of debugging stand-alone programs and dynamicaly loaded libraries one quite convenient way is missed. Gdb can be attached to a running program with -p option after all plugins have been loaded.

Roland Kuhn wrote:

> The point was that I normally do not dynamically link my 'custom shared
> library', which enables me to do
>
> prompt> gdb analyze
> (gdb) br some_function
> (gdb) run -i infile -o outfile

An example with interpreter and aclic. Two shells marked as '1:' and '2:'.

1:bash$ root -l
1:root [0] .L test.cc+g
1:Info in <TUnixSystem::ACLiC>: creating shared library 
/home/nikulin/tmp/root-gdb/./test_cc.so

2:bash$ ps x | grep root.exe
2: 4413 pts/0 S+ 0:00 /mnt/soft/hep/root-5.02.00/bin/root.exe -splash -l

2:bash$ gdb -p 4413
2:...
2:(gdb) break 'test()'
2:Breakpoint 1 at 0x421e355a: file test.cc, line 4.
2:(gdb) c
2:Continuing.

1:root [1] test()

2:Breakpoint 1, test () at test.cc:4
2:4          int result = 0;
2:Current language:  auto; currently c++
2:(gdb)

Sometimes it's more tricky to set a break point inside a shared library linked to a stand-alone program.

-- 
Best regards,
Maxim Nikulin
Received on Thu Jun 01 2006 - 18:32:21 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET