target description XML support for PowerPC
cover target description XML support for PowerPC
This patch series implements target description XML support for PowerPC in the GDB stub. It's fairly straightforward:
- Include the necessary XML files in the build process;
- Inform the GDB stub that we have XML for PowerPC;
- Instruct the stub on how to use the XML files for the three major flavors of "extra" registers: floating-point, AltiVec, and SPE.
Ideally, support can be added later for sending interesting SPRs.
-Nathan
PATCH 1/6 Add XML files for PowerPC registers
These files are nearly identical to the XML files provided with GDB. The only difference is that power-{fpu,spe}.xml do not assign register numbers; the internal QEMU machinery takes care of that.
Define gdb_xml_files for ppc targets in configure as well.
--- configure | 4 +++ gdb-xml/power-altivec.xml | 57 +++++++++++++++++++++++++++++++++++++++++++++ gdb-xml/power-core.xml | 49 ++++++++++++++++++++++++++++++++++++++ gdb-xml/power-fpu.xml | 44 ++++++++++++++++++++++++++++++++++ gdb-xml/power-spe.xml | 45 +++++++++++++++++++++++++++++++++++ gdb-xml/power64-core.xml | 49 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 248 insertions(+), 0 deletions(-) create mode 100644 gdb-xml/power-altivec.xml create mode 100644 gdb-xml/power-core.xml create mode 100644 gdb-xml/power-fpu.xml create mode 100644 gdb-xml/power-spe.xml create mode 100644 gdb-xml/power64-core.xml
configure +4 -0
@@ -1638,6 +1638,7 @@ case "$target_cpu" in echo "TARGET_ARCH=ppc" >> $config_mak echo "#define TARGET_ARCH \"ppc\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h + gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml" ;; ppcemb) echo "TARGET_ARCH=ppcemb" >> $config_mak
@@ -1650,6 +1651,7 @@ case "$target_cpu" in echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak echo "#define CONFIG_KVM 1" >> $config_h fi + gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml" ;; ppc64) echo "TARGET_ARCH=ppc64" >> $config_mak
@@ -1657,6 +1659,7 @@ case "$target_cpu" in echo "#define TARGET_ARCH \"ppc64\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPC64 1" >> $config_h + gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" ;; ppc64abi32) echo "TARGET_ARCH=ppc64" >> $config_mak
@@ -1666,6 +1669,7 @@ case "$target_cpu" in echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPC64 1" >> $config_h echo "#define TARGET_ABI32 1" >> $config_h + gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" ;; sh4|sh4eb) echo "TARGET_ARCH=sh4" >> $config_mak
gdb-xml/power-altivec.xml new file +57 -0
57 lines not on this page · raw message
gdb-xml/power-core.xml new file +49 -0
49 lines not on this page · raw message
gdb-xml/power-fpu.xml new file +44 -0
44 lines not on this page · raw message
gdb-xml/power-spe.xml new file +45 -0
45 lines not on this page · raw message
gdb-xml/power64-core.xml new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
1.6.0.5
PATCH 2/6 Change core powerpc gdbstub bits to be XML-aware
In reply to Nathan FroydDefine GDB_CORE_XML and hack things similarly to ARM so that despite the FP registers coming in between the GPRs and some status registers, everything works out OK no matter which kind of GDB we're communicating with.
It matters whether we're built to target 64-bit or 32-bit cores. I think there are still problems if we are debugging 32-bit programs on a built-for-64-bit QEMU (QEMU will always send 64-bit registers), but I don't know if there's a good way around that at the time being.
--- gdbstub.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-)
gdbstub.c +22 -1
@@ -620,7 +620,17 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int i)#elif defined (TARGET_PPC ) +/* Old gdb always expects FP registers. Newer (xml-aware) gdb only +expects whatever the target description contains. Due to a +historical mishap the FP registers appear in between core integer +regs and PC, MSR, CR, and so forth. We hack round this by giving the +FP regs zero size when talking to a newer gdb. */ #define NUM_CORE_REGS 71 +#if defined (TARGET_PPC64 ) +#define GDB_CORE_XML "power64-core.xml" +#else +#define GDB_CORE_XML "power-core.xml" +#endif static int cpu_gdb_read_register (CPUState *env,uint8_t *mem_buf,int n) {
@@ -629,6 +639,8 @@ static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)GET_REGL (env->gpr[n]); }else if (n <64 ) {/* fprs */ +if (gdb_has_xml) +return 0 ;stfq_p (mem_buf, env->fpr[n-32 ]);return 8 ; }else {
@@ -646,7 +658,12 @@ static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)case 67 :GET_REGL (env->lr);case 68 :GET_REGL (env->ctr);case 69 :GET_REGL (env->xer); -case 70 :GET_REG32 (0 );/* fpscr */ +case 70 : + { +if (gdb_has_xml) +return 0 ; +GET_REG32 (0 );/* fpscr */ + } } }return 0 ;
@@ -660,6 +677,8 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)return sizeof (target_ulong); }else if (n <64 ) {/* fprs */ +if (gdb_has_xml) +return 0 ; env->fpr[n-32 ] =ldfq_p (mem_buf);return 8 ; }else {
@@ -689,6 +708,8 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)return sizeof (target_ulong);case 70 :/* fpscr */ +if (gdb_has_xml) +return 0 ;return 4 ; } }
Signature · 1 line
1.6.0.5
PATCH 3/6 Include gdbstub.h
In reply to Nathan Froyd--- target-ppc/translate_init.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
target-ppc/translate_init.c +1 -0
@@ -25,6 +25,7 @@#include "dis-asm.h" #include "host-utils.h" +#include "gdbstub.h" //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR
Signature · 1 line
1.6.0.5
PATCH 4/6 Add float register read/write using XML
In reply to Nathan Froyd--- target-ppc/translate_init.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-)
target-ppc/translate_init.c +32 -0
@@ -9272,6 +9272,33 @@ static void dump_ppc_insns (CPUPPCState *env) }#endif +static int gdb_get_float_reg (CPUState *env,uint8_t *mem_buf,int n) +{ +if (n <32 ) { +stfq_p (mem_buf, env->fpr[n]); +return 8 ; + } +if (n ==32 ) { +/* FPSCR not implemented */ +memset (mem_buf,0 ,4 ); +return 4 ; + } +return 0 ; +} + +static int gdb_set_float_reg (CPUState *env,uint8_t *mem_buf,int n) +{ +if (n <32 ) { + env->fpr[n] =ldfq_p (mem_buf); +return 8 ; + } +if (n ==32 ) { +/* FPSCR not implemented */ +return 4 ; + } +return 0 ; +} +int cpu_ppc_register_internal (CPUPPCState *env,const ppc_def_t *def) { env->msr_mask = def->msr_mask;
@@ -9284,6 +9311,11 @@ int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def)if (create_ppc_opcodes (env, def) <0 )return -1 ;init_ppc_proc (env, def); + +if (def->insns_flags &PPC_FLOAT ) { +gdb_register_coprocessor (env, gdb_get_float_reg, gdb_set_float_reg, +33 ,"power-fpu.xml" ,0 ); + }#if defined(PPC_DUMP_CPU ) {const char *mmu_model, *excp_model, *bus_model;
Signature · 1 line
1.6.0.5
PATCH 5/6 Add Altivec register read/write using XML
In reply to Nathan Froyd--- target-ppc/translate_init.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-)
target-ppc/translate_init.c +50 -0
@@ -9299,6 +9299,52 @@ static int gdb_set_float_reg(CPUState *env, uint8_t *mem_buf, int n)return 0 ; } +static int gdb_get_avr_reg (CPUState *env,uint8_t *mem_buf,int n) +{ +if (n <32 ) { +#ifdef WORDS_BIGENDIAN +stq_p (mem_buf, env->avr[n].u64[0 ]); +stq_p (mem_buf+8 , env->avr[n].u64[1 ]); +#else +stq_p (mem_buf, env->avr[n].u64[1 ]); +stq_p (mem_buf+8 , env->avr[n].u64[0 ]); +#endif +return 16 ; + } +if (n ==33 ) { +stl_p (mem_buf, env->vscr); +return 4 ; + } +if (n ==34 ) { +stl_p (mem_buf, (uint32_t )env->spr[SPR_VRSAVE ]); +return 4 ; + } +return 0 ; +} + +static int gdb_set_avr_reg (CPUState *env,uint8_t *mem_buf,int n) +{ +if (n <32 ) { +#ifdef WORDS_BIGENDIAN + env->avr[n].u64[0 ] =ldq_p (mem_buf); + env->avr[n].u64[1 ] =ldq_p (mem_buf+8 ); +#else + env->avr[n].u64[1 ] =ldq_p (mem_buf); + env->avr[n].u64[0 ] =ldq_p (mem_buf+8 ); +#endif +return 16 ; + } +if (n ==33 ) { + env->vscr =ldl_p (mem_buf); +return 4 ; + } +if (n ==34 ) { + env->spr[SPR_VRSAVE ] = (target_ulong )ldl_p (mem_buf); +return 4 ; + } +return 0 ; +} +int cpu_ppc_register_internal (CPUPPCState *env,const ppc_def_t *def) { env->msr_mask = def->msr_mask;
@@ -9316,6 +9362,10 @@ int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def)gdb_register_coprocessor (env, gdb_get_float_reg, gdb_set_float_reg,33 ,"power-fpu.xml" ,0 ); } +if (def->insns_flags &PPC_ALTIVEC ) { +gdb_register_coprocessor (env, gdb_get_avr_reg, gdb_set_avr_reg, +34 ,"power-altivec.xml" ,0 ); + }#if defined(PPC_DUMP_CPU ) {const char *mmu_model, *excp_model, *bus_model;
Signature · 1 line
1.6.0.5
PATCH 6/6 Add SPE register read/write using XML
In reply to Nathan FroydDon't read/write SPEFSCR until we figure out what to do about exceptions.
--- target-ppc/translate_init.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-)
target-ppc/translate_init.c +50 -0
@@ -9345,6 +9345,51 @@ static int gdb_set_avr_reg(CPUState *env, uint8_t *mem_buf, int n)return 0 ; } +static int gdb_get_spe_reg (CPUState *env,uint8_t *mem_buf,int n) +{ +if (n <32 ) { +#if defined(TARGET_POWERPC64 ) +stl_p (mem_buf, env->gpr[n] >>32 ); +#else +stl_p (mem_buf, env->gprh[n]); +#endif +return 4 ; + } +if (n ==33 ) { +stq_p (mem_buf, env->spe_acc); +return 8 ; + } +if (n ==34 ) { +/* SPEFSCR not implemented */ +memset (mem_buf,0 ,4 ); +return 4 ; + } +return 0 ; +} + +static int gdb_set_spe_reg (CPUState *env,uint8_t *mem_buf,int n) +{ +if (n <32 ) { +#if defined(TARGET_POWERPC64 ) +target_ulong lo = (uint32_t )env->gpr[n]; +target_ulong hi =ldl_p (mem_buf) <<32 ; + env->gpr[n] = lo | hi; +#else + env->gprh[n] =ldl_p (mem_buf); +#endif +return 4 ; + } +if (n ==33 ) { + env->spe_acc =ldq_p (mem_buf); +return 8 ; + } +if (n ==34 ) { +/* SPEFSCR not implemented */ +return 4 ; + } +return 0 ; +} +int cpu_ppc_register_internal (CPUPPCState *env,const ppc_def_t *def) { env->msr_mask = def->msr_mask;
@@ -9366,6 +9411,11 @@ int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def)gdb_register_coprocessor (env, gdb_get_avr_reg, gdb_set_avr_reg,34 ,"power-altivec.xml" ,0 ); } +if ((def->insns_flags &PPC_SPE ) | (def->insns_flags &PPC_SPEFPU )) { +gdb_register_coprocessor (env, gdb_get_spe_reg, gdb_set_spe_reg, +34 ,"power-spe.xml" ,0 ); + } +#if defined(PPC_DUMP_CPU ) {const char *mmu_model, *excp_model, *bus_model;
Signature · 1 line
1.6.0.5
Aurelien Jarno
AppliedQuoted 10 lines · Nathan Froyd
This patch series implements target description XML support for PowerPC in the GDB stub. It's fairly straightforward:
- Include the necessary XML files in the build process;
- Inform the GDB stub that we have XML for PowerPC;
- Instruct the stub on how to use the XML files for the three major flavors of "extra" registers: floating-point, AltiVec, and SPE.Ideally, support can be added later for sending interesting SPRs.
Thanks, applied with minor warning fixes in patch 6.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net