newbie question: debug a multiple processes server program
PoWah Wong
wong_powah@yahoo.ca
Fri Feb 9 22:18:00 GMT 2007
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
More information about the Gdb
mailing list