multithreading gdb debugging techniques

Internship project need to use gdb debugging multi-threaded, so the search for the next record common statement for future reference.

Content of the discussion from the network.

Commonly used commands:

* You can enter directly abbreviated statement, you can also enter the full statement.
1. b main.cpp:15In line 15 main.cpp interrupted point. Can be followed by conditions such as if i == 2, only when the conditions are satisfied, break force.
2. r [option]is run shorthand. Continue to run, if there is no break later, the program will run until the end.
3. nis next shorthand, run the next line.
4 sis short for step, into the interior of a function to be executed next.
The startsingle-step execution, the program starts, stops at the first row.
6. set var a=1Set the value of the variable, the variable a is set to 1 here.
7. btCheck the function call stack frame and the stack.
8. cis shorthand continue, continue to run.
8 p ais a shorthand print, print variable values, where the value of a variable print.
9. infofor viewing information, such as the info breakview breakpoint conditions.
10. The d bID, del D is shorthand, can remove the breakpoint, the breakpoint is bID numbers available through the preceding command.
11. dispaly a perform each step will print the variable, in this case print a.
12. undispaly dID, step on the inverse operation, cancel printing a variable. Note here dID numbered, non-variable name. No need to see through the info display.
13 qis shorthand quit, quit gdb.

Multithreading command:

1. info threadsCheck the thread of the current process. gdb will assign an ID for each thread, preceded by "*" indicates the currently running thread.
2. thread IDswitch debugging thread.
6. b main.c:10 thread allFor all the threads break points.
7. The set scheduler-locking off|on|step
8. The thread apply ID1 ID2 commandIDl ID2 Run.
9. thread apply all commandAll thread.

Debugging macro definitions:

Because macros are pre-compiled, the default can not be printed. For debugging macro definition, you need to add parameters when compiling the program-ggdb3

Published 11 original articles · won praise 15 · views 10000 +

Guess you like

Origin blog.csdn.net/DJ_xiaoming/article/details/104376777