/[qemu]/qemu/gdbstub.c
ViewVC logotype

Diff of /qemu/gdbstub.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by bellard, Fri Jun 27 17:34:32 2003 UTC revision 1.2 by bellard, Sat Jul 26 12:06:08 2003 UTC
# Line 37  Line 37 
37  #include "thunk.h"  #include "thunk.h"
38  #include "exec.h"  #include "exec.h"
39    
40  //#define DEBUG_GDB  #define DEBUG_GDB
41    
42  int gdbstub_fd = -1;  int gdbstub_fd = -1;
43    
# Line 283  static int memory_rw(uint8_t *buf, uint3 Line 283  static int memory_rw(uint8_t *buf, uint3
283  }  }
284    
285  /* port = 0 means default port */  /* port = 0 means default port */
286  int cpu_gdbstub(void *opaque, void (*main_loop)(void *opaque), int port)  int cpu_gdbstub(void *opaque, int (*main_loop)(void *opaque), int port)
287  {  {
288      CPUState *env;      CPUState *env;
289      const char *p;      const char *p;
290      int ret, ch, nb_regs, i;      int ret, ch, nb_regs, i, type;
291      char buf[4096];      char buf[4096];
292      uint8_t mem_buf[2000];      uint8_t mem_buf[2000];
293      uint32_t *registers;      uint32_t *registers;
# Line 309  int cpu_gdbstub(void *opaque, void (*mai Line 309  int cpu_gdbstub(void *opaque, void (*mai
309              put_packet(buf);              put_packet(buf);
310              break;              break;
311          case 'c':          case 'c':
312              main_loop(opaque);              if (*p != '\0') {
313              snprintf(buf, sizeof(buf), "S%02x", 0);                  addr = strtoul(p, (char **)&p, 16);
314                    env = cpu_gdbstub_get_env(opaque);
315    #if defined(TARGET_I386)
316                    env->eip = addr;
317    #endif
318                }
319                ret = main_loop(opaque);
320                if (ret == EXCP_DEBUG)
321                    ret = SIGTRAP;
322                else
323                    ret = 0;
324                snprintf(buf, sizeof(buf), "S%02x", ret);
325              put_packet(buf);              put_packet(buf);
326              break;              break;
327          case 'g':          case 'g':
# Line 379  int cpu_gdbstub(void *opaque, void (*mai Line 390  int cpu_gdbstub(void *opaque, void (*mai
390              else              else
391                  put_packet("OK");                  put_packet("OK");
392              break;              break;
393            case 'Z':
394                type = strtoul(p, (char **)&p, 16);
395                if (*p == ',')
396                    p++;
397                addr = strtoul(p, (char **)&p, 16);
398                if (*p == ',')
399                    p++;
400                len = strtoul(p, (char **)&p, 16);
401                if (type == 0 || type == 1) {
402                    env = cpu_gdbstub_get_env(opaque);
403                    if (cpu_breakpoint_insert(env, addr) < 0)
404                        goto breakpoint_error;
405                    put_packet("OK");
406                } else {
407                breakpoint_error:
408                    put_packet("ENN");
409                }
410                break;
411            case 'z':
412                type = strtoul(p, (char **)&p, 16);
413                if (*p == ',')
414                    p++;
415                addr = strtoul(p, (char **)&p, 16);
416                if (*p == ',')
417                    p++;
418                len = strtoul(p, (char **)&p, 16);
419                if (type == 0 || type == 1) {
420                    env = cpu_gdbstub_get_env(opaque);
421                    cpu_breakpoint_remove(env, addr);
422                    put_packet("OK");
423                } else {
424                    goto breakpoint_error;
425                }
426                break;
427          default:          default:
428              /* put empty packet */              /* put empty packet */
429              buf[0] = '\0';              buf[0] = '\0';

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26