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:15
In 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. n
is next shorthand, run the next line.
4 s
is short for step, into the interior of a function to be executed next.
The start
single-step execution, the program starts, stops at the first row.
6. set var a=1
Set the value of the variable, the variable a is set to 1 here.
7. bt
Check the function call stack frame and the stack.
8. c
is shorthand continue, continue to run.
8 p a
is a shorthand print, print variable values, where the value of a variable print.
9. info
for viewing information, such as the info break
view 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 q
is shorthand quit, quit gdb.
Multithreading command:
1. info threads
Check the thread of the current process. gdb will assign an ID for each thread, preceded by "*" indicates the currently running thread.
2. thread ID
switch debugging thread.
6. b main.c:10 thread all
For all the threads break points.
7. The set scheduler-locking off|on|step
8. The thread apply ID1 ID2 command
IDl ID2 Run.
9. thread apply all command
All 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