Commit 41625033686b7cb8bf8966c7d0907ec208d6a028
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 | 42 | RS_GETLINE, |
43 | 43 | RS_CHKSUM1, |
44 | 44 | RS_CHKSUM2, |
45 | - RS_CONTINUE | |
46 | 45 | }; |
47 | 46 | /* XXX: This is not thread safe. Do we care? */ |
48 | 47 | static int gdbserver_fd = -1; |
49 | 48 | |
50 | 49 | typedef struct GDBState { |
51 | - enum RSState state; | |
50 | + enum RSState state; /* parsing state */ | |
52 | 51 | int fd; |
53 | 52 | char line_buf[4096]; |
54 | 53 | int line_buf_index; |
55 | 54 | int line_csum; |
55 | +#ifdef CONFIG_USER_ONLY | |
56 | + int running_state; | |
57 | +#endif | |
56 | 58 | } GDBState; |
57 | 59 | |
58 | 60 | #ifdef CONFIG_USER_ONLY |
... | ... | @@ -431,7 +433,12 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf) |
431 | 433 | env->npc = addr + 4; |
432 | 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 | 442 | case 's': |
436 | 443 | if (*p != '\0') { |
437 | 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 | 452 | #endif |
446 | 453 | } |
447 | 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 | 461 | case 'g': |
450 | 462 | reg_size = cpu_gdb_read_registers(env, mem_buf); |
451 | 463 | memtohex(buf, mem_buf, reg_size); |
... | ... | @@ -556,8 +568,9 @@ static void gdb_read_byte(GDBState *s, CPUState *env, int ch) |
556 | 568 | /* when the CPU is running, we cannot do anything except stop |
557 | 569 | it when receiving a char */ |
558 | 570 | vm_stop(EXCP_INTERRUPT); |
559 | - } else { | |
571 | + } else | |
560 | 572 | #endif |
573 | + { | |
561 | 574 | switch(s->state) { |
562 | 575 | case RS_IDLE: |
563 | 576 | if (ch == '$') { |
... | ... | @@ -595,16 +608,8 @@ static void gdb_read_byte(GDBState *s, CPUState *env, int ch) |
595 | 608 | s->state = gdb_handle_packet(s, env, s->line_buf); |
596 | 609 | } |
597 | 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 | 615 | #ifdef CONFIG_USER_ONLY |
... | ... | @@ -630,11 +635,10 @@ gdb_handlesig (CPUState *env, int sig) |
630 | 635 | put_packet(s, buf); |
631 | 636 | } |
632 | 637 | |
633 | - /* TODO: How do we terminate this loop? */ | |
634 | 638 | sig = 0; |
635 | 639 | s->state = RS_IDLE; |
636 | - while (s->state != RS_CONTINUE) | |
637 | - { | |
640 | + s->running_state = 0; | |
641 | + while (s->running_state == 0) { | |
638 | 642 | n = read (s->fd, buf, 256); |
639 | 643 | if (n > 0) |
640 | 644 | { |
... | ... | @@ -649,7 +653,7 @@ gdb_handlesig (CPUState *env, int sig) |
649 | 653 | connection before continuing. */ |
650 | 654 | return sig; |
651 | 655 | } |
652 | - } | |
656 | + } | |
653 | 657 | return sig; |
654 | 658 | } |
655 | 659 | #else | ... | ... |