debugging threads with the Attach command

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.