Patchwork [RFC,qom-cpu,09/41] gdbstub: Replace two find_cpu() with qemu_get_cpu()

login
register
mail settings
Submitter Andreas Färber
Date June 29, 2013, 8:01 p.m.
Message ID <1372536117-28167-10-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/255782/
State New
Headers show

Comments

Andreas Färber - June 29, 2013, 8:01 p.m.
Since commit cb446ecab714b2444a270be209e0533bcd2ee534 (kvm: Change
cpu_synchronize_state() argument to CPUState), one was no longer
accessing CPUArchState, the other was just checking existence.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 gdbstub.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Richard Henderson - July 1, 2013, 5:14 p.m.
On 06/29/2013 01:01 PM, Andreas Färber wrote:
> Since commit cb446ecab714b2444a270be209e0533bcd2ee534 (kvm: Change
> cpu_synchronize_state() argument to CPUState), one was no longer
> accessing CPUArchState, the other was just checking existence.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  gdbstub.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~
Andreas Färber - July 6, 2013, 12:42 a.m.
Am 01.07.2013 19:14, schrieb Richard Henderson:
> On 06/29/2013 01:01 PM, Andreas Färber wrote:
>> Since commit cb446ecab714b2444a270be209e0533bcd2ee534 (kvm: Change
>> cpu_synchronize_state() argument to CPUState), one was no longer
>> accessing CPUArchState, the other was just checking existence.
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>>  gdbstub.c | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> Reviewed-by: Richard Henderson <rth@twiddle.net>

Thanks, applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

Patch

diff --git a/gdbstub.c b/gdbstub.c
index bdf4496..07838eb 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2065,6 +2065,7 @@  static CPUArchState *find_cpu(uint32_t thread_id)
 static int gdb_handle_packet(GDBState *s, const char *line_buf)
 {
     CPUArchState *env;
+    CPUState *cpu;
     const char *p;
     uint32_t thread;
     int ch, reg_size, type, res;
@@ -2333,9 +2334,9 @@  static int gdb_handle_packet(GDBState *s, const char *line_buf)
         break;
     case 'T':
         thread = strtoull(p, (char **)&p, 16);
-        env = find_cpu(thread);
+        cpu = qemu_get_cpu(thread);
 
-        if (env != NULL) {
+        if (cpu != NULL) {
             put_packet(s, "OK");
         } else {
             put_packet(s, "E22");
@@ -2385,9 +2386,8 @@  static int gdb_handle_packet(GDBState *s, const char *line_buf)
             break;
         } else if (strncmp(p,"ThreadExtraInfo,", 16) == 0) {
             thread = strtoull(p+16, (char **)&p, 16);
-            env = find_cpu(thread);
-            if (env != NULL) {
-                CPUState *cpu = ENV_GET_CPU(env);
+            cpu = qemu_get_cpu(thread);
+            if (cpu != NULL) {
                 cpu_synchronize_state(cpu);
                 len = snprintf((char *)mem_buf, sizeof(mem_buf),
                                "CPU#%d [%s]", cpu->cpu_index,