Commit 41625033686b7cb8bf8966c7d0907ec208d6a028

Authored by bellard
1 parent 6bae7ed8

removed RS_CONTINUE 'state'


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1389 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 21 additions and 17 deletions
gdbstub.c
@@ -42,17 +42,19 @@ enum RSState { @@ -42,17 +42,19 @@ enum RSState {
42 RS_GETLINE, 42 RS_GETLINE,
43 RS_CHKSUM1, 43 RS_CHKSUM1,
44 RS_CHKSUM2, 44 RS_CHKSUM2,
45 - RS_CONTINUE  
46 }; 45 };
47 /* XXX: This is not thread safe. Do we care? */ 46 /* XXX: This is not thread safe. Do we care? */
48 static int gdbserver_fd = -1; 47 static int gdbserver_fd = -1;
49 48
50 typedef struct GDBState { 49 typedef struct GDBState {
51 - enum RSState state; 50 + enum RSState state; /* parsing state */
52 int fd; 51 int fd;
53 char line_buf[4096]; 52 char line_buf[4096];
54 int line_buf_index; 53 int line_buf_index;
55 int line_csum; 54 int line_csum;
  55 +#ifdef CONFIG_USER_ONLY
  56 + int running_state;
  57 +#endif
56 } GDBState; 58 } GDBState;
57 59
58 #ifdef CONFIG_USER_ONLY 60 #ifdef CONFIG_USER_ONLY
@@ -431,7 +433,12 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf) @@ -431,7 +433,12 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf)
431 env->npc = addr + 4; 433 env->npc = addr + 4;
432 #endif 434 #endif
433 } 435 }
434 - return RS_CONTINUE; 436 +#ifdef CONFIG_USER_ONLY
  437 + s->running_state = 1;
  438 +#else
  439 + vm_start();
  440 +#endif
  441 + return RS_IDLE;
435 case 's': 442 case 's':
436 if (*p != '\0') { 443 if (*p != '\0') {
437 addr = strtoul(p, (char **)&p, 16); 444 addr = strtoul(p, (char **)&p, 16);
@@ -445,7 +452,12 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf) @@ -445,7 +452,12 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf)
445 #endif 452 #endif
446 } 453 }
447 cpu_single_step(env, 1); 454 cpu_single_step(env, 1);
448 - return RS_CONTINUE; 455 +#ifdef CONFIG_USER_ONLY
  456 + s->running_state = 1;
  457 +#else
  458 + vm_start();
  459 +#endif
  460 + return RS_IDLE;
449 case 'g': 461 case 'g':
450 reg_size = cpu_gdb_read_registers(env, mem_buf); 462 reg_size = cpu_gdb_read_registers(env, mem_buf);
451 memtohex(buf, mem_buf, reg_size); 463 memtohex(buf, mem_buf, reg_size);
@@ -556,8 +568,9 @@ static void gdb_read_byte(GDBState *s, CPUState *env, int ch) @@ -556,8 +568,9 @@ static void gdb_read_byte(GDBState *s, CPUState *env, int ch)
556 /* when the CPU is running, we cannot do anything except stop 568 /* when the CPU is running, we cannot do anything except stop
557 it when receiving a char */ 569 it when receiving a char */
558 vm_stop(EXCP_INTERRUPT); 570 vm_stop(EXCP_INTERRUPT);
559 - } else { 571 + } else
560 #endif 572 #endif
  573 + {
561 switch(s->state) { 574 switch(s->state) {
562 case RS_IDLE: 575 case RS_IDLE:
563 if (ch == '$') { 576 if (ch == '$') {
@@ -595,16 +608,8 @@ static void gdb_read_byte(GDBState *s, CPUState *env, int ch) @@ -595,16 +608,8 @@ static void gdb_read_byte(GDBState *s, CPUState *env, int ch)
595 s->state = gdb_handle_packet(s, env, s->line_buf); 608 s->state = gdb_handle_packet(s, env, s->line_buf);
596 } 609 }
597 break; 610 break;
598 - case RS_CONTINUE:  
599 -#ifndef CONFIG_USER_ONLY  
600 - vm_start();  
601 - s->state = RS_IDLE;  
602 -#endif  
603 - break;  
604 } 611 }
605 -#ifndef CONFIG_USER_ONLY  
606 } 612 }
607 -#endif  
608 } 613 }
609 614
610 #ifdef CONFIG_USER_ONLY 615 #ifdef CONFIG_USER_ONLY
@@ -630,11 +635,10 @@ gdb_handlesig (CPUState *env, int sig) @@ -630,11 +635,10 @@ gdb_handlesig (CPUState *env, int sig)
630 put_packet(s, buf); 635 put_packet(s, buf);
631 } 636 }
632 637
633 - /* TODO: How do we terminate this loop? */  
634 sig = 0; 638 sig = 0;
635 s->state = RS_IDLE; 639 s->state = RS_IDLE;
636 - while (s->state != RS_CONTINUE)  
637 - { 640 + s->running_state = 0;
  641 + while (s->running_state == 0) {
638 n = read (s->fd, buf, 256); 642 n = read (s->fd, buf, 256);
639 if (n > 0) 643 if (n > 0)
640 { 644 {
@@ -649,7 +653,7 @@ gdb_handlesig (CPUState *env, int sig) @@ -649,7 +653,7 @@ gdb_handlesig (CPUState *env, int sig)
649 connection before continuing. */ 653 connection before continuing. */
650 return sig; 654 return sig;
651 } 655 }
652 - } 656 + }
653 return sig; 657 return sig;
654 } 658 }
655 #else 659 #else