From 00fcd100c3f47445f6a59d39e11601460880cfe4 Mon Sep 17 00:00:00 2001 From: Abdallah Bouassida Date: Wed, 28 Dec 2016 17:34:02 +0100 Subject: [PATCH] target/i386: Add GDB XML register description support This patch implements XML target description support for X86 and X86-64 architectures in the GDB stub, as the way with ARM and PowerPC: - gdb-xml/32bit-core.xml & gdb-xml/64bit-core.xml: Adding the XML target description files, these files are picked from GDB source code. - configure: Define gdb_xml_files for X86 targets. - target/i386/cpu.c: Define gdb_core_xml_file and gdb_arch_name to add XML awareness for this architecture, modify the gdb_num_core_regs to fit the registers number defined in each XML file. Signed-off-by: Abdallah Bouassida Message-Id: <2b3c8119-1602-28c7-eab4-296593877103@lauterbach.com> Signed-off-by: Paolo Bonzini --- configure | 2 + gdb-xml/i386-32bit-core.xml | 65 +++++++++++++++++++++++++++++++++ gdb-xml/i386-64bit-core.xml | 73 +++++++++++++++++++++++++++++++++++++ target/i386/cpu.c | 21 +++++++++-- 4 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 gdb-xml/i386-32bit-core.xml create mode 100644 gdb-xml/i386-64bit-core.xml diff --git a/configure b/configure index 48a9370cc6..ff2c81f2c7 100755 --- a/configure +++ b/configure @@ -6023,9 +6023,11 @@ TARGET_ABI_DIR="" case "$target_name" in i386) + gdb_xml_files="i386-32bit-core.xml" ;; x86_64) TARGET_BASE_ARCH=i386 + gdb_xml_files="i386-64bit-core.xml" ;; alpha) mttcg="yes" diff --git a/gdb-xml/i386-32bit-core.xml b/gdb-xml/i386-32bit-core.xml new file mode 100644 index 0000000000..7aeeeca3b2 --- /dev/null +++ b/gdb-xml/i386-32bit-core.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb-xml/i386-64bit-core.xml b/gdb-xml/i386-64bit-core.xml new file mode 100644 index 0000000000..5088d84ceb --- /dev/null +++ b/gdb-xml/i386-64bit-core.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 13c0985f11..7e87031fad 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2577,6 +2577,15 @@ out: return ret; } +static gchar *x86_gdb_arch_name(CPUState *cs) +{ +#ifdef TARGET_X86_64 + return g_strdup("i386:x86-64"); +#else + return g_strdup("i386"); +#endif +} + X86CPU *cpu_x86_init(const char *cpu_model) { return X86_CPU(cpu_generic_init(TYPE_X86_CPU, cpu_model)); @@ -4056,10 +4065,14 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote; cc->vmsd = &vmstate_x86_cpu; #endif - /* CPU_NB_REGS * 2 = general regs + xmm regs - * 25 = eip, eflags, 6 seg regs, st[0-7], fctrl,...,fop, mxcsr. - */ - cc->gdb_num_core_regs = CPU_NB_REGS * 2 + 25; + cc->gdb_arch_name = x86_gdb_arch_name; +#ifdef TARGET_X86_64 + cc->gdb_core_xml_file = "i386-64bit-core.xml"; + cc->gdb_num_core_regs = 40; +#else + cc->gdb_core_xml_file = "i386-32bit-core.xml"; + cc->gdb_num_core_regs = 32; +#endif #ifndef CONFIG_USER_ONLY cc->debug_excp_handler = breakpoint_handler; #endif