Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* newbie question: debug a multiple processes server program
@ 2007-02-09 22:18 PoWah Wong
  2007-02-09 22:27 ` Daniel Jacobowitz
  2007-02-09 22:38 ` Nick Roberts
  0 siblings, 2 replies; 3+ messages in thread
From: PoWah Wong @ 2007-02-09 22:18 UTC (permalink / raw)
  To: gdb

I want to debug a server program testd which calls fork() to create multiple processes.
testd is created as follow:
g++ -g -o linux/util.o src/util.c
...
ar -r linux/libUtilLib2.a linux/util.o ...
g++ -lpthread -ldl -g -o linux/testd  linux/libUtilLib2.a ...

testd is started as follows:
# linux/testd
# ps -ef|grep test
root     31629     1  1 16:51 ?        00:00:00 linux/testd
root     31630 31629  0 16:51 ?        00:00:00 linux/testd
root     31631 31630  0 16:51 ?        00:00:00 linux/testd
root     31632 31630  0 16:51 ?        00:00:00 linux/testd
root     31633 31630  0 16:51 ?        00:00:00 linux/testd
root     31634 31630  0 16:51 ?        00:00:00 linux/testd
root     31635 31630  0 16:51 ?        00:00:00 linux/testd
root     31636 31630  0 16:51 ?        00:00:00 linux/testd
root     31637 31630  0 16:51 ?        00:00:00 linux/testd
root     31638 31630  0 16:51 ?        00:00:00 linux/testd
root     31639 31630  0 16:51 ?        00:00:00 linux/testd
root     31640 31630  0 16:51 ?        00:00:00 linux/testd

The program testd has a bug in the foo() of the util.c in the src directory.
What is the best way to setup gdb to debug this program?

This is what I am think, please comment:
- cd src
- Start testd by ../linux/testd
- Start gdb
- Load debugging info
  symbol-file ../linux/testd
- Attach to the parent process (i.e. pid 31629)
- set breakpoint in the foo() of the util.c
  b foo
- Resume testd execution
  run
- Execute the client program
- Wait for breakpoint to occur



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com


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

* Re: newbie question: debug a multiple processes server program
  2007-02-09 22:18 newbie question: debug a multiple processes server program PoWah Wong
@ 2007-02-09 22:27 ` Daniel Jacobowitz
  2007-02-09 22:38 ` Nick Roberts
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2007-02-09 22:27 UTC (permalink / raw)
  To: PoWah Wong; +Cc: gdb

On Fri, Feb 09, 2007 at 02:17:52PM -0800, PoWah Wong wrote:
> This is what I am think, please comment:
> - cd src
> - Start testd by ../linux/testd
> - Start gdb
> - Load debugging info
>   symbol-file ../linux/testd

Always use "file".

> - Attach to the parent process (i.e. pid 31629)
> - set breakpoint in the foo() of the util.c
>   b foo
> - Resume testd execution
>   run

"continue"

> - Execute the client program
> - Wait for breakpoint to occur

Yes, this is usually the best way.  If you know which process the bug
will occur in, you can also get to it by running the program under
GDB and using "catch fork" and "set follow-fork-mode".

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: newbie question: debug a multiple processes server program
  2007-02-09 22:18 newbie question: debug a multiple processes server program PoWah Wong
  2007-02-09 22:27 ` Daniel Jacobowitz
@ 2007-02-09 22:38 ` Nick Roberts
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Roberts @ 2007-02-09 22:38 UTC (permalink / raw)
  To: PoWah Wong; +Cc: gdb

 > This is what I am think, please comment:

Read the manual ? (Debugging programs with multiple processes).
Use a recent GDB which has new features for handling forks.

-- 
Nick                                           http://www.inet.net.nz/~nickrob


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

end of thread, other threads:[~2007-02-09 22:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-09 22:18 newbie question: debug a multiple processes server program PoWah Wong
2007-02-09 22:27 ` Daniel Jacobowitz
2007-02-09 22:38 ` Nick Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox