Multiple Threads in gdb Mode

Source: Internet
Author: User

I don't know how to execute a single thread in a single step. I have only one thread in the current mode.
When the current thread is tuned, other threads are always running, which is difficult to control. I do not like multi-threaded debugging. I usually try to convert a multi-threaded program into a single thread for debugging,
Run each function after it is successfully adjusted. The original print method will not be used.

------------------
The following Source: http://book.77169.org/ask30/how210438.htm

The key point is to run the program first, and then attach the thread number for debugging.
1. Run your main program first
2. Use ps to view the thread number of your program, or print it out in the thread program.
3. Run gdb and the "attach thread number"
4. Info stack: Check where the job is running and set the breakpoint in the thread file.
5. Tracking debugging
6. "Detach thread number" to cancel debugging this thread

I have tried it, and the success or failure is basically half-open.
------------------

How to view the thread Number:
To get info about threads:
Ps-eLf
Ps axms

When used with-L, the NLWP (number of threads) and LWP (thread ID)

------------------
How to generate core files:
[Gan @ localhost tmp] $ ulimit-
Core file size (blocks,-c) 0
...
[Gan @ localhost tmp] $ ulimit-c unlimited
[Gan @ localhost tmp] $ ulimit-
Core file size (blocks,-c) unlimited
...
[Gan @ localhost tmp] $./a. out
Segment error (core dumped)

The core. [pid] file is generated in the current directory.

-------------------
You must also note that the gcc-g parameter can be tuned using gdb. However, if you only have one execution file, there is no way to tune it. after testing today, we took the execution file from another machine to gdb on our machine. It turns out that gdb needs to access the original file. c file to display detailed code information.

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.