Received: from eggs.gnu.org ([2001:4830:134:3::10]:45713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMHB8-0005ch-QU for qemu-devel@nongnu.org; Wed, 28 Dec 2016 11:34:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMHB5-0007Ts-MK for qemu-devel@nongnu.org; Wed, 28 Dec 2016 11:34:14 -0500 Received: from smtp1.lauterbach.com ([62.154.241.196]:34650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cMHB5-0007SF-BS for qemu-devel@nongnu.org; Wed, 28 Dec 2016 11:34:11 -0500 From: Abdallah Bouassida Message-ID: <2b3c8119-1602-28c7-eab4-296593877103@lauterbach.com> Date: Wed, 28 Dec 2016 17:34:02 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] target-x86:Add GDB XML register description support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Khaled Jmal , pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com [Qemu-devel] [PATCH] target-x86: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 --- configure | 2 ++ gdb-xml/32bit-core.xml | 65 ++++++++++++++++++++++++++++++++++++++++++++ gdb-xml/64bit-core.xml | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ target/i386/cpu.c | 21 ++++++++++++--- 4 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 gdb-xml/32bit-core.xml create mode 100644 gdb-xml/64bit-core.xml diff --git a/configure b/configure index 218df87..b701d1e 100755 --- a/configure +++ b/configure @@ -5890,9 +5890,11 @@ TARGET_ABI_DIR="" case "$target_name" in i386) + gdb_xml_files="32bit-core.xml" ;; x86_64) TARGET_BASE_ARCH=i386 + gdb_xml_files="64bit-core.xml" ;; alpha) ;; diff --git a/gdb-xml/32bit-core.xml b/gdb-xml/32bit-core.xml new file mode 100644 index 0000000..7aeeeca --- /dev/null +++ b/gdb-xml/32bit-core.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb-xml/64bit-core.xml b/gdb-xml/64bit-core.xml new file mode 100644 index 0000000..5088d84 --- /dev/null +++ b/gdb-xml/64bit-core.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b0640f1..d712e8b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2371,6 +2371,15 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp) } +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)); @@ -3720,10 +3729,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 = "64bit-core.xml"; + cc->gdb_num_core_regs = 40; +#else + cc->gdb_core_xml_file = "32bit-core.xml"; + cc->gdb_num_core_regs = 32; +#endif #ifndef CONFIG_USER_ONLY cc->debug_excp_handler = breakpoint_handler; #endif -- 1.9.1