Next: , Up: Set Tracepoints


13.1.1 Create and Delete Tracepoints

trace location
The trace command is very similar to the break command. Its argument location can be a source line, a function name, or an address in the target program. See Specify Location. The trace command defines a tracepoint, which is a point in the target program where the debugger will briefly stop, collect some data, and then allow the program to continue. Setting a tracepoint or changing its actions doesn't take effect until the next tstart command, and once a trace experiment is running, further changes will not have any effect until the next trace experiment starts.

Here are some examples of using the trace command:

          (gdb) trace foo.c:121    // a source file and line number
          
          (gdb) trace +2           // 2 lines forward
          
          (gdb) trace my_function  // first source line of function
          
          (gdb) trace *my_function // EXACT start address of function
          
          (gdb) trace *0x2117c4    // an address
     

You can abbreviate trace as tr.

trace location if cond
Set a tracepoint with condition cond; evaluate the expression cond each time the tracepoint is reached, and collect data only if the value is nonzero—that is, if cond evaluates as true. See Tracepoint Conditions, for more information on tracepoint conditions.

The convenience variable $tpnum records the tracepoint number of the most recently set tracepoint.


delete tracepoint [num]
Permanently delete one or more tracepoints. With no argument, the default is to delete all tracepoints. Note that the regular delete command can remove tracepoints also.

Examples:

          (gdb) delete trace 1 2 3 // remove three tracepoints
          
          (gdb) delete trace       // remove all tracepoints
     

You can abbreviate this command as del tr.