Commit fab9d28414ecbfbb2d89d9fecb47b7c982513072

Authored by aurel32
1 parent dbfe4c36

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 <froydnj@codesourcery.com>
Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7039 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 25 additions and 38 deletions
gdbstub.c
@@ -1512,6 +1512,29 @@ static void gdb_breakpoint_remove_all(void) @@ -1512,6 +1512,29 @@ static void gdb_breakpoint_remove_all(void)
1512 } 1512 }
1513 } 1513 }
1514 1514
  1515 +static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)
  1516 +{
  1517 +#if defined(TARGET_I386)
  1518 + s->c_cpu->eip = pc;
  1519 + cpu_synchronize_state(s->c_cpu, 1);
  1520 +#elif defined (TARGET_PPC)
  1521 + s->c_cpu->nip = pc;
  1522 +#elif defined (TARGET_SPARC)
  1523 + s->c_cpu->pc = pc;
  1524 + s->c_cpu->npc = pc + 4;
  1525 +#elif defined (TARGET_ARM)
  1526 + s->c_cpu->regs[15] = pc;
  1527 +#elif defined (TARGET_SH4)
  1528 + s->c_cpu->pc = pc;
  1529 +#elif defined (TARGET_MIPS)
  1530 + s->c_cpu->active_tc.PC = pc;
  1531 +#elif defined (TARGET_CRIS)
  1532 + s->c_cpu->pc = pc;
  1533 +#elif defined (TARGET_ALPHA)
  1534 + s->c_cpu->pc = pc;
  1535 +#endif
  1536 +}
  1537 +
1515 static int gdb_handle_packet(GDBState *s, const char *line_buf) 1538 static int gdb_handle_packet(GDBState *s, const char *line_buf)
1516 { 1539 {
1517 CPUState *env; 1540 CPUState *env;
@@ -1542,25 +1565,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) @@ -1542,25 +1565,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
1542 case 'c': 1565 case 'c':
1543 if (*p != '\0') { 1566 if (*p != '\0') {
1544 addr = strtoull(p, (char **)&p, 16); 1567 addr = strtoull(p, (char **)&p, 16);
1545 -#if defined(TARGET_I386)  
1546 - s->c_cpu->eip = addr;  
1547 - cpu_synchronize_state(s->c_cpu, 1);  
1548 -#elif defined (TARGET_PPC)  
1549 - s->c_cpu->nip = addr;  
1550 -#elif defined (TARGET_SPARC)  
1551 - s->c_cpu->pc = addr;  
1552 - s->c_cpu->npc = addr + 4;  
1553 -#elif defined (TARGET_ARM)  
1554 - s->c_cpu->regs[15] = addr;  
1555 -#elif defined (TARGET_SH4)  
1556 - s->c_cpu->pc = addr;  
1557 -#elif defined (TARGET_MIPS)  
1558 - s->c_cpu->active_tc.PC = addr;  
1559 -#elif defined (TARGET_CRIS)  
1560 - s->c_cpu->pc = addr;  
1561 -#elif defined (TARGET_ALPHA)  
1562 - s->c_cpu->pc = addr;  
1563 -#endif 1568 + gdb_set_cpu_pc(s, addr);
1564 } 1569 }
1565 s->signal = 0; 1570 s->signal = 0;
1566 gdb_continue(s); 1571 gdb_continue(s);
@@ -1584,25 +1589,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) @@ -1584,25 +1589,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
1584 case 's': 1589 case 's':
1585 if (*p != '\0') { 1590 if (*p != '\0') {
1586 addr = strtoull(p, (char **)&p, 16); 1591 addr = strtoull(p, (char **)&p, 16);
1587 -#if defined(TARGET_I386)  
1588 - s->c_cpu->eip = addr;  
1589 - cpu_synchronize_state(s->c_cpu, 1);  
1590 -#elif defined (TARGET_PPC)  
1591 - s->c_cpu->nip = addr;  
1592 -#elif defined (TARGET_SPARC)  
1593 - s->c_cpu->pc = addr;  
1594 - s->c_cpu->npc = addr + 4;  
1595 -#elif defined (TARGET_ARM)  
1596 - s->c_cpu->regs[15] = addr;  
1597 -#elif defined (TARGET_SH4)  
1598 - s->c_cpu->pc = addr;  
1599 -#elif defined (TARGET_MIPS)  
1600 - s->c_cpu->active_tc.PC = addr;  
1601 -#elif defined (TARGET_CRIS)  
1602 - s->c_cpu->pc = addr;  
1603 -#elif defined (TARGET_ALPHA)  
1604 - s->c_cpu->pc = addr;  
1605 -#endif 1592 + gdb_set_cpu_pc(s, addr);
1606 } 1593 }
1607 cpu_single_step(s->c_cpu, sstep_flags); 1594 cpu_single_step(s->c_cpu, sstep_flags);
1608 gdb_continue(s); 1595 gdb_continue(s);