$ ls
config.ini echosvc log.txt runtest.sh
$ gdb echosvc
GNU gdb 6.8-debian
Copyright (C) 2008 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 "i486-linux-gnu"...
(gdb) l
95 }
96
97 apr_pollset_add(cs->pollset,cs->pfd);
98 return 0;
99 }
100
101 int main(int argc,const char * const argv[])
102 {
103
104 if(zevent_init(file,&pglobal)==-1)
(gdb)
set follow-fork-mode child
(gdb) b zevent_process_connection
Breakpoint 1 at 0x80489b2: file echo.c, line 34.
(gdb) r
Starting program: echosvc
[Thread debugging using libthread_db enabled]
[Thread debugging using libthread_db enabled]
[New Thread 0xb7ce08d0 (LWP 8755)]
[Thread debugging using libthread_db enabled]
[New Thread 0xb7ce08d0 (LWP 8756)]
[New Thread 0xb637ab90 (LWP 8757)]
[New Thread 0xb5b79b90 (LWP 875
]
[New Thread 0xb5378b90 (LWP 8759)]
[New Thread 0xb4b77b90 (LWP 8760)]
[New Thread 0xb4376b90 (LWP 8761)]
[New Thread 0xb3b75b90 (LWP 8762)]
[New Thread 0xb3374b90 (LWP 8763)]
[New Thread 0xb2b73b90 (LWP 8764)]
[New Thread 0xb2372b90 (LWP 8765)]
[New Thread 0xb1b71b90 (LWP 8766)]
[New Thread 0xb1370b90 (LWP 8767)]
[New Thread 0xb0b6fb90 (LWP 876
]
[New Thread 0xb036eb90 (LWP 8769)]
[New Thread 0xafb6db90 (LWP 8770)]
[New Thread 0xaf36cb90 (LWP 8771)]
[New Thread 0xaeb6bb90 (LWP 8772)]
[New Thread 0xae36ab90 (LWP 8773)]
[New Thread 0xadb69b90 (LWP 8774)]
[tcsetpgrp failed in terminal_inferior: No such process]
[Thread 0xb637ab90 (LWP 8757) exited]
[Switching to Thread 0xae36ab90 (LWP 8773)]
Breakpoint 1, zevent_process_connection (cs=0x832cc40) at echo.c:34
当客户端发送消息成功进入断点函数
34 apr_size_t len=0;
(gdb) l
29 /*
30 * code for your app,this just an example for echo test.
31 */
32 apr_bucket *b;
33 char *msg;
34 apr_size_t len=0;
35 int olen = 0;
36 const char *buf;
37 apr_status_t rv;
38
(gdb)
39 cs->pfd->reqevents = APR_POLLIN;
40
41 if(cs->pfd->rtnevents & APR_POLLIN){
42 len = 4096;
43 msg = (char *)apr_bucket_alloc(len,cs->baout);
44 if (msg == NULL) {
45 return -1;
46 }
47 rv = apr_socket_recv(cs->pfd->desc.s,msg,&len);
48 if(rv != APR_SUCCESS)
(gdb) b 47
想看看我到底收到了什么
Breakpoint 2 at 0x8048a13: file echo.c, line 47.
(gdb) c
Continuing.
Breakpoint 2, zevent_process_connection (cs=0x832cc40) at echo.c:47
47 rv = apr_socket_recv(cs->pfd->desc.s,msg,&len);
(gdb) n
48 if(rv != APR_SUCCESS)
(gdb) p msg
$1 = 0x8332a78 "asdf/r/n"
(gdb) info threads
19 Thread 0xadb69b90 (LWP 8774) 0xb7f2a430 in __kernel_vsyscall ()
* 18 Thread 0xae36ab90 (LWP 8773) zevent_process_connection (cs=0x832cc40) at echo.c:48
我们正在调试的线程
17 Thread 0xaeb6bb90 (LWP 8772) 0xb7f2a430 in __kernel_vsyscall ()
16 Thread 0xaf36cb90 (LWP 8771) 0xb7f2a430 in __kernel_vsyscall ()
15 Thread 0xafb6db90 (LWP 8770) 0xb7f2a430 in __kernel_vsyscall ()
14 Thread 0xb036eb90 (LWP 8769) 0xb7f2a430 in __kernel_vsyscall ()
13 Thread 0xb0b6fb90 (LWP 876
0xb7f2a430 in __kernel_vsyscall ()
12 Thread 0xb1370b90 (LWP 8767) 0xb7f2a430 in __kernel_vsyscall ()
11 Thread 0xb1b71b90 (LWP 8766) 0xb7f2a430 in __kernel_vsyscall ()
10 Thread 0xb2372b90 (LWP 8765) 0xb7f2a430 in __kernel_vsyscall ()
9 Thread 0xb2b73b90 (LWP 8764) 0xb7f2a430 in __kernel_vsyscall ()
8 Thread 0xb3374b90 (LWP 8763) 0xb7f2a430 in __kernel_vsyscall ()
7 Thread 0xb3b75b90 (LWP 8762) 0xb7f2a430 in __kernel_vsyscall ()
6 Thread 0xb4376b90 (LWP 8761) 0xb7f2a430 in __kernel_vsyscall ()
5 Thread 0xb4b77b90 (LWP 8760) 0xb7f2a430 in __kernel_vsyscall ()
4 Thread 0xb5378b90 (LWP 8759) 0xb7f2a430 in __kernel_vsyscall ()
3 Thread 0xb5b79b90 (LWP 875
0xb7f2a430 in __kernel_vsyscall ()
1 Thread 0xb7ce08d0 (LWP 8756) 0xb7f2a430 in __kernel_vsyscall ()
(gdb) bt
#0 zevent_process_connection (cs=0x832cc40) at echo.c:48
#1 0xb7f2457c in zevent_run_process_connection (cs=0x832cc40) at zevent_hooks.c:14
#2 0xb7f20aef in process_socket (p=0x832ca50, sock=0x832ca90, cs=0x832cc40, my_child_num=0, my_thread_num=15)
at zevent.c:401
#3 0xb7f2145b in worker_thread (thd=0x8305f38, dummy=0x8307b5
at zevent.c:788
#4 0xb7f13736 in dummy_worker (opaque=0x8305f3
at threadproc/unix/thread.c:142
#5 0xb7d0f4ff in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#6 0xb7e4149e in clone () from /lib/tls/i686/cmov/libc.so.6
(gdb)