You can also attach to a running program using the gdb "attach" command.
If your program can run in background, you can do this. Interactive programs can be debugged using different xterminals.
$ yourprogram &
[1] <pid>
$ gdb
(gdb) attach <pid>
-Clark
On Thu, 2006-06-01 at 23:31 +0700, Maxim Nikulin wrote:
> 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.
> 
-- Clark McGrew Univ. at Stony Brook, Physics and Astronomy <clark.mcgrew_at_stonybrook.edu> 631-632-8299Received on Thu Jun 01 2006 - 23:01:47 MEST
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET