All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] gdbstub: fix sThreadInfo handler
@ 2013-07-22  5:24 Max Filippov
  2013-07-22 10:54 ` Andreas Färber
  0 siblings, 1 reply; 3+ messages in thread
From: Max Filippov @ 2013-07-22  5:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Andreas Färber, Max Filippov

After the commit 182735e cpu: Make first_cpu and next_cpu CPUState
we can no longer blindly use cpu->next_cpu->env_ptr to get CPUArchState
of the next CPU, as the next_cpu is NULL in the last CPU.

This fixes segfault caused by gdb command 'info threads'.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 gdbstub.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdbstub.c b/gdbstub.c
index 0ee82a9..deb8159 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2406,10 +2406,11 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
         } else if (strcmp(p,"sThreadInfo") == 0) {
         report_cpuinfo:
             if (s->query_cpu) {
+                CPUState *cpu = ENV_GET_CPU(s->query_cpu);
                 snprintf(buf, sizeof(buf), "m%x",
-                         cpu_index(ENV_GET_CPU(s->query_cpu)));
+                         cpu_index(cpu));
                 put_packet(s, buf);
-                s->query_cpu = ENV_GET_CPU(s->query_cpu)->next_cpu->env_ptr;
+                s->query_cpu = cpu->next_cpu ? cpu->next_cpu->env_ptr : NULL;
             } else
                 put_packet(s, "l");
             break;
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-22 12:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-22  5:24 [Qemu-devel] [PATCH] gdbstub: fix sThreadInfo handler Max Filippov
2013-07-22 10:54 ` Andreas Färber
2013-07-22 11:32   ` Max Filippov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.