You copied the Doc URL to your clipboard.

newvar

Declares and initializes a new debugger convenience variable.

Syntax

newvar [global] $name [=initial_value]

Where:

Syntax

global

Specifies that the variable has global scope. If global is not specified, then the variable is only accessible within its enclosing lexical scope.

name

Specifies the name of the new variable. The name must be a valid C identifier but prefixed with $.

initial_value

Specifies the initial value of the variable. If an initial value is not specified, then by default, the variable is of integer type with value 0.

  • Debugger scripts and the top-level interactive interpreter are considered separate lexical scopes where non-global convenience variables are not visible to any child or parent debugger script.

  • A user-defined command created with define is considered a separate lexical scope and cannot reference non-global convenience variables in surrounding scripts or from the top-level interpreter.

  • The if, else, and while commands define new lexical scopes that inherit parent lexical scopes up to the level of a script, top-level interpreter, or user-defined command.

  • Any non-global convenience variables, declared within a lexical scope, are destroyed at the end of the lexical scope.

Example 1-105 Examples

define advance_hw    # This defines a new command that runs
                     # to an address using a hardware breakpoint.
  hbreak $arg0       # Set a hardware breakpoint at the value of the first parameter.
  newvar $bp_num = $ # Save the number of the breakpoint in a new variable.
  continue
  wait
  delete $bp_num     # Delete the hardware breakpoint.
end
advance_hw 0x00008000