12.11. Using the debug functionality

This section provides some examples of using the processor debug functionality, both from the point of view of a software engineer writing code to run on an ARM processor and of a developer creating debug tools for the processor. In the former case, examples are given in ARM assembly language. In the latter case, the examples are in C pseudo-language, intended to convey the algorithms to be used. These examples are not intended as source code for a debugger.

The debugger examples use a pair of pseudo-functions such as the following:

uint32 ReadDebugRegister(int reg_num)
{
    // read the value of the debug register reg_num at address reg_num << 2
}

WriteDebugRegister(int reg_num, uint32 val)
{
    // write the value val to the debug register reg_num at address reg_num >> 2
}

A basic function for using the debug state is executing an instruction through the DBGITR. Example 12.1 shows the sequence for executing an ARM instruction through the DBGITR.

Example 12.1. Executing an ARM instruction through the DBGITR

ExecuteARMInstruction(uint32 instr)
{
    // Step 1. Poll DBGDSCR until InstrCompl_l is set.
    repeat
    {
        dbgdscr := ReadDebugRegister(34);
    }
    until (dbgdscr & (1<<24));
    // Step 2. Write the opcode to the DBGITR.
    WriteDebugRegister(33, instr);
    // Step 3. Poll DBGDSCR until InstrCompl is set.
    repeat
    {
        dbgdscr := ReadDebugRegister(34);
    }
    until (dbgdscr & (1<<24);
}

This section describes:

Copyright © 2010-2011 ARM. All rights reserved.ARM DDI 0460C
Non-ConfidentialID021511