public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* using continue from .gdbinit
@ 2012-03-12  1:00 Bob
  2012-03-12  7:39 ` Jan Kratochvil
  0 siblings, 1 reply; 2+ messages in thread
From: Bob @ 2012-03-12  1:00 UTC (permalink / raw)
  To: gdb

I am trying to debug a unix daemon which is spawned by a master process.
The master process is configured to cause children it forks off to sleep 
for 15 seconds which is long enough to start gdb on them.

I have a script which tails the log output by the master looking for a 
line which indicates it has spawned off a child.  Once this line is 
found the script launches an xterm like this.

xterm -T {} -e gdb /usr/lib/cyrus-imapd/imapd {}

where {} is replaced by the pid.

My .gdbinit file has the following:
set breakpoint pending on
directory /home/xxx/src
b imapd.c:5171
b imapd.c:5242
continue

When gdb is invoked I would like the continue command at the bottom of 
the init file to cause execution to resume but it appears the continue 
is executed by gdb before the daemon is loaded.

In the xterm I have to manually type "c" to cause gdb to continue.  This 
works since by the time I manually type "c" the program has already been 
loaded.  I want the session to be interactive and to stop at the 
breakpoints I have set.  Is there a way to automatically cause gdb to 
continue after the daemon has been loaded?

GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-37.el5_7.1)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Really redefine built-in command "frame"? (y or n) [answered Y; input 
not from terminal]
Really redefine built-in command "thread"? (y or n) [answered Y; input 
not from terminal]
No symbol table is loaded.  Use the "file" command.
Breakpoint 1 (imapd.c:5171) pending.
No symbol table is loaded.  Use the "file" command.
Breakpoint 2 (imapd.c:5242) pending.
/root/.gdbinit:297: Error in sourced command file:
No executable file specified.
Use the "file" or "exec-file" command.
Reading symbols from /usr/lib/cyrus-imapd/imapd...done.
Attaching to program: /usr/lib/cyrus-imapd/imapd, process 25831
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols 
found)...done.

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

* Re: using continue from .gdbinit
  2012-03-12  1:00 using continue from .gdbinit Bob
@ 2012-03-12  7:39 ` Jan Kratochvil
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kratochvil @ 2012-03-12  7:39 UTC (permalink / raw)
  To: Bob; +Cc: gdb

On Mon, 12 Mar 2012 02:00:13 +0100, Bob wrote:
> My .gdbinit file has the following:
+
> but it appears the continue is executed by gdb before the daemon is loaded.

Please read: $ info '(gdb)Startup'

I guess yout .gdbinit is in $HOME directory, you should place it to current
directory somewhere else then $HOME (even if $HOME is your current directory).

Primarily I would rather recomment to call that file like myscript and use:

xterm -T {} -e gdb /usr/lib/cyrus-imapd/imapd {} -x /tmp/myscript

Without relying on .gdbinit files which may be tricky.


Regards,
Jan

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

end of thread, other threads:[~2012-03-12  7:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-12  1:00 using continue from .gdbinit Bob
2012-03-12  7:39 ` Jan Kratochvil

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).