Diff for /qemu/gdbstub.c between versions 1.1.1.13 and 1.1.1.14

version 1.1.1.13, 2018/04/24 19:16:34 version 1.1.1.14, 2018/04/24 19:33:31
Line 42 Line 42
 #include "kvm.h"  #include "kvm.h"
   
 #ifndef TARGET_CPU_MEMORY_RW_DEBUG  #ifndef TARGET_CPU_MEMORY_RW_DEBUG
 static inline int target_memory_rw_debug(CPUState *env, target_ulong addr,  static inline int target_memory_rw_debug(CPUArchState *env, target_ulong addr,
                                          uint8_t *buf, int len, int is_write)                                           uint8_t *buf, int len, int is_write)
 {  {
     return cpu_memory_rw_debug(env, addr, buf, len, is_write);      return cpu_memory_rw_debug(env, addr, buf, len, is_write);
Line 284  enum RSState { Line 284  enum RSState {
     RS_GETLINE,      RS_GETLINE,
     RS_CHKSUM1,      RS_CHKSUM1,
     RS_CHKSUM2,      RS_CHKSUM2,
     RS_SYSCALL,  
 };  };
 typedef struct GDBState {  typedef struct GDBState {
     CPUState *c_cpu; /* current CPU for step/continue ops */      CPUArchState *c_cpu; /* current CPU for step/continue ops */
     CPUState *g_cpu; /* current CPU for other ops */      CPUArchState *g_cpu; /* current CPU for other ops */
     CPUState *query_cpu; /* for q{f|s}ThreadInfo */      CPUArchState *query_cpu; /* for q{f|s}ThreadInfo */
     enum RSState state; /* parsing state */      enum RSState state; /* parsing state */
     char line_buf[MAX_PACKET_LENGTH];      char line_buf[MAX_PACKET_LENGTH];
     int line_buf_index;      int line_buf_index;
Line 304  typedef struct GDBState { Line 303  typedef struct GDBState {
     CharDriverState *chr;      CharDriverState *chr;
     CharDriverState *mon_chr;      CharDriverState *mon_chr;
 #endif  #endif
       char syscall_buf[256];
       gdb_syscall_complete_cb current_syscall_cb;
 } GDBState;  } GDBState;
   
 /* By default use no IRQs and no timers while single stepping so as to  /* By default use no IRQs and no timers while single stepping so as to
Line 346  static int get_char(GDBState *s) Line 347  static int get_char(GDBState *s)
 }  }
 #endif  #endif
   
 static gdb_syscall_complete_cb gdb_current_syscall_cb;  
   
 static enum {  static enum {
     GDB_SYS_UNKNOWN,      GDB_SYS_UNKNOWN,
     GDB_SYS_ENABLED,      GDB_SYS_ENABLED,
Line 533  static const int gpr_map32[8] = { 0, 1,  Line 532  static const int gpr_map32[8] = { 0, 1, 
 #define IDX_XMM_REGS    (IDX_FP_REGS + 16)  #define IDX_XMM_REGS    (IDX_FP_REGS + 16)
 #define IDX_MXCSR_REG   (IDX_XMM_REGS + CPU_NB_REGS)  #define IDX_MXCSR_REG   (IDX_XMM_REGS + CPU_NB_REGS)
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUX86State *env, uint8_t *mem_buf, int n)
 {  {
     if (n < CPU_NB_REGS) {      if (n < CPU_NB_REGS) {
         if (TARGET_LONG_BITS == 64 && env->hflags & HF_CS64_MASK) {          if (TARGET_LONG_BITS == 64 && env->hflags & HF_CS64_MASK) {
Line 590  static int cpu_gdb_read_register(CPUStat Line 589  static int cpu_gdb_read_register(CPUStat
     return 0;      return 0;
 }  }
   
 static int cpu_x86_gdb_load_seg(CPUState *env, int sreg, uint8_t *mem_buf)  static int cpu_x86_gdb_load_seg(CPUX86State *env, int sreg, uint8_t *mem_buf)
 {  {
     uint16_t selector = ldl_p(mem_buf);      uint16_t selector = ldl_p(mem_buf);
   
Line 615  static int cpu_x86_gdb_load_seg(CPUState Line 614  static int cpu_x86_gdb_load_seg(CPUState
     return 4;      return 4;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUX86State *env, uint8_t *mem_buf, int n)
 {  {
     uint32_t tmp;      uint32_t tmp;
   
Line 703  static int cpu_gdb_write_register(CPUSta Line 702  static int cpu_gdb_write_register(CPUSta
 #define GDB_CORE_XML "power-core.xml"  #define GDB_CORE_XML "power-core.xml"
 #endif  #endif
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUPPCState *env, uint8_t *mem_buf, int n)
 {  {
     if (n < 32) {      if (n < 32) {
         /* gprs */          /* gprs */
Line 740  static int cpu_gdb_read_register(CPUStat Line 739  static int cpu_gdb_read_register(CPUStat
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUPPCState *env, uint8_t *mem_buf, int n)
 {  {
     if (n < 32) {      if (n < 32) {
         /* gprs */          /* gprs */
Line 801  static int cpu_gdb_write_register(CPUSta Line 800  static int cpu_gdb_write_register(CPUSta
 #define GET_REGA(val) GET_REGL(val)  #define GET_REGA(val) GET_REGL(val)
 #endif  #endif
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUSPARCState *env, uint8_t *mem_buf, int n)
 {  {
     if (n < 8) {      if (n < 8) {
         /* g0..g7 */          /* g0..g7 */
Line 860  static int cpu_gdb_read_register(CPUStat Line 859  static int cpu_gdb_read_register(CPUStat
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUSPARCState *env, uint8_t *mem_buf, int n)
 {  {
 #if defined(TARGET_ABI32)  #if defined(TARGET_ABI32)
     abi_ulong tmp;      abi_ulong tmp;
Line 944  static int cpu_gdb_write_register(CPUSta Line 943  static int cpu_gdb_write_register(CPUSta
 #define NUM_CORE_REGS 26  #define NUM_CORE_REGS 26
 #define GDB_CORE_XML "arm-core.xml"  #define GDB_CORE_XML "arm-core.xml"
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUARMState *env, uint8_t *mem_buf, int n)
 {  {
     if (n < 16) {      if (n < 16) {
         /* Core integer register.  */          /* Core integer register.  */
Line 971  static int cpu_gdb_read_register(CPUStat Line 970  static int cpu_gdb_read_register(CPUStat
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUARMState *env, uint8_t *mem_buf, int n)
 {  {
     uint32_t tmp;      uint32_t tmp;
   
Line 1014  static int cpu_gdb_write_register(CPUSta Line 1013  static int cpu_gdb_write_register(CPUSta
   
 #define GDB_CORE_XML "cf-core.xml"  #define GDB_CORE_XML "cf-core.xml"
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUM68KState *env, uint8_t *mem_buf, int n)
 {  {
     if (n < 8) {      if (n < 8) {
         /* D0-D7 */          /* D0-D7 */
Line 1033  static int cpu_gdb_read_register(CPUStat Line 1032  static int cpu_gdb_read_register(CPUStat
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUM68KState *env, uint8_t *mem_buf, int n)
 {  {
     uint32_t tmp;      uint32_t tmp;
   
Line 1058  static int cpu_gdb_write_register(CPUSta Line 1057  static int cpu_gdb_write_register(CPUSta
   
 #define NUM_CORE_REGS 73  #define NUM_CORE_REGS 73
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUMIPSState *env, uint8_t *mem_buf, int n)
 {  {
     if (n < 32) {      if (n < 32) {
         GET_REGL(env->active_tc.gpr[n]);          GET_REGL(env->active_tc.gpr[n]);
Line 1104  static unsigned int ieee_rm[] = Line 1103  static unsigned int ieee_rm[] =
 #define RESTORE_ROUNDING_MODE \  #define RESTORE_ROUNDING_MODE \
     set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3], &env->active_fpu.fp_status)      set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3], &env->active_fpu.fp_status)
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUMIPSState *env, uint8_t *mem_buf, int n)
 {  {
     target_ulong tmp;      target_ulong tmp;
   
Line 1163  static int cpu_gdb_write_register(CPUSta Line 1162  static int cpu_gdb_write_register(CPUSta
   
 #define NUM_CORE_REGS 59  #define NUM_CORE_REGS 59
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUSH4State *env, uint8_t *mem_buf, int n)
 {  {
     if (n < 8) {      if (n < 8) {
         if ((env->sr & (SR_MD | SR_RB)) == (SR_MD | SR_RB)) {          if ((env->sr & (SR_MD | SR_RB)) == (SR_MD | SR_RB)) {
Line 1197  static int cpu_gdb_read_register(CPUStat Line 1196  static int cpu_gdb_read_register(CPUStat
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUSH4State *env, uint8_t *mem_buf, int n)
 {  {
     uint32_t tmp;      uint32_t tmp;
   
Line 1244  static int cpu_gdb_write_register(CPUSta Line 1243  static int cpu_gdb_write_register(CPUSta
   
 #define NUM_CORE_REGS (32 + 5)  #define NUM_CORE_REGS (32 + 5)
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUMBState *env, uint8_t *mem_buf, int n)
 {  {
     if (n < 32) {      if (n < 32) {
         GET_REG32(env->regs[n]);          GET_REG32(env->regs[n]);
Line 1254  static int cpu_gdb_read_register(CPUStat Line 1253  static int cpu_gdb_read_register(CPUStat
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUMBState *env, uint8_t *mem_buf, int n)
 {  {
     uint32_t tmp;      uint32_t tmp;
   
Line 1275  static int cpu_gdb_write_register(CPUSta Line 1274  static int cpu_gdb_write_register(CPUSta
 #define NUM_CORE_REGS 49  #define NUM_CORE_REGS 49
   
 static int  static int
 read_register_crisv10(CPUState *env, uint8_t *mem_buf, int n)  read_register_crisv10(CPUCRISState *env, uint8_t *mem_buf, int n)
 {  {
     if (n < 15) {      if (n < 15) {
         GET_REG32(env->regs[n]);          GET_REG32(env->regs[n]);
Line 1307  read_register_crisv10(CPUState *env, uin Line 1306  read_register_crisv10(CPUState *env, uin
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUCRISState *env, uint8_t *mem_buf, int n)
 {  {
     uint8_t srs;      uint8_t srs;
   
Line 1337  static int cpu_gdb_read_register(CPUStat Line 1336  static int cpu_gdb_read_register(CPUStat
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUCRISState *env, uint8_t *mem_buf, int n)
 {  {
     uint32_t tmp;      uint32_t tmp;
   
Line 1370  static int cpu_gdb_write_register(CPUSta Line 1369  static int cpu_gdb_write_register(CPUSta
   
 #define NUM_CORE_REGS 67  #define NUM_CORE_REGS 67
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUAlphaState *env, uint8_t *mem_buf, int n)
 {  {
     uint64_t val;      uint64_t val;
     CPU_DoubleU d;      CPU_DoubleU d;
Line 1404  static int cpu_gdb_read_register(CPUStat Line 1403  static int cpu_gdb_read_register(CPUStat
     GET_REGL(val);      GET_REGL(val);
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUAlphaState *env, uint8_t *mem_buf, int n)
 {  {
     target_ulong tmp = ldtul_p(mem_buf);      target_ulong tmp = ldtul_p(mem_buf);
     CPU_DoubleU d;      CPU_DoubleU d;
Line 1440  static int cpu_gdb_write_register(CPUSta Line 1439  static int cpu_gdb_write_register(CPUSta
   
 #define NUM_CORE_REGS S390_NUM_TOTAL_REGS  #define NUM_CORE_REGS S390_NUM_TOTAL_REGS
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUS390XState *env, uint8_t *mem_buf, int n)
 {  {
     switch (n) {      switch (n) {
         case S390_PSWM_REGNUM: GET_REGL(env->psw.mask); break;          case S390_PSWM_REGNUM: GET_REGL(env->psw.mask); break;
Line 1464  static int cpu_gdb_read_register(CPUStat Line 1463  static int cpu_gdb_read_register(CPUStat
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUS390XState *env, uint8_t *mem_buf, int n)
 {  {
     target_ulong tmpl;      target_ulong tmpl;
     uint32_t tmp32;      uint32_t tmp32;
Line 1494  static int cpu_gdb_write_register(CPUSta Line 1493  static int cpu_gdb_write_register(CPUSta
 #include "hw/lm32_pic.h"  #include "hw/lm32_pic.h"
 #define NUM_CORE_REGS (32 + 7)  #define NUM_CORE_REGS (32 + 7)
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPULM32State *env, uint8_t *mem_buf, int n)
 {  {
     if (n < 32) {      if (n < 32) {
         GET_REG32(env->regs[n]);          GET_REG32(env->regs[n]);
Line 1527  static int cpu_gdb_read_register(CPUStat Line 1526  static int cpu_gdb_read_register(CPUStat
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPULM32State *env, uint8_t *mem_buf, int n)
 {  {
     uint32_t tmp;      uint32_t tmp;
   
Line 1573  static int cpu_gdb_write_register(CPUSta Line 1572  static int cpu_gdb_write_register(CPUSta
 #define NUM_CORE_REGS (env->config->gdb_regmap.num_regs)  #define NUM_CORE_REGS (env->config->gdb_regmap.num_regs)
 #define num_g_regs NUM_CORE_REGS  #define num_g_regs NUM_CORE_REGS
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUXtensaState *env, uint8_t *mem_buf, int n)
 {  {
     const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n;      const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n;
   
Line 1610  static int cpu_gdb_read_register(CPUStat Line 1609  static int cpu_gdb_read_register(CPUStat
     }      }
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUXtensaState *env, uint8_t *mem_buf, int n)
 {  {
     uint32_t tmp;      uint32_t tmp;
     const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n;      const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n;
Line 1655  static int cpu_gdb_write_register(CPUSta Line 1654  static int cpu_gdb_write_register(CPUSta
   
 #define NUM_CORE_REGS 0  #define NUM_CORE_REGS 0
   
 static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_read_register(CPUArchState *env, uint8_t *mem_buf, int n)
 {  {
     return 0;      return 0;
 }  }
   
 static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)  static int cpu_gdb_write_register(CPUArchState *env, uint8_t *mem_buf, int n)
 {  {
     return 0;      return 0;
 }  }
Line 1736  static const char *get_feature_xml(const Line 1735  static const char *get_feature_xml(const
 }  }
 #endif  #endif
   
 static int gdb_read_register(CPUState *env, uint8_t *mem_buf, int reg)  static int gdb_read_register(CPUArchState *env, uint8_t *mem_buf, int reg)
 {  {
     GDBRegisterState *r;      GDBRegisterState *r;
   
Line 1751  static int gdb_read_register(CPUState *e Line 1750  static int gdb_read_register(CPUState *e
     return 0;      return 0;
 }  }
   
 static int gdb_write_register(CPUState *env, uint8_t *mem_buf, int reg)  static int gdb_write_register(CPUArchState *env, uint8_t *mem_buf, int reg)
 {  {
     GDBRegisterState *r;      GDBRegisterState *r;
   
Line 1773  static int gdb_write_register(CPUState * Line 1772  static int gdb_write_register(CPUState *
    gdb reading a CPU register, and set_reg is gdb modifying a CPU register.     gdb reading a CPU register, and set_reg is gdb modifying a CPU register.
  */   */
   
 void gdb_register_coprocessor(CPUState * env,  void gdb_register_coprocessor(CPUArchState * env,
                              gdb_reg_cb get_reg, gdb_reg_cb set_reg,                               gdb_reg_cb get_reg, gdb_reg_cb set_reg,
                              int num_regs, const char *xml, int g_pos)                               int num_regs, const char *xml, int g_pos)
 {  {
Line 1820  static const int xlat_gdb_type[] = { Line 1819  static const int xlat_gdb_type[] = {
   
 static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int type)  static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int type)
 {  {
     CPUState *env;      CPUArchState *env;
     int err = 0;      int err = 0;
   
     if (kvm_enabled())      if (kvm_enabled())
Line 1854  static int gdb_breakpoint_insert(target_ Line 1853  static int gdb_breakpoint_insert(target_
   
 static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type)  static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type)
 {  {
     CPUState *env;      CPUArchState *env;
     int err = 0;      int err = 0;
   
     if (kvm_enabled())      if (kvm_enabled())
Line 1887  static int gdb_breakpoint_remove(target_ Line 1886  static int gdb_breakpoint_remove(target_
   
 static void gdb_breakpoint_remove_all(void)  static void gdb_breakpoint_remove_all(void)
 {  {
     CPUState *env;      CPUArchState *env;
   
     if (kvm_enabled()) {      if (kvm_enabled()) {
         kvm_remove_all_breakpoints(gdbserver_state->c_cpu);          kvm_remove_all_breakpoints(gdbserver_state->c_cpu);
Line 1904  static void gdb_breakpoint_remove_all(vo Line 1903  static void gdb_breakpoint_remove_all(vo
   
 static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)  static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)
 {  {
 #if defined(TARGET_I386)  
     cpu_synchronize_state(s->c_cpu);      cpu_synchronize_state(s->c_cpu);
   #if defined(TARGET_I386)
     s->c_cpu->eip = pc;      s->c_cpu->eip = pc;
 #elif defined (TARGET_PPC)  #elif defined (TARGET_PPC)
     s->c_cpu->nip = pc;      s->c_cpu->nip = pc;
Line 1930  static void gdb_set_cpu_pc(GDBState *s,  Line 1929  static void gdb_set_cpu_pc(GDBState *s, 
 #elif defined (TARGET_ALPHA)  #elif defined (TARGET_ALPHA)
     s->c_cpu->pc = pc;      s->c_cpu->pc = pc;
 #elif defined (TARGET_S390X)  #elif defined (TARGET_S390X)
     cpu_synchronize_state(s->c_cpu);  
     s->c_cpu->psw.addr = pc;      s->c_cpu->psw.addr = pc;
 #elif defined (TARGET_LM32)  #elif defined (TARGET_LM32)
     s->c_cpu->pc = pc;      s->c_cpu->pc = pc;
Line 1939  static void gdb_set_cpu_pc(GDBState *s,  Line 1937  static void gdb_set_cpu_pc(GDBState *s, 
 #endif  #endif
 }  }
   
 static inline int gdb_id(CPUState *env)  static inline int gdb_id(CPUArchState *env)
 {  {
 #if defined(CONFIG_USER_ONLY) && defined(CONFIG_USE_NPTL)  #if defined(CONFIG_USER_ONLY) && defined(CONFIG_USE_NPTL)
     return env->host_tid;      return env->host_tid;
Line 1948  static inline int gdb_id(CPUState *env) Line 1946  static inline int gdb_id(CPUState *env)
 #endif  #endif
 }  }
   
 static CPUState *find_cpu(uint32_t thread_id)  static CPUArchState *find_cpu(uint32_t thread_id)
 {  {
     CPUState *env;      CPUArchState *env;
   
     for (env = first_cpu; env != NULL; env = env->next_cpu) {      for (env = first_cpu; env != NULL; env = env->next_cpu) {
         if (gdb_id(env) == thread_id) {          if (gdb_id(env) == thread_id) {
Line 1963  static CPUState *find_cpu(uint32_t threa Line 1961  static CPUState *find_cpu(uint32_t threa
   
 static int gdb_handle_packet(GDBState *s, const char *line_buf)  static int gdb_handle_packet(GDBState *s, const char *line_buf)
 {  {
     CPUState *env;      CPUArchState *env;
     const char *p;      const char *p;
     uint32_t thread;      uint32_t thread;
     int ch, reg_size, type, res;      int ch, reg_size, type, res;
Line 2062  static int gdb_handle_packet(GDBState *s Line 2060  static int gdb_handle_packet(GDBState *s
             goto unknown_command;              goto unknown_command;
         }          }
     case 'k':      case 'k':
   #ifdef CONFIG_USER_ONLY
         /* Kill the target */          /* Kill the target */
         fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");          fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");
         exit(0);          exit(0);
   #endif
     case 'D':      case 'D':
         /* Detach packet */          /* Detach packet */
         gdb_breakpoint_remove_all();          gdb_breakpoint_remove_all();
Line 2095  static int gdb_handle_packet(GDBState *s Line 2095  static int gdb_handle_packet(GDBState *s
             if (*p == ',')              if (*p == ',')
                 p++;                  p++;
             type = *p;              type = *p;
             if (gdb_current_syscall_cb)              if (s->current_syscall_cb) {
                 gdb_current_syscall_cb(s->c_cpu, ret, err);                  s->current_syscall_cb(s->c_cpu, ret, err);
                   s->current_syscall_cb = NULL;
               }
             if (type == 'C') {              if (type == 'C') {
                 put_packet(s, "T02");                  put_packet(s, "T02");
             } else {              } else {
Line 2381  static int gdb_handle_packet(GDBState *s Line 2383  static int gdb_handle_packet(GDBState *s
     return RS_IDLE;      return RS_IDLE;
 }  }
   
 void gdb_set_stop_cpu(CPUState *env)  void gdb_set_stop_cpu(CPUArchState *env)
 {  {
     gdbserver_state->c_cpu = env;      gdbserver_state->c_cpu = env;
     gdbserver_state->g_cpu = env;      gdbserver_state->g_cpu = env;
Line 2391  void gdb_set_stop_cpu(CPUState *env) Line 2393  void gdb_set_stop_cpu(CPUState *env)
 static void gdb_vm_state_change(void *opaque, int running, RunState state)  static void gdb_vm_state_change(void *opaque, int running, RunState state)
 {  {
     GDBState *s = gdbserver_state;      GDBState *s = gdbserver_state;
     CPUState *env = s->c_cpu;      CPUArchState *env = s->c_cpu;
     char buf[256];      char buf[256];
     const char *type;      const char *type;
     int ret;      int ret;
   
     if (running || s->state == RS_INACTIVE || s->state == RS_SYSCALL) {      if (running || s->state == RS_INACTIVE) {
           return;
       }
       /* Is there a GDB syscall waiting to be sent?  */
       if (s->current_syscall_cb) {
           put_packet(s, s->syscall_buf);
         return;          return;
     }      }
     switch (state) {      switch (state) {
Line 2466  send_packet: Line 2473  send_packet:
 void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)  void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
 {  {
     va_list va;      va_list va;
     char buf[256];  
     char *p;      char *p;
       char *p_end;
     target_ulong addr;      target_ulong addr;
     uint64_t i64;      uint64_t i64;
     GDBState *s;      GDBState *s;
Line 2475  void gdb_do_syscall(gdb_syscall_complete Line 2482  void gdb_do_syscall(gdb_syscall_complete
     s = gdbserver_state;      s = gdbserver_state;
     if (!s)      if (!s)
         return;          return;
     gdb_current_syscall_cb = cb;      s->current_syscall_cb = cb;
     s->state = RS_SYSCALL;  
 #ifndef CONFIG_USER_ONLY  #ifndef CONFIG_USER_ONLY
     vm_stop(RUN_STATE_DEBUG);      vm_stop(RUN_STATE_DEBUG);
 #endif  #endif
     s->state = RS_IDLE;  
     va_start(va, fmt);      va_start(va, fmt);
     p = buf;      p = s->syscall_buf;
       p_end = &s->syscall_buf[sizeof(s->syscall_buf)];
     *(p++) = 'F';      *(p++) = 'F';
     while (*fmt) {      while (*fmt) {
         if (*fmt == '%') {          if (*fmt == '%') {
Line 2490  void gdb_do_syscall(gdb_syscall_complete Line 2496  void gdb_do_syscall(gdb_syscall_complete
             switch (*fmt++) {              switch (*fmt++) {
             case 'x':              case 'x':
                 addr = va_arg(va, target_ulong);                  addr = va_arg(va, target_ulong);
                 p += snprintf(p, &buf[sizeof(buf)] - p, TARGET_FMT_lx, addr);                  p += snprintf(p, p_end - p, TARGET_FMT_lx, addr);
                 break;                  break;
             case 'l':              case 'l':
                 if (*(fmt++) != 'x')                  if (*(fmt++) != 'x')
                     goto bad_format;                      goto bad_format;
                 i64 = va_arg(va, uint64_t);                  i64 = va_arg(va, uint64_t);
                 p += snprintf(p, &buf[sizeof(buf)] - p, "%" PRIx64, i64);                  p += snprintf(p, p_end - p, "%" PRIx64, i64);
                 break;                  break;
             case 's':              case 's':
                 addr = va_arg(va, target_ulong);                  addr = va_arg(va, target_ulong);
                 p += snprintf(p, &buf[sizeof(buf)] - p, TARGET_FMT_lx "/%x",                  p += snprintf(p, p_end - p, TARGET_FMT_lx "/%x",
                               addr, va_arg(va, int));                                addr, va_arg(va, int));
                 break;                  break;
             default:              default:
Line 2515  void gdb_do_syscall(gdb_syscall_complete Line 2521  void gdb_do_syscall(gdb_syscall_complete
     }      }
     *p = 0;      *p = 0;
     va_end(va);      va_end(va);
     put_packet(s, buf);  
 #ifdef CONFIG_USER_ONLY  #ifdef CONFIG_USER_ONLY
       put_packet(s, s->syscall_buf);
     gdb_handlesig(s->c_cpu, 0);      gdb_handlesig(s->c_cpu, 0);
 #else  #else
       /* In this case wait to send the syscall packet until notification that
          the CPU has stopped.  This must be done because if the packet is sent
          now the reply from the syscall request could be received while the CPU
          is still in the running state, which can cause packets to be dropped
          and state transition 'T' packets to be sent while the syscall is still
          being processed.  */
     cpu_exit(s->c_cpu);      cpu_exit(s->c_cpu);
 #endif  #endif
 }  }
Line 2600  static void gdb_read_byte(GDBState *s, i Line 2612  static void gdb_read_byte(GDBState *s, i
 }  }
   
 /* Tell the remote gdb that the process has exited.  */  /* Tell the remote gdb that the process has exited.  */
 void gdb_exit(CPUState *env, int code)  void gdb_exit(CPUArchState *env, int code)
 {  {
   GDBState *s;    GDBState *s;
   char buf[4];    char buf[4];
Line 2640  gdb_queuesig (void) Line 2652  gdb_queuesig (void)
 }  }
   
 int  int
 gdb_handlesig (CPUState *env, int sig)  gdb_handlesig (CPUArchState *env, int sig)
 {  {
   GDBState *s;    GDBState *s;
   char buf[256];    char buf[256];
Line 2678  gdb_handlesig (CPUState *env, int sig) Line 2690  gdb_handlesig (CPUState *env, int sig)
         }          }
       else if (n == 0 || errno != EAGAIN)        else if (n == 0 || errno != EAGAIN)
         {          {
           /* XXX: Connection closed.  Should probably wait for annother            /* XXX: Connection closed.  Should probably wait for another
              connection before continuing.  */               connection before continuing.  */
           return sig;            return sig;
         }          }
Line 2689  gdb_handlesig (CPUState *env, int sig) Line 2701  gdb_handlesig (CPUState *env, int sig)
 }  }
   
 /* Tell the remote gdb that the process has exited due to SIG.  */  /* Tell the remote gdb that the process has exited due to SIG.  */
 void gdb_signalled(CPUState *env, int sig)  void gdb_signalled(CPUArchState *env, int sig)
 {  {
   GDBState *s;    GDBState *s;
   char buf[4];    char buf[4];
Line 2762  static int gdbserver_open(int port) Line 2774  static int gdbserver_open(int port)
     ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));      ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
     if (ret < 0) {      if (ret < 0) {
         perror("bind");          perror("bind");
           close(fd);
         return -1;          return -1;
     }      }
     ret = listen(fd, 0);      ret = listen(fd, 0);
     if (ret < 0) {      if (ret < 0) {
         perror("listen");          perror("listen");
           close(fd);
         return -1;          return -1;
     }      }
     return fd;      return fd;
Line 2783  int gdbserver_start(int port) Line 2797  int gdbserver_start(int port)
 }  }
   
 /* Disable gdb stub for child processes.  */  /* Disable gdb stub for child processes.  */
 void gdbserver_fork(CPUState *env)  void gdbserver_fork(CPUArchState *env)
 {  {
     GDBState *s = gdbserver_state;      GDBState *s = gdbserver_state;
     if (gdbserver_fd < 0 || s->fd < 0)      if (gdbserver_fd < 0 || s->fd < 0)
Line 2915  int gdbserver_start(const char *device) Line 2929  int gdbserver_start(const char *device)
     s->chr = chr;      s->chr = chr;
     s->state = chr ? RS_IDLE : RS_INACTIVE;      s->state = chr ? RS_IDLE : RS_INACTIVE;
     s->mon_chr = mon_chr;      s->mon_chr = mon_chr;
       s->current_syscall_cb = NULL;
   
     return 0;      return 0;
 }  }

Removed from v.1.1.1.13  
changed lines
  Added in v.1.1.1.14


unix.superglobalmegacorp.com