7.7. Manipulating registers and variables

Select View → Registers from the Code window main menu to open the Registers view where you can view registers for threads in the system. If the Code window is unattached, the Registers view shows processor registers for the current thread.

If you attach a Code window to a specified thread, the Registers view displays the registers associated with the thread. These might not have the same values as the current processor registers.

You can use in-place editing to change a register value in the usual way. However, you can only see register values, and change them, when the thread is stopped. The new register values are written to the OS Task Control Block (TCB) for the selected thread. When that thread is next scheduled, the registers used by the thread are read from the TCB into the processor.

If you are debugging ARM code, the ARM Architecture Procedure Call Standard (AAPCS) specifies that the first four parameters to a function are passed in registers. In addition, some local variables are optimized into registers by the compiler for parts of the function. Therefore if you modify a local variable that is stored in a register, the debugger modifies the TCB state to transfer the value into a processor register instead of modifying the target memory allocated to that variable.

Note

If you are modifying a value that you expect to be shared by several threads, for example a global variable, the compiler might have cached that value in a register for one or more of the threads. As a result, the modification you want is not propagated to all of the threads that reference the variable. To make sure that such modifications operate correctly, you must do one of the following:

  • in RSD mode, modify the variable, then at the point you have stopped the relevant thread, if any thread has a cached copy of the variable, modify the copy

  • in HSD mode, modify the variable, then at the point you have stopped the processor, if any thread has a cached copy of the variable, modify the copy

  • in RSD or HSD, declare the variable to be volatile and recompile the program.

See also:

Copyright © 2006-2011 ARM. All rights reserved.ARM DUI 0323G
Non-ConfidentialID052111