* [Qemu-devel] [RESEND][PATCH] gdbstub: Add vCont support
@ 2009-03-10 17:21 Jan Kiszka
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2009-03-10 17:21 UTC (permalink / raw)
To: qemu-devel
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.
There was quite some discussion around this patch in the past, dealing
with the model for presenting VCPU as threads to the gdb front-end. This
patch should be merged nevertheless because
- this patch does not introduce the threading model, it only introduces
vCont according to the exiting model used by qemu 0.10.x.
- current gdb provides no alternative yet, but we already have lots of
use cases that are covered by the basic threading model.
- enhancing qemu later on with a true multicore model once gdb supports
it will not obsolete this patch.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
gdbstub.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/gdbstub.c b/gdbstub.c
index 8876c1d..1191dc2 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1570,6 +1570,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");
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [RESEND][PATCH] gdbstub: Add vCont support
@ 2009-01-14 14:44 Jan Kiszka
2009-01-14 15:03 ` Krumme, Chris
2009-01-15 20:32 ` Anthony Liguori
0 siblings, 2 replies; 4+ messages in thread
From: Jan Kiszka @ 2009-01-14 14:44 UTC (permalink / raw)
To: qemu-devel@nongnu.org
[ Also available via git://git.kiszka.org/qemu.git queue/gdb ]
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 <jan.kiszka@siemens.com>
---
gdbstub.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/gdbstub.c b/gdbstub.c
index 0bcd5d5..1cb20b7 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1542,6 +1542,62 @@ 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);
+ gdb_continue(s);
+ return RS_IDLE;
+ }
+ break;
+ }
case 'k':
/* Kill the target */
fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [Qemu-devel] [RESEND][PATCH] gdbstub: Add vCont support
2009-01-14 14:44 Jan Kiszka
@ 2009-01-14 15:03 ` Krumme, Chris
2009-01-15 20:32 ` Anthony Liguori
1 sibling, 0 replies; 4+ messages in thread
From: Krumme, Chris @ 2009-01-14 15:03 UTC (permalink / raw)
To: qemu-devel
> -----Original Message-----
> From:
> qemu-devel-bounces+chris.krumme=windriver.com@nongnu.org
> [mailto:qemu-devel-bounces+chris.krumme=windriver.com@nongnu.o
> rg] On Behalf Of Jan Kiszka
> Sent: Wednesday, January 14, 2009 8:44 AM
> To: qemu-devel@nongnu.org
> Subject: [Qemu-devel] [RESEND][PATCH] gdbstub: Add vCont support
>
> [ Also available via git://git.kiszka.org/qemu.git queue/gdb ]
>
> 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 <jan.kiszka@siemens.com>
> ---
>
> gdbstub.c | 56
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 56 insertions(+), 0 deletions(-)
>
> diff --git a/gdbstub.c b/gdbstub.c
> index 0bcd5d5..1cb20b7 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -1542,6 +1542,62 @@ 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);
> + gdb_continue(s);
Where did res_signal go? (btw: some OS use signal 0 along with the
rest.)
> + return RS_IDLE;
> + }
If the command is not vCont do you need to return an error?
Thanks
Chris
> + break;
> + }
> case 'k':
> /* Kill the target */
> fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [RESEND][PATCH] gdbstub: Add vCont support
2009-01-14 14:44 Jan Kiszka
2009-01-14 15:03 ` Krumme, Chris
@ 2009-01-15 20:32 ` Anthony Liguori
1 sibling, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2009-01-15 20:32 UTC (permalink / raw)
To: qemu-devel
Jan Kiszka wrote:
> [ Also available via git://git.kiszka.org/qemu.git queue/gdb ]
>
> 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 <jan.kiszka@siemens.com>
>
I think the consensus from the last posting of this was that modeling
threads was pretty broken and that we should model as processes. Did I
miss something there?
Regards,
Anthony Liguori
> ---
>
> gdbstub.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 56 insertions(+), 0 deletions(-)
>
> diff --git a/gdbstub.c b/gdbstub.c
> index 0bcd5d5..1cb20b7 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -1542,6 +1542,62 @@ 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);
> + gdb_continue(s);
> + return RS_IDLE;
> + }
> + break;
> + }
> case 'k':
> /* Kill the target */
> fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-03-10 17:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-10 17:21 [Qemu-devel] [RESEND][PATCH] gdbstub: Add vCont support Jan Kiszka
-- strict thread matches above, loose matches on Subject: below --
2009-01-14 14:44 Jan Kiszka
2009-01-14 15:03 ` Krumme, Chris
2009-01-15 20:32 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).