Search code examples
variablesarmgdbeclipse-cdtds-5

How to define and set a variable in ARM DS-5 Debug/Command view on Eclipse CDT


I am using ARM DS-5 (v5.29.1) Eclipse CDT to debug an embedded project, trying to use the debugger command line for manipulating memory locations through the Commands view in the Debug perspective.

According to the debugger's own context help (Ctrl+Space on the command line), the following command should define a variable and set its value:

set variable INTR_MASK=4

However, when typing this, I get an error:

ERROR(EXP8): Could not find the symbol "INTR_MASK"

How can I define and set a variable?


For reference, here's the help description:

set variable
------------

Evaluates an expression and assigns the result to a variable, register or
memory.

Syntax
  set [variable] <expression>
Where:
<expression>
  Specifies an expression and assigns the result to a variable, register, or
  memory address.

Example
  set variable myVar=10                               # Assign 10 to variable myVar
  set variable $PC=0x8000                             # Assign address 0x8000 to
                                                      # PC register
  set variable $CPSR.N=0                              # Clear N bit
  set variable (*(int*)0x8000)=1                      # Assign 1 to address 0x8000
  set variable *0x8000=1                              # Assign 1 to address 0x8000
  set variable strcpy((char*)0x8000,"My String")      # Assign string to address 0x8000
  set variable memcpy(void*)0x8000,{10,20,30,40},4)   # Assign array to address 0x8000

Solution

  • After communicating ARM support, it come out that the right way to achieve that is something like:

    newvar $INTR_MASK = (unsigned int)(0x00000004)
    set variable $INTR_MASK = (unsigned int)($INTR_MASK + 0x00080000)
    

    ... and the associated bonus is that those symbols can be used in the Expressions view as well, so no more explicit addresses, but rather meaningful names.