A trace state variable is a special type of variable that is
created and managed by target-side code. The syntax is the same as
that for GDB's convenience variables (a string prefixed with “$”),
but they are stored on the target. They must be created explicitly,
tvariable command. They are always 64-bit signed
Trace state variables are remembered by gdb, and downloaded to the target along with tracepoint information when the trace experiment starts. There are no intrinsic limits on the number of trace state variables, beyond memory limitations of the target.
Although trace state variables are managed by the target, you can use
them in print commands and expressions as if they were convenience
variables; gdb will get the current value from the target
while the trace experiment is running. Trace state variables share
the same namespace as other “$” variables, which means that you
cannot have trace state variables with names like
$pc, nor can you have a trace state variable and a convenience
variable with the same name.
tvariablecommand creates a new trace state variable named
$name, and optionally gives it an initial value of expression. expression is evaluated when this command is entered; the result will be converted to an integer if possible, otherwise gdb will report an error. A subsequent
tvariablecommand specifying the same name does not create a variable, but instead assigns the supplied initial value to the existing variable of that name, overwriting any previous initial value. The default initial value is 0.