target/ppc: Enable reporting of SPRs to GDB
commit707c7c2ee1f6fb425a3c78f587feda7cd8501905
authorFabiano Rosas <farosas@linux.ibm.com>
Wed, 6 Feb 2019 16:51:33 +0000 (6 14:51 -0200)
committerDavid Gibson <david@gibson.dropbear.id.au>
Sun, 17 Feb 2019 10:54:02 +0000 (17 21:54 +1100)
tree9129262e3c0b7f8dd05f63df3f62c8d7ab7ae078
parent5c7adcf422d4bd7235e0d2f2f85efcc393795fb2
target/ppc: Enable reporting of SPRs to GDB

This allows reading and writing of SPRs via GDB:

(gdb) p/x $srr1
$1 = 0x8000000002803033

(gdb) p/x $pvr
$2 = 0x4b0201
(gdb) set $pvr=0x4b0000
(gdb) p/x $pvr
$3 = 0x4b0000

The `info` command can also be used:
(gdb) info registers spr

For this purpose, GDB needs to be provided with an XML description of
the registers (see the gdb-xml directory for examples) and a set of
callbacks for reading and writing the registers must be defined.

The XML file in this case is created dynamically, based on the SPRs
already defined in the machine. This way we avoid the need for several
XML files to suit each possible ppc machine.

The gdb_{get,set}_spr_reg callbacks take an index based on the order
the registers appear in the XML file. This index does not match the
actual location of the registers in the env->spr array so the
gdb_find_spr_idx function does that conversion.

Note: GDB currently needs to know the guest endianness in order to
properly print the registers values. This is done automatically by GDB
when provided with the ELF file or explicitly with the `set endian
<big|little>` command.

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
target/ppc/cpu-qom.h
target/ppc/cpu.h
target/ppc/gdbstub.c
target/ppc/translate_init.inc.c