gdbstub: Add vCont support
PATCH 1/1 gdbstub: Add vCont support
[ Fix signal forwarding, properly handle unknown v-packets. ]
In order to set the VCPU for the next single-step command, you need gdb 6.8 or better - and this patch. It enhances the existing support for representing VCPUs as threads to the gdb frontend by introducing the vCont remote gdb command. This is used by gdb to switch the debugging focus for single-stepping multi-threaded targets.
---
gdbstub.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)
gdbstub.c +58 -0
@@ -1542,6 +1542,64 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) s->signal =0 ;gdb_continue (s);return RS_IDLE ; +case 'v' : +if (strncmp (p,"Cont" ,4 ) ==0 ) { +int res_signal, res_thread; + + p +=4 ; +if (*p =='?' ) { +put_packet (s,"vCont;c;C;s;S" ); +break ; + } + res =0 ; + res_signal =0 ; + res_thread =0 ; +while (*p) { +int action, signal; + +if (*p++ !=';' ) { + res =0 ; +break ; + } + action = *p++; + signal =0 ; +if (action =='C' || action =='S' ) + signal =strtoul (p, (char **)&p,16 ); +else if (action !='c' && action !='s' ) { + res =0 ; +break ; + } + thread =0 ; +if (*p ==':' ) + thread =strtoull (p+1 , (char **)&p,16 ); + + action =tolower (action); +if (res ==0 || (res =='c' && action =='s' )) { + res = action; + res_signal = signal; + res_thread = thread; + } + } +if (res) { +if (res_thread !=-1 && res_thread !=0 ) { +for (env = first_cpu; env !=NULL ; env = env->next_cpu) +if (env->cpu_index +1 == res_thread) +break ; +if (env ==NULL ) { +put_packet (s,"E22" ); +break ; + } + s->c_cpu = env; + } +if (res =='s' ) +cpu_single_step (s->c_cpu, sstep_flags); + s->signal = res_signal; +gdb_continue (s); +return RS_IDLE ; + } +break ; + }else + goto unknown_command;case 'k' :/* Kill the target */ fprintf (stderr,"\nQEMU: Terminated via GDBstub\n" );
Quoted 78 lines
-----Original Message-----
From:
[email protected] [mailto:[email protected] rg] On Behalf Of Jan Kiszka
Sent: Wednesday, January 14, 2009 10:57 AM
To: [email protected]
Subject: [Qemu-devel] [PATCH -v2] gdbstub: Add vCont support[ Fix signal forwarding, properly handle unknown v-packets. ]
In order to set the VCPU for the next single-step command, you need gdb
6.8 or better - and this patch. It enhances the existing support for representing VCPUs as threads to the gdb frontend by introducing the vCont remote gdb command. This is used by gdb to switch the debugging focus for single-stepping multi-threaded targets.Signed-off-by Jan Kiszka <[email protected]>---
gdbstub.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)gdbstub.c +41
-0@@ -1542,6 +1542,64 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) s->signal =0 ;gdb_continue (s);return RS_IDLE ; +case 'v' : +if (strncmp (p,"Cont" ,4 ) ==0 ) { +int res_signal, res_thread; + + p +=4 ; +if (*p =='?' ) { +put_packet (s,"vCont;c;C;s;S" ); +break ; + } + res =0 ; + res_signal =0 ; + res_thread =0 ; +while (*p) { +int action, signal; + +if (*p++ !=';' ) { + res =0 ; +break ; + } + action = *p++; + signal =0 ; +if (action =='C' || action =='S' ) + signal =strtoul (p, (char **)&p,16 ); +else if (action !='c' && action !='s' ) { + res =0 ; +break ; + } + thread =0 ; +if (*p ==':' ) + thread =strtoull (p+1 , (char **)&p,16 ); + + action =tolower (action); +if (res ==0 || (res =='c' && action =='s' )) { + res = action; + res_signal = signal; + res_thread = thread; + } + } +if (res) { +if (res_thread !=-1 && res_thread !=0 ) { +for (env = first_cpu; env !=NULL ; env = env->next_cpu)
gdbstub.c static int gdb_handle_packet(GDBState · line 1597
Quoted 10 lines
gdbstub.c +10
-0+if (env->cpu_index +1 == res_thread) +break ; +if (env ==NULL ) { +put_packet (s,"E22" ); +break ; + } + s->c_cpu = env; + } +if (res =='s' ) +cpu_single_step (s->c_cpu, sstep_flags);
Sorry I am not more familure with the code, but does cpu_single_step need to know about the res_signal?
Thanks
Chris
Quoted 14 lines
gdbstub.c +7
-0+ s->signal = res_signal; +gdb_continue (s); +return RS_IDLE ; + } +break ; + }else + goto unknown_command;case 'k' :/* Kill the target */ fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");
Quoted 83 lines · Chris
Quoted 83 lines
-----Original Message-----
From:
[email protected] [mailto:[email protected] rg] On Behalf Of Jan Kiszka
Sent: Wednesday, January 14, 2009 10:57 AM
To: [email protected]
Subject: [Qemu-devel] [PATCH -v2] gdbstub: Add vCont support[ Fix signal forwarding, properly handle unknown v-packets. ]
In order to set the VCPU for the next single-step command, you need gdb
6.8 or better - and this patch. It enhances the existing support for representing VCPUs as threads to the gdb frontend by introducing the vCont remote gdb command. This is used by gdb to switch the debugging focus for single-stepping multi-threaded targets.Signed-off-by Jan Kiszka <[email protected]>---
gdbstub.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-)gdbstub.c +46
-0@@ -1542,6 +1542,64 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) s->signal =0 ;gdb_continue (s);return RS_IDLE ; +case 'v' : +if (strncmp (p,"Cont" ,4 ) ==0 ) { +int res_signal, res_thread; + + p +=4 ; +if (*p =='?' ) { +put_packet (s,"vCont;c;C;s;S" ); +break ; + } + res =0 ; + res_signal =0 ; + res_thread =0 ; +while (*p) { +int action, signal; + +if (*p++ !=';' ) { + res =0 ; +break ; + } + action = *p++; + signal =0 ; +if (action =='C' || action =='S' ) + signal =strtoul (p, (char **)&p,16 ); +else if (action !='c' && action !='s' ) { + res =0 ; +break ; + } + thread =0 ; +if (*p ==':' ) + thread =strtoull (p+1 , (char **)&p,16 ); + + action =tolower (action); +if (res ==0 || (res =='c' && action =='s' )) { + res = action; + res_signal = signal; + res_thread = thread; + } + } +if (res) { +if (res_thread !=-1 && res_thread !=0 ) { +for (env = first_cpu; env !=NULL ; env = env->next_cpu) +if (env->cpu_index +1 == res_thread) +break ; +if (env ==NULL ) { +put_packet (s,"E22" ); +break ;
Quoted 9 lines
gdbstub.c static int gdb_handle_packet(GDBState *s, const char *line_buf) · line 1595
Quoted 5 lines
gdbstub.c +5
-0+ } + s->c_cpu = env; + } +if (res =='s' ) +cpu_single_step (s->c_cpu, sstep_flags);Sorry I am not more familure with the code, but does
cpu_single_stepneed to know about theres_signal?
Nope, cpu_single_step just toggles the switch that future guest code execution should single-step and flushes translated code buffers (when in emulation mode).
Jan