diff mbox series

[V1,13/32] gdbstub: gdb support for suspended state

Message ID 1596122076-341293-14-git-send-email-steven.sistare@oracle.com
State Superseded
Headers show
Series [V1,01/32] savevm: add vmstate handler iterators | expand

Commit Message

Steven Sistare July 30, 2020, 3:14 p.m. UTC
Modify the gdb server so a continue command appears to resume execution
when in RUN_STATE_SUSPENDED.  Do not print the next gdb prompt, but do not
actually resume instruction fetch.  While in this "fake" running mode, a
ctrl-C returns the user to the gdb prompt.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
 gdbstub.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Dr. David Alan Gilbert Sept. 11, 2020, 6:41 p.m. UTC | #1
* Steve Sistare (steven.sistare@oracle.com) wrote:
> Modify the gdb server so a continue command appears to resume execution
> when in RUN_STATE_SUSPENDED.  Do not print the next gdb prompt, but do not
> actually resume instruction fetch.  While in this "fake" running mode, a
> ctrl-C returns the user to the gdb prompt.
> 
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>

This patch doesn't feel like it lives here; it seems to be a separate
gdbstub patch and it'll get noticed/merged quicker just sent on it's
own.

Dave

> ---
>  gdbstub.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/gdbstub.c b/gdbstub.c
> index f3a318c..2f0d9ff 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -461,7 +461,9 @@ static inline void gdb_continue(void)
>  #else
>      if (!runstate_needs_reset()) {
>          trace_gdbstub_op_continue();
> -        vm_start();
> +        if (!runstate_check(RUN_STATE_SUSPENDED)) {
> +            vm_start();
> +        }
>      }
>  #endif
>  }
> @@ -490,7 +492,7 @@ static int gdb_continue_partial(char *newstates)
>      int flag = 0;
>  
>      if (!runstate_needs_reset()) {
> -        if (vm_prepare_start()) {
> +        if (!runstate_check(RUN_STATE_SUSPENDED) && vm_prepare_start()) {
>              return 0;
>          }
>  
> @@ -2835,6 +2837,9 @@ static void gdb_read_byte(uint8_t ch)
>          /* when the CPU is running, we cannot do anything except stop
>             it when receiving a char */
>          vm_stop(RUN_STATE_PAUSED);
> +    } else if (runstate_check(RUN_STATE_SUSPENDED) && ch == 3) {
> +        /* Received ctrl-c from gdb */
> +        gdb_vm_state_change(0, 0, RUN_STATE_PAUSED);
>      } else
>  #endif
>      {
> @@ -3282,6 +3287,8 @@ static void gdb_sigterm_handler(int signal)
>  {
>      if (runstate_is_running()) {
>          vm_stop(RUN_STATE_PAUSED);
> +    } else if (runstate_check(RUN_STATE_SUSPENDED)) {
> +        gdb_vm_state_change(0, 0, RUN_STATE_PAUSED);
>      }
>  }
>  #endif
> -- 
> 1.8.3.1
>
Steven Sistare Sept. 24, 2020, 9:51 p.m. UTC | #2
On 9/11/2020 2:41 PM, Dr. David Alan Gilbert wrote:
> * Steve Sistare (steven.sistare@oracle.com) wrote:

>> Modify the gdb server so a continue command appears to resume execution

>> when in RUN_STATE_SUSPENDED.  Do not print the next gdb prompt, but do not

>> actually resume instruction fetch.  While in this "fake" running mode, a

>> ctrl-C returns the user to the gdb prompt.

>>

>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>

> 

> This patch doesn't feel like it lives here; it seems to be a separate

> gdbstub patch and it'll get noticed/merged quicker just sent on it's

> own.


OK, I will submit it separately.

- Steve

>>  gdbstub.c | 11 +++++++++--

>>  1 file changed, 9 insertions(+), 2 deletions(-)

>>

>> diff --git a/gdbstub.c b/gdbstub.c

>> index f3a318c..2f0d9ff 100644

>> --- a/gdbstub.c

>> +++ b/gdbstub.c

>> @@ -461,7 +461,9 @@ static inline void gdb_continue(void)

>>  #else

>>      if (!runstate_needs_reset()) {

>>          trace_gdbstub_op_continue();

>> -        vm_start();

>> +        if (!runstate_check(RUN_STATE_SUSPENDED)) {

>> +            vm_start();

>> +        }

>>      }

>>  #endif

>>  }

>> @@ -490,7 +492,7 @@ static int gdb_continue_partial(char *newstates)

>>      int flag = 0;

>>  

>>      if (!runstate_needs_reset()) {

>> -        if (vm_prepare_start()) {

>> +        if (!runstate_check(RUN_STATE_SUSPENDED) && vm_prepare_start()) {

>>              return 0;

>>          }

>>  

>> @@ -2835,6 +2837,9 @@ static void gdb_read_byte(uint8_t ch)

>>          /* when the CPU is running, we cannot do anything except stop

>>             it when receiving a char */

>>          vm_stop(RUN_STATE_PAUSED);

>> +    } else if (runstate_check(RUN_STATE_SUSPENDED) && ch == 3) {

>> +        /* Received ctrl-c from gdb */

>> +        gdb_vm_state_change(0, 0, RUN_STATE_PAUSED);

>>      } else

>>  #endif

>>      {

>> @@ -3282,6 +3287,8 @@ static void gdb_sigterm_handler(int signal)

>>  {

>>      if (runstate_is_running()) {

>>          vm_stop(RUN_STATE_PAUSED);

>> +    } else if (runstate_check(RUN_STATE_SUSPENDED)) {

>> +        gdb_vm_state_change(0, 0, RUN_STATE_PAUSED);

>>      }

>>  }

>>  #endif

>> -- 

>> 1.8.3.1

>>
diff mbox series

Patch

diff --git a/gdbstub.c b/gdbstub.c
index f3a318c..2f0d9ff 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -461,7 +461,9 @@  static inline void gdb_continue(void)
 #else
     if (!runstate_needs_reset()) {
         trace_gdbstub_op_continue();
-        vm_start();
+        if (!runstate_check(RUN_STATE_SUSPENDED)) {
+            vm_start();
+        }
     }
 #endif
 }
@@ -490,7 +492,7 @@  static int gdb_continue_partial(char *newstates)
     int flag = 0;
 
     if (!runstate_needs_reset()) {
-        if (vm_prepare_start()) {
+        if (!runstate_check(RUN_STATE_SUSPENDED) && vm_prepare_start()) {
             return 0;
         }
 
@@ -2835,6 +2837,9 @@  static void gdb_read_byte(uint8_t ch)
         /* when the CPU is running, we cannot do anything except stop
            it when receiving a char */
         vm_stop(RUN_STATE_PAUSED);
+    } else if (runstate_check(RUN_STATE_SUSPENDED) && ch == 3) {
+        /* Received ctrl-c from gdb */
+        gdb_vm_state_change(0, 0, RUN_STATE_PAUSED);
     } else
 #endif
     {
@@ -3282,6 +3287,8 @@  static void gdb_sigterm_handler(int signal)
 {
     if (runstate_is_running()) {
         vm_stop(RUN_STATE_PAUSED);
+    } else if (runstate_check(RUN_STATE_SUSPENDED)) {
+        gdb_vm_state_change(0, 0, RUN_STATE_PAUSED);
     }
 }
 #endif