Debug
ARM DDI 0363E Copyright © 2009 ARM Limited. All rights reserved. 11-63
ID013010 Non-Confidential, Unrestricted Access
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 DRCR.
WriteDebugRegister(36, 1<<1);
// Step 6. Poll the RESTARTED flag in the DSCR.
repeat
{
dscr := ReadDebugRegister(34);
}
until (dscr & (1<<1));
}
11.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 11-64
• Reading the CPSR in debug state on page 11-64
• Writing the CPSR in debug state on page 11-64
• Reading memory on page 11-65
• Fast register read/write on page 11-67
• Fast memory read/write on page 11-68
• Accessing coprocessor registers on page 11-69.
Reading and writing registers through the DCC
To read a single register, the debugger can use the sequence that Example 11-13 shows. This
sequence depends on two other sequences, Executing an ARM instruction through the ITR on
page 11-54 and Target to host data transfer (host end) on page 11-56.
Example 11-13 Reading an ARM register
uint32 ReadARMRegister(int Rd)
{
// Step 1. Execute instruction MCR p14, 0, Rd, c0, c5, 0 through the ITR.
ExecuteARMInstruction(0xEE000E15 + (Rd<<12));
// Step 2. Read the register value through DTRTX.
reg_val := ReadDCC();
return reg_val;
}
Example 11-14 shows a similar sequence for writing an ARM register.
Example 11-14 Writing an ARM register
WriteRegister(int Rd, uint32 reg_val)
{
// Step 1. Write the register value to DTRRX.
WriteDCC(reg_val);
// Step 2. Execute instruction MRC p14, 0, Rd, c0, c5, 0 to the ITR.
ExecuteARMInstruction(0xEE100E15 + (Rd<<12));