From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LrfL2-0007HI-UA for qemu-devel@nongnu.org; Wed, 08 Apr 2009 17:29:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LrfL1-0007Gu-FJ for qemu-devel@nongnu.org; Wed, 08 Apr 2009 17:29:39 -0400 Received: from [199.232.76.173] (port=46121 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LrfL1-0007Gp-3i for qemu-devel@nongnu.org; Wed, 08 Apr 2009 17:29:39 -0400 Received: from savannah.gnu.org ([199.232.41.3]:51298 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LrfL0-00021h-Nv for qemu-devel@nongnu.org; Wed, 08 Apr 2009 17:29:38 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LrfL0-0008GF-2A for qemu-devel@nongnu.org; Wed, 08 Apr 2009 21:29:38 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LrfKz-0008GA-Qx for qemu-devel@nongnu.org; Wed, 08 Apr 2009 21:29:37 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Wed, 08 Apr 2009 21:29:37 +0000 Subject: [Qemu-devel] [7039] factor out setting pc in gdbstub Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 7039 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7039 Author: aurel32 Date: 2009-04-08 21:29:37 +0000 (Wed, 08 Apr 2009) Log Message: ----------- factor out setting pc in gdbstub The code for handling the c and s packets both contain code for setting the pc. Move that code out to a common function. Signed-off-by: Nathan Froyd Acked-by: Jan Kiszka Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/gdbstub.c Modified: trunk/gdbstub.c =================================================================== --- trunk/gdbstub.c 2009-04-08 21:29:30 UTC (rev 7038) +++ trunk/gdbstub.c 2009-04-08 21:29:37 UTC (rev 7039) @@ -1512,6 +1512,29 @@ } } +static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) +{ +#if defined(TARGET_I386) + s->c_cpu->eip = pc; + cpu_synchronize_state(s->c_cpu, 1); +#elif defined (TARGET_PPC) + s->c_cpu->nip = pc; +#elif defined (TARGET_SPARC) + s->c_cpu->pc = pc; + s->c_cpu->npc = pc + 4; +#elif defined (TARGET_ARM) + s->c_cpu->regs[15] = pc; +#elif defined (TARGET_SH4) + s->c_cpu->pc = pc; +#elif defined (TARGET_MIPS) + s->c_cpu->active_tc.PC = pc; +#elif defined (TARGET_CRIS) + s->c_cpu->pc = pc; +#elif defined (TARGET_ALPHA) + s->c_cpu->pc = pc; +#endif +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *env; @@ -1542,25 +1565,7 @@ case 'c': if (*p != '\0') { addr = strtoull(p, (char **)&p, 16); -#if defined(TARGET_I386) - s->c_cpu->eip = addr; - cpu_synchronize_state(s->c_cpu, 1); -#elif defined (TARGET_PPC) - s->c_cpu->nip = addr; -#elif defined (TARGET_SPARC) - s->c_cpu->pc = addr; - s->c_cpu->npc = addr + 4; -#elif defined (TARGET_ARM) - s->c_cpu->regs[15] = addr; -#elif defined (TARGET_SH4) - s->c_cpu->pc = addr; -#elif defined (TARGET_MIPS) - s->c_cpu->active_tc.PC = addr; -#elif defined (TARGET_CRIS) - s->c_cpu->pc = addr; -#elif defined (TARGET_ALPHA) - s->c_cpu->pc = addr; -#endif + gdb_set_cpu_pc(s, addr); } s->signal = 0; gdb_continue(s); @@ -1584,25 +1589,7 @@ case 's': if (*p != '\0') { addr = strtoull(p, (char **)&p, 16); -#if defined(TARGET_I386) - s->c_cpu->eip = addr; - cpu_synchronize_state(s->c_cpu, 1); -#elif defined (TARGET_PPC) - s->c_cpu->nip = addr; -#elif defined (TARGET_SPARC) - s->c_cpu->pc = addr; - s->c_cpu->npc = addr + 4; -#elif defined (TARGET_ARM) - s->c_cpu->regs[15] = addr; -#elif defined (TARGET_SH4) - s->c_cpu->pc = addr; -#elif defined (TARGET_MIPS) - s->c_cpu->active_tc.PC = addr; -#elif defined (TARGET_CRIS) - s->c_cpu->pc = addr; -#elif defined (TARGET_ALPHA) - s->c_cpu->pc = addr; -#endif + gdb_set_cpu_pc(s, addr); } cpu_single_step(s->c_cpu, sstep_flags); gdb_continue(s);