2.2.1. ADD

The ADD command creates a symbol and adds it to the RealView Debugger symbol table.

Syntax

ADD [type] symbol_name [&address] [=value [,value]...]

where:

type

One of the following data types:

int

The symbol represents a location holding a four byte signed integer value. This is the default type of symbols.

char

The symbol represents a location holding a one byte value.

short

The symbol represents a location holding a two byte value.

long

The symbol represents a location holding a four byte value.

long long

The symbol represents a location holding an 8-byte value.

You can use these types together with * and [] to indicate pointer and array variables, using the C language syntax.

You can also create symbols with type float or double, but you cannot initialize them with a value in the ADD statement.

You can create references to existing instances of the following types:

struct

The symbol is an instance of, or a pointer to, a C structure.

enum

The symbol is an instance of, or a pointer to, a C enumeration.

union

The symbol is an instance of, or a pointer to, a C union.

You cannot create new enumerations, structures, or unions. You cannot initialize complete structures at once, although you can individually assign values to the members with CEXPRESSION.

If the symbol is an array, then the array size must be specified after to the symbol name within in square brackets. You can define multidimensional arrays by appending several bracketed array dimensions.

symbol_name

Is the name of the symbol being added. The name must start with an alphabetic character or an underscore, optionally followed by alphabetic or numeric characters or underscores. The symbol name must not already exist (when appropriate, use DELETE on DELETE to remove a symbol).

address

Is the address in target memory that is referred to by this debugger symbol. If you do not specify an address, the new debugger symbol refers to a location in debugger memory, and is not available to code running on the target.

value

Is the initial value of the added symbol. You can use:

  • integer values corresponding to the C types int, char, short, long or long long

  • pointers to integers in target memory

  • strings in double quotes, matching the character array type, char[n], but not char *

  • a list of values separated by a comma.

If the symbol type is a pointer, an assigned value must be the address of the value on the target.

You can initialize array symbols using multiple value arguments. For example:

add char names[3][2] ="aa", "bb"
print names[1]
"bb...

The ... after bb indicates that there is no terminating NUL for the string, in this case because each element of the array is only 2 characters in size.

The value is loaded into the memory location referred to by the symbol. If value is not specified, the symbol is set to zero in debugger memory but is not given a value in target memory.

Floating-point values are not recognized.

Description

The ADD command adds a symbol to the debugger symbol table for the current connection. You cannot add a symbol without a connection, but you do not have to have loaded an executable image file. The symbol survives an executable image being reloaded (File → Reload Image to Target) but is destroyed if the target is disconnected and then reconnected or another, different, image is loaded.

You can remove a symbol defined using ADD by using the DELETE command, and you can modify its value using CEXPRESSION.

Rules

The following rules apply to the use of the ADD command:

  • ADD runs asynchronously unless in a macro.

  • The specified symbol must not exist at the time it is added.

  • To change the symbol type, delete the symbol and then add it again.

  • When initializing symbols, the size of the symbol is used, not the size of the type of value supplied. In particular, the size of a char array is not determined by the string used to initialize it.

  • If a char array is created, for example using ADD char namearray[n], it is filled with the initial value.

  • If there is a runtime error in the initial value, the symbol is still created. You can then assign the correct value with the CEXPRESSION command, or you can delete the symbol and add it again with a legal initial value.

Examples

The following examples show how to use ADD:

add mysymbol =3

Adds a new symbol called mysymbol of type int to the debugger symbol table. The new symbol refers to a 1-int area of debugger memory that is given an initial value of 3.

add char *xyz

Adds a new symbol called xyz to the debugger symbol table. The new symbol is of character pointer type and has an initial value of zero.

See also

The following commands provide similar or related functionality:

Copyright © 2003, 2004 ARM Limited. All rights reserved.ARM DUI 0235B
Non-Confidential