| |||
| Home > Working with the CLI > Using variables in the debugger > Data types | |||
All symbols and expressions have an associated data type:
Source language modules can contain any valid C or C++ language data type.
Assembly language modules can contain variables with the types shown in Table 1.10. Some assemblers might have other types such as fixed-point. In addition, each symbol has an attribute that indicates whether a variable was defined in a code or data area. Also, the assembler can create arrays of these types in addition to structures (check with the assembler manufacturer for details).
Table 1.10. Equivalent RealView Debugger data types for ARM assembler
| ARM assembler data type | Equivalent data type in RealView Debugger | Size (bytes) |
|---|---|---|
| byte | unsigned char | 1 |
| word | unsigned short int | 2 |
| long | unsigned long | 4 |
| 8-byte long | long long | 8 |
| single-precision floating point | float | 4 |
| double-precision floating point | double | 8 |
| label | label | 1 |
You can access a specific number of bytes in memory using the following predefined macros:
byte() to return an unsigned
char
word() to return an unsigned
short int
dword() to return an unsigned
long.
The RealView Debugger performs data-type conversions under the following circumstances:
when two or more operands of different types appear in an expression, data type conversion is performed according to the rules of C or C++
when arguments are passed to a macro, the types of the passed arguments are converted to the types given in the macro function definition
when the data type of an operand is forced by user-specified type casting, it is converted
when a specific type is required by a command, the value is converted according to the rules of C/C++.
Type casting forces the conversion of an expression to the specified data type. The contents of any variables that are referenced are not altered. Debugger expressions can be cast into different types using the following syntax:
(type_name)expression
Example 1.2 shows examples of casting different types.
Example 1.2. Casting symbols and expressions into different types
(char) prime /* prime is cast to type char */
(float) 12 /* value is 12.0. (integer 12 in floating point) */
(int) sin(0.2) /* value is 0, sin(0.2) is 0.198, truncates to 0 */
(int) ptr_char /* the variable expression ptr_char is */
/* cast to type int */
The debugger can cast some expression types to an array type. Example 1.3 casts the constant
expression 7 to an array of three characters starting at location 0x0007.
This type of casting to an array can be used with the PRINTVALUE command. Assembly language structures can be displayed in a more meaningful form by using this technique. Table 1.11 lists additional special casting types. Arrays of hexadecimal types and pointers to hexadecimal types can also be used.
Table 1.11. Special casting types
| Cast | Commands | Meaning |
|---|---|---|
| PRINTVALUE | Show as "string." |
| All | Convert into a legal source-level address. |
| All | Convert into a single byte. |
| All | Show in hex bytes. |
| All | Show in 16 bit hex. |
| All | Show in 32 bit hex. |