A deamo can only be debugged at run time, and the thread is bound by the attach command in GDB, and everything is OK.
The steps are as follows:
1) determine the thread number
My process is named Webproc and the thread is displayed using Ps-el
[Email protected] linux]$ ps-el|grep webproc29176 29176 pts/0 00:00:00 webproc29176 29182 pts/0 00:00:00 Webpro c29176 29183 pts/0 00:00:00 webproc29176 29184 pts/0 00:00:00 Webproc
The thread I want to debug at this point is number No. 29184
2) Start gdb and bind the thread with the Attach command.
(gdb) Attach 29184Attaching to process 29184
3) After the thread is bound, the thread is in a blocking state, and the point can be interrupted at this point.
Specify the source code file location of the Webproc before the break point. My source code is placed in the/home/syscom/jud/webproc/directory.
Dir/home/syscom/jud/webproc
Attention:The dir command cannot recursively search the source code folder! Must be a direct upper-level directory of source code
4) Enter "C" to start the thread
When a breakpoint is triggered, it can be debugged in one step.
debugging threads with the Attach command