Next: , Previous: Specifying Machine Properties, Up: Configuration


4.3 Specifying Registers

The registers are specified immediately after the machine properties. The section is introduced by the keyword REGISTERS followed by the number of registers in parenthesis.

This number should match the number of real registers specified in the GDB client's architecture definition. I.e not including any pseudo-registers. For example in the OpenRISC 1000 architecture, the real registers that GDB knows about are the 32 general purpose registers, the Previous Program Counter, the Next Program Counter and the Supervision Register, so its register specification starts as follows.

     REGISTERS (35)

This declaration is followed by a comma separated triple in braces ({ and }) for each register. The triple specifies a name of the register (in double quotes), its width in bits and its initial value. The registers must be specified in the same order that they are specified in the GDB client architecture.

The following example specifies the OpenRISC 1000 registers for a program about the execute the instruction at location 0x1030, with a stack pointer at 0x7eb4 and frame pointer at 0x7ebc, and return address (in the link register) of 0x12b0.

     REGISTERS ( 35 )
     { "gpr0", 32, 0 }               // Always zero
     { "gpr1", 32, 0x7eb4 }          // Stack pointer
     { "gpr2", 32, 0x7ebc }          // Frame pointer
     { "gpr3", 32, 0 }               // Start of argument registers
     { "gpr4", 32, 0 }
     { "gpr5", 32, 0 }
     { "gpr6", 32, 0 }
     { "gpr7", 32, 0 }
     { "gpr8", 32, 0 }               // End of argument registers
     { "gpr9", 32, 0x12b0 }          // Link register
     { "gpr10", 32, 0 }
     
     ... More general purpose registers initialized to zero ...
     
     { "gpr31", 32, 0 }
     { "ppc",   32, 0x102c }         // Previous program counter
     { "npc",   32, 0x1030 }         // Next program counter
     { "sr",    32, 0 }              // Supervision register

The bit size and initial value may be specified in octal, decimal or hexadecimal using the conventional C/C++ notation.