diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-07-26 12:06:08 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-07-26 12:06:08 +0000 |
commit | 4c3a88a284b288e0ed3c097de7fc07111d848003 (patch) | |
tree | 8f4a8190c97d326f26b4e7d603ac8f98c50e8706 /gdbstub.c | |
parent | d6b4936796b37f629879de69d847c5cdc4892157 (diff) |
gdb stub breakpoints support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@332 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'gdbstub.c')
-rw-r--r-- | gdbstub.c | 55 |
1 files changed, 50 insertions, 5 deletions
@@ -37,7 +37,7 @@ #include "thunk.h" #include "exec.h" -//#define DEBUG_GDB +#define DEBUG_GDB int gdbstub_fd = -1; @@ -283,11 +283,11 @@ static int memory_rw(uint8_t *buf, uint32_t addr, int len, int is_write) } /* port = 0 means default port */ -int cpu_gdbstub(void *opaque, void (*main_loop)(void *opaque), int port) +int cpu_gdbstub(void *opaque, int (*main_loop)(void *opaque), int port) { CPUState *env; const char *p; - int ret, ch, nb_regs, i; + int ret, ch, nb_regs, i, type; char buf[4096]; uint8_t mem_buf[2000]; uint32_t *registers; @@ -309,8 +309,19 @@ int cpu_gdbstub(void *opaque, void (*main_loop)(void *opaque), int port) put_packet(buf); break; case 'c': - main_loop(opaque); - snprintf(buf, sizeof(buf), "S%02x", 0); + if (*p != '\0') { + addr = strtoul(p, (char **)&p, 16); + env = cpu_gdbstub_get_env(opaque); +#if defined(TARGET_I386) + env->eip = addr; +#endif + } + ret = main_loop(opaque); + if (ret == EXCP_DEBUG) + ret = SIGTRAP; + else + ret = 0; + snprintf(buf, sizeof(buf), "S%02x", ret); put_packet(buf); break; case 'g': @@ -379,6 +390,40 @@ int cpu_gdbstub(void *opaque, void (*main_loop)(void *opaque), int port) else put_packet("OK"); break; + case 'Z': + type = strtoul(p, (char **)&p, 16); + if (*p == ',') + p++; + addr = strtoul(p, (char **)&p, 16); + if (*p == ',') + p++; + len = strtoul(p, (char **)&p, 16); + if (type == 0 || type == 1) { + env = cpu_gdbstub_get_env(opaque); + if (cpu_breakpoint_insert(env, addr) < 0) + goto breakpoint_error; + put_packet("OK"); + } else { + breakpoint_error: + put_packet("ENN"); + } + break; + case 'z': + type = strtoul(p, (char **)&p, 16); + if (*p == ',') + p++; + addr = strtoul(p, (char **)&p, 16); + if (*p == ',') + p++; + len = strtoul(p, (char **)&p, 16); + if (type == 0 || type == 1) { + env = cpu_gdbstub_get_env(opaque); + cpu_breakpoint_remove(env, addr); + put_packet("OK"); + } else { + goto breakpoint_error; + } + break; default: /* put empty packet */ buf[0] = '\0'; |