summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-03-08 18:05:47 +0200
committerAvi Kivity <avi@redhat.com>2009-03-08 18:05:47 +0200
commitb2348016dfafa932523c2d4ac842ba82ce90edf1 (patch)
treee087c868f49ce9ee370ed3c6657ac0075ad4ae47 /gdbstub.c
parentkvm: external module: add kvm-ia64.c to hack files list (diff)
parentUse firmware configuration instead of NVRAM (initial patch by Aurelien Jarno) (diff)
downloadqemu-kvm-b2348016dfafa932523c2d4ac842ba82ce90edf1.tar.gz
qemu-kvm-b2348016dfafa932523c2d4ac842ba82ce90edf1.tar.bz2
qemu-kvm-b2348016dfafa932523c2d4ac842ba82ce90edf1.zip
Merge branch 'qemu-cvs'
* qemu-cvs: (135 commits) Use firmware configuration instead of NVRAM (initial patch by Aurelien Jarno) Add new entries to firmware configuration device Rename _BSD to HOST_BSD so that it's more obvious that it's defined by configure target-mips: remove dead code target-mips: rename helpers from do_ to helper_ do not pretend to support low voltage operation Fix correct reset value for ARM CP15 c1 auxiliary control register Work around QEMU GDB stub suboptimality Fix off-by-one errors for Altivec and SPE registers Use C99 initializers for BlockDriver methods clean build: Fix remaining m68k warnings clean build: Fix arm build warnings arm: Fix gic_irq_state.level bitfield type target-ppc: move the CD-ROM drive to the second IDE ppc_oldworld: swap the MACIO and CMD646 IDE controllers Use a dedicated function to request exit from execution loop Fix texinfo syntax errors. Disable BAT for 970 Fix mfcr on ppc64-softmmu Keep SLB in-CPU ... Conflicts: qemu/configure qemu/cpu-defs.h qemu/exec.c qemu/hw/pci-hotplug.c qemu/monitor.c qemu/net.c qemu/pc-bios/Makefile qemu/pc-bios/bios.bin qemu/qemu-tool.c qemu/sysemu.h qemu/vl.c Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'gdbstub.c')
-rw-r--r--gdbstub.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/gdbstub.c b/gdbstub.c
index a23e916a5..6a41f3f3b 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -30,6 +30,7 @@
#include "qemu.h"
#else
+#include "monitor.h"
#include "qemu-char.h"
#include "sysemu.h"
#include "gdbstub.h"
@@ -286,6 +287,7 @@ typedef struct GDBState {
int running_state;
#else
CharDriverState *chr;
+ CharDriverState *mon_chr;
#endif
} GDBState;
@@ -1818,7 +1820,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
}
break;
}
-#ifdef CONFIG_LINUX_USER
+#ifdef CONFIG_USER_ONLY
else if (strncmp(p, "Offsets", 7) == 0) {
TaskState *ts = s->c_cpu->opaque;
@@ -1831,7 +1833,22 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
put_packet(s, buf);
break;
}
-#endif
+#else /* !CONFIG_USER_ONLY */
+ else if (strncmp(p, "Rcmd,", 5) == 0) {
+ int len = strlen(p + 5);
+
+ if ((len % 2) != 0) {
+ put_packet(s, "E01");
+ break;
+ }
+ hextomem(mem_buf, p + 5, len);
+ len = len / 2;
+ mem_buf[len++] = 0;
+ qemu_chr_read(s->mon_chr, mem_buf, len);
+ put_packet(s, "OK");
+ break;
+ }
+#endif /* !CONFIG_USER_ONLY */
if (strncmp(p, "Supported", 9) == 0) {
snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH);
#ifdef GDB_CORE_XML
@@ -2007,7 +2024,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
#ifdef CONFIG_USER_ONLY
gdb_handlesig(s->c_cpu, 0);
#else
- cpu_interrupt(s->c_cpu, CPU_INTERRUPT_EXIT);
+ cpu_exit(s->c_cpu);
#endif
}
@@ -2294,6 +2311,35 @@ static void gdb_chr_event(void *opaque, int event)
}
}
+static void gdb_monitor_output(GDBState *s, const char *msg, int len)
+{
+ char buf[MAX_PACKET_LENGTH];
+
+ buf[0] = 'O';
+ if (len > (MAX_PACKET_LENGTH/2) - 1)
+ len = (MAX_PACKET_LENGTH/2) - 1;
+ memtohex(buf + 1, (uint8_t *)msg, len);
+ put_packet(s, buf);
+}
+
+static int gdb_monitor_write(CharDriverState *chr, const uint8_t *buf, int len)
+{
+ const char *p = (const char *)buf;
+ int max_sz;
+
+ max_sz = (sizeof(gdbserver_state->last_packet) - 2) / 2;
+ for (;;) {
+ if (len <= max_sz) {
+ gdb_monitor_output(gdbserver_state, p, len);
+ break;
+ }
+ gdb_monitor_output(gdbserver_state, p, max_sz);
+ p += max_sz;
+ len -= max_sz;
+ }
+ return len;
+}
+
int gdbserver_start(const char *port)
{
GDBState *s;
@@ -2325,6 +2371,12 @@ int gdbserver_start(const char *port)
qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,
gdb_chr_event, NULL);
qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
+
+ /* Initialize a monitor terminal for gdb */
+ s->mon_chr = qemu_mallocz(sizeof(*s->mon_chr));
+ s->mon_chr->chr_write = gdb_monitor_write;
+ monitor_init(s->mon_chr, 0);
+
return 0;
}
#endif