Received: from eggs.gnu.org ([2001:4830:134:3::10]:37426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwgKl-00029k-BL for qemu-devel@nongnu.org; Tue, 09 Jul 2013 18:24:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UwgKh-0002MK-UW for qemu-devel@nongnu.org; Tue, 09 Jul 2013 18:24:31 -0400 Received: from cantor2.suse.de ([195.135.220.15]:32991 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwgKh-0002M4-C8 for qemu-devel@nongnu.org; Tue, 09 Jul 2013 18:24:27 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CAA50A535C for ; Wed, 10 Jul 2013 00:24:26 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 10 Jul 2013 00:23:36 +0200 Message-Id: <1373408640-6046-18-git-send-email-afaerber@suse.de> In-Reply-To: <1373408640-6046-1-git-send-email-afaerber@suse.de> References: <1373408640-6046-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu v3 17/41] gdbstub: Change GDBState::{c, g}_cpu and find_cpu() to CPUState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= Use CPUState::env_ptr where still needed. Signed-off-by: Andreas F=C3=A4rber --- gdbstub.c | 104 +++++++++++++++++++++++++++++++-------------------------= ------ 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 9e017ed..ee31603 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -288,8 +288,8 @@ enum RSState { RS_CHKSUM2, }; typedef struct GDBState { - CPUArchState *c_cpu; /* current CPU for step/continue ops */ - CPUArchState *g_cpu; /* current CPU for other ops */ + CPUState *c_cpu; /* current CPU for step/continue ops */ + CPUState *g_cpu; /* current CPU for other ops */ CPUState *query_cpu; /* for q{f|s}ThreadInfo */ enum RSState state; /* parsing state */ char line_buf[MAX_PACKET_LENGTH]; @@ -1958,8 +1958,7 @@ static int gdb_breakpoint_insert(target_ulong addr,= target_ulong len, int type) int err =3D 0; =20 if (kvm_enabled()) { - return kvm_insert_breakpoint(ENV_GET_CPU(gdbserver_state->c_cpu)= , - addr, len, type); + return kvm_insert_breakpoint(gdbserver_state->c_cpu, addr, len, = type); } =20 switch (type) { @@ -1997,8 +1996,7 @@ static int gdb_breakpoint_remove(target_ulong addr,= target_ulong len, int type) int err =3D 0; =20 if (kvm_enabled()) { - return kvm_remove_breakpoint(ENV_GET_CPU(gdbserver_state->c_cpu)= , - addr, len, type); + return kvm_remove_breakpoint(gdbserver_state->c_cpu, addr, len, = type); } =20 switch (type) { @@ -2034,7 +2032,7 @@ static void gdb_breakpoint_remove_all(void) CPUArchState *env; =20 if (kvm_enabled()) { - kvm_remove_all_breakpoints(ENV_GET_CPU(gdbserver_state->c_cpu)); + kvm_remove_all_breakpoints(gdbserver_state->c_cpu); return; } =20 @@ -2049,7 +2047,7 @@ static void gdb_breakpoint_remove_all(void) =20 static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) { - CPUState *cpu =3D ENV_GET_CPU(s->c_cpu); + CPUState *cpu =3D s->c_cpu; CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 cpu_synchronize_state(cpu); @@ -2058,13 +2056,13 @@ static void gdb_set_cpu_pc(GDBState *s, target_ul= ong pc) } } =20 -static CPUArchState *find_cpu(uint32_t thread_id) +static CPUState *find_cpu(uint32_t thread_id) { CPUState *cpu; =20 for (cpu =3D first_cpu; cpu !=3D NULL; cpu =3D cpu->next_cpu) { if (cpu_index(cpu) =3D=3D thread_id) { - return cpu->env_ptr; + return cpu; } } =20 @@ -2073,7 +2071,10 @@ static CPUArchState *find_cpu(uint32_t thread_id) =20 static int gdb_handle_packet(GDBState *s, const char *line_buf) { +#ifdef TARGET_XTENSA CPUArchState *env; +#endif + CPUState *cpu; const char *p; uint32_t thread; int ch, reg_size, type, res; @@ -2091,7 +2092,7 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) case '?': /* TODO: Make this return the correct value for user-mode. */ snprintf(buf, sizeof(buf), "T%02xthread:%02x;", GDB_SIGNAL_TRAP, - cpu_index(ENV_GET_CPU(s->c_cpu))); + cpu_index(s->c_cpu)); put_packet(s, buf); /* Remove all the breakpoints when this query is issued, * because gdb is doing and initial connect and the state @@ -2153,15 +2154,15 @@ static int gdb_handle_packet(GDBState *s, const c= har *line_buf) } if (res) { if (res_thread !=3D -1 && res_thread !=3D 0) { - env =3D find_cpu(res_thread); - if (env =3D=3D NULL) { + cpu =3D find_cpu(res_thread); + if (cpu =3D=3D NULL) { put_packet(s, "E22"); break; } - s->c_cpu =3D env; + s->c_cpu =3D cpu; } if (res =3D=3D 's') { - cpu_single_step(ENV_GET_CPU(s->c_cpu), sstep_flags); + cpu_single_step(s->c_cpu, sstep_flags); } s->signal =3D res_signal; gdb_continue(s); @@ -2189,7 +2190,7 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) addr =3D strtoull(p, (char **)&p, 16); gdb_set_cpu_pc(s, addr); } - cpu_single_step(ENV_GET_CPU(s->c_cpu), sstep_flags); + cpu_single_step(s->c_cpu, sstep_flags); gdb_continue(s); return RS_IDLE; case 'F': @@ -2208,7 +2209,7 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) p++; type =3D *p; if (s->current_syscall_cb) { - s->current_syscall_cb(ENV_GET_CPU(s->c_cpu), ret, err); + s->current_syscall_cb(s->c_cpu, ret, err); s->current_syscall_cb =3D NULL; } if (type =3D=3D 'C') { @@ -2219,26 +2220,28 @@ static int gdb_handle_packet(GDBState *s, const c= har *line_buf) } break; case 'g': - cpu_synchronize_state(ENV_GET_CPU(s->g_cpu)); - env =3D s->g_cpu; + cpu_synchronize_state(s->g_cpu); +#ifdef TARGET_XTENSA + env =3D s->g_cpu->env_ptr; +#endif len =3D 0; for (addr =3D 0; addr < num_g_regs; addr++) { - reg_size =3D gdb_read_register(ENV_GET_CPU(s->g_cpu), - mem_buf + len, addr); + reg_size =3D gdb_read_register(s->g_cpu, mem_buf + len, addr= ); len +=3D reg_size; } memtohex(buf, mem_buf, len); put_packet(s, buf); break; case 'G': - cpu_synchronize_state(ENV_GET_CPU(s->g_cpu)); - env =3D s->g_cpu; + cpu_synchronize_state(s->g_cpu); +#ifdef TARGET_XTENSA + env =3D s->g_cpu->env_ptr; +#endif registers =3D mem_buf; len =3D strlen(p) / 2; hextomem((uint8_t *)registers, p, len); for (addr =3D 0; addr < num_g_regs && len > 0; addr++) { - reg_size =3D gdb_write_register(ENV_GET_CPU(s->g_cpu), regis= ters, - addr); + reg_size =3D gdb_write_register(s->g_cpu, registers, addr); len -=3D reg_size; registers +=3D reg_size; } @@ -2249,8 +2252,7 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) if (*p =3D=3D ',') p++; len =3D strtoull(p, NULL, 16); - if (target_memory_rw_debug(ENV_GET_CPU(s->g_cpu), addr, mem_buf,= len, - false) !=3D 0) { + if (target_memory_rw_debug(s->g_cpu, addr, mem_buf, len, false) = !=3D 0) { put_packet (s, "E14"); } else { memtohex(buf, mem_buf, len); @@ -2265,7 +2267,7 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) if (*p =3D=3D ':') p++; hextomem(mem_buf, p, len); - if (target_memory_rw_debug(ENV_GET_CPU(s->g_cpu), addr, mem_buf,= len, + if (target_memory_rw_debug(s->g_cpu, addr, mem_buf, len, true) !=3D 0) { put_packet(s, "E14"); } else { @@ -2279,7 +2281,7 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) if (!gdb_has_xml) goto unknown_command; addr =3D strtoull(p, (char **)&p, 16); - reg_size =3D gdb_read_register(ENV_GET_CPU(s->g_cpu), mem_buf, a= ddr); + reg_size =3D gdb_read_register(s->g_cpu, mem_buf, addr); if (reg_size) { memtohex(buf, mem_buf, reg_size); put_packet(s, buf); @@ -2295,7 +2297,7 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) p++; reg_size =3D strlen(p) / 2; hextomem(mem_buf, p, reg_size); - gdb_write_register(ENV_GET_CPU(s->g_cpu), mem_buf, addr); + gdb_write_register(s->g_cpu, mem_buf, addr); put_packet(s, "OK"); break; case 'Z': @@ -2325,18 +2327,18 @@ static int gdb_handle_packet(GDBState *s, const c= har *line_buf) put_packet(s, "OK"); break; } - env =3D find_cpu(thread); - if (env =3D=3D NULL) { + cpu =3D find_cpu(thread); + if (cpu =3D=3D NULL) { put_packet(s, "E22"); break; } switch (type) { case 'c': - s->c_cpu =3D env; + s->c_cpu =3D cpu; put_packet(s, "OK"); break; case 'g': - s->g_cpu =3D env; + s->g_cpu =3D cpu; put_packet(s, "OK"); break; default: @@ -2346,9 +2348,9 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) break; case 'T': thread =3D strtoull(p, (char **)&p, 16); - env =3D find_cpu(thread); + cpu =3D find_cpu(thread); =20 - if (env !=3D NULL) { + if (cpu !=3D NULL) { put_packet(s, "OK"); } else { put_packet(s, "E22"); @@ -2398,9 +2400,8 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) break; } else if (strncmp(p,"ThreadExtraInfo,", 16) =3D=3D 0) { thread =3D strtoull(p+16, (char **)&p, 16); - env =3D find_cpu(thread); - if (env !=3D NULL) { - CPUState *cpu =3D ENV_GET_CPU(env); + cpu =3D find_cpu(thread); + if (cpu !=3D NULL) { cpu_synchronize_state(cpu); len =3D snprintf((char *)mem_buf, sizeof(mem_buf), "CPU#%d [%s]", cpu->cpu_index, @@ -2412,7 +2413,8 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } #ifdef CONFIG_USER_ONLY else if (strncmp(p, "Offsets", 7) =3D=3D 0) { - TaskState *ts =3D s->c_cpu->opaque; + CPUArchState *env =3D s->c_cpu->env_ptr; + TaskState *ts =3D env->opaque; =20 snprintf(buf, sizeof(buf), "Text=3D" TARGET_ABI_FMT_lx ";Data=3D" TARGET_ABI_F= MT_lx @@ -2502,18 +2504,16 @@ static int gdb_handle_packet(GDBState *s, const c= har *line_buf) =20 void gdb_set_stop_cpu(CPUState *cpu) { - CPUArchState *env =3D cpu->env_ptr; - - gdbserver_state->c_cpu =3D env; - gdbserver_state->g_cpu =3D env; + gdbserver_state->c_cpu =3D cpu; + gdbserver_state->g_cpu =3D cpu; } =20 #ifndef CONFIG_USER_ONLY static void gdb_vm_state_change(void *opaque, int running, RunState stat= e) { GDBState *s =3D gdbserver_state; - CPUArchState *env =3D s->c_cpu; - CPUState *cpu =3D ENV_GET_CPU(env); + CPUArchState *env =3D s->c_cpu->env_ptr; + CPUState *cpu =3D s->c_cpu; char buf[256]; const char *type; int ret; @@ -2643,7 +2643,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, con= st char *fmt, ...) va_end(va); #ifdef CONFIG_USER_ONLY put_packet(s, s->syscall_buf); - gdb_handlesig(ENV_GET_CPU(s->c_cpu), 0); + gdb_handlesig(s->c_cpu, 0); #else /* In this case wait to send the syscall packet until notification t= hat the CPU has stopped. This must be done because if the packet is = sent @@ -2651,7 +2651,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, con= st char *fmt, ...) is still in the running state, which can cause packets to be drop= ped and state transition 'T' packets to be sent while the syscall is = still being processed. */ - cpu_exit(ENV_GET_CPU(s->c_cpu)); + cpu_exit(s->c_cpu); #endif } =20 @@ -2860,8 +2860,8 @@ static void gdb_accept(void) socket_set_nodelay(fd); =20 s =3D g_malloc0(sizeof(GDBState)); - s->c_cpu =3D first_cpu->env_ptr; - s->g_cpu =3D first_cpu->env_ptr; + s->c_cpu =3D first_cpu; + s->g_cpu =3D first_cpu; s->fd =3D fd; gdb_has_xml =3D 0; =20 @@ -3045,8 +3045,8 @@ int gdbserver_start(const char *device) mon_chr =3D s->mon_chr; memset(s, 0, sizeof(GDBState)); } - s->c_cpu =3D first_cpu->env_ptr; - s->g_cpu =3D first_cpu->env_ptr; + s->c_cpu =3D first_cpu; + s->g_cpu =3D first_cpu; s->chr =3D chr; s->state =3D chr ? RS_IDLE : RS_INACTIVE; s->mon_chr =3D mon_chr; --=20 1.8.1.4