Debugging of GDB thread under Linux

Source: Internet
Author: User

Multi-Threaded DEBUG commands

1. Info Threads:
This command shows all threads currently available for debugging, and GDB assigns an ID to each thread. the thread in front of * is the thread that is currently being debugged.
2. Thread ID:
Switches to the thread that is currently being debugged for the specified ID.
3. Thread Apply all command:
To have all the threads being debugged execute command commands
4. Thread Apply ID1 ID2 ... command:
This command is to let the thread number is ID1,ID2 ... And so on, the threads all execute command commands
5. Set Scheduler-locking Off|on|step:
When debugging a currently debugged thread using the step or Continue command, the other threads are executed concurrently, and if we only want the thread being debugged to execute, and the other threads stop waiting, then lock the thread to be debugged and let it run.
OFF: No threads are locked and all threads are executed.
On: Only threads that are currently being debugged will execute.
Step: Prevents other threads from seizing the current thread while stepping through the current thread. Other threads will be re-run only when next, continue, Util, and finish are available.
6, show scheduler-locking:
This command is to view the mode of the currently locked thread.

7.I Threads

Implement inter-thread switching

8. when compiling, it is important to remember to add the dynamic link library and-G.

Gcc-g *.c-o xxx-lxxx

my: gcc-g rwlock.c main.c-o A-lpthread

A little hint:

When you enter GdB xx, the GDB command is entered, and some information is output. As shown above, most of this information is about GDB, and you can not let him output,

such as: Gdb-q XX

In this, a is the file name of the debug information I generated.

Debugging of GDB thread under Linux

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.