Debug
ARM DDI 0363G Copyright © 2006-2011 ARM Limited. All rights reserved. 12-66
ID073015 Non-Confidential
WritePC(state->pc);
// Step 4. Writing the PC corrupts R0 therefore, restore R0 now.
WriteRegister(0, state->r0);
// Step 5. Write the restart request bit in the DBGDRCR.
WriteDebugRegister(36, 1<<1);
// Step 6. Poll the RESTARTED flag in the DBGDSCR.
repeat
{
dscr := ReadDebugRegister(34);
}
until (dscr & (1<<1));
}
12.11.6 Accessing registers and memory in debug state
This section describes the following:
• Reading and writing registers through the DCC
• Reading the PC in debug state on page 12-67
• Reading the CPSR in debug state on page 12-67
• Writing the CPSR in debug state on page 12-68
• Reading memory on page 12-68
• Fast register read/write on page 12-70
• Fast memory read/write on page 12-71
• Accessing coprocessor registers on page 12-72.
Reading and writing registers through the DCC
To read a single register, the debugger can use the sequence that Example 12-13 shows. This
sequence depends on two other sequences, Executing an ARM instruction through the DBGITR
on page 12-57 and Target to host data transfer (host end) on page 12-59.
Example 12-13 Reading an ARM register
uint32 ReadARMRegister(int Rd)
{
// Step 1. Execute instruction MCR p14, 0, Rd, c0, c5, 0 through the DBGITR.
ExecuteARMInstruction(0xEE000E15 + (Rd<<12));
// Step 2. Read the register value through DBGDTRTX.
reg_val := ReadDCC();
return reg_val;
}
Example 12-14 shows a similar sequence for writing an ARM register.
Example 12-14 Writing an ARM register
WriteRegister(int Rd, uint32 reg_val)
{
// Step 1. Write the register value to DBGDTRRX.
WriteDCC(reg_val);