From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V974l-00059z-Pb for qemu-devel@nongnu.org; Tue, 13 Aug 2013 01:23:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V974c-0000tU-DV for qemu-devel@nongnu.org; Tue, 13 Aug 2013 01:23:23 -0400 Received: from e28smtp05.in.ibm.com ([122.248.162.5]:56360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V974b-0000pb-Pm for qemu-devel@nongnu.org; Tue, 13 Aug 2013 01:23:14 -0400 Received: from /spool/local by e28smtp05.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Aug 2013 10:46:53 +0530 From: "Aneesh Kumar K.V" In-Reply-To: <1376328163-7323-1-git-send-email-afaerber@suse.de> References: <1376328163-7323-1-git-send-email-afaerber@suse.de> Date: Tue, 13 Aug 2013 10:53:01 +0530 Message-ID: <87siye9nbe.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFT qom-cpu for-next] gdbstub: Fix gdb_register_coprocessor() register counting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= , qemu-devel@nongnu.org Cc: Peter Maydell , "for 1.6" , agraf@suse.de, Max Filippov , qemu-ppc@nongnu.org, Anthony Liguori Andreas F=C3=A4rber writes: > Commit a0e372f0c49ac01faeaeb73a6e8f50e8ac615f34 reorganized the register > counting for GDB. While it seems correct not to let the total number of > registers skyrocket in an SMP scenario through a static variable, the > distinction between total register count and 'g' packet register count > (last_reg vs. num_g_regs) got lost among the way. > > Fix this by introducing CPUState::gdb_num_g_regs and using that in > gdb_handle_packet(). > > Reported-by: Aneesh Kumar K.V > Cc: qemu-stable@nongnu.org (for 1.6) > Cc: Peter Maydell > Cc: Max Filippov > Signed-off-by: Andreas F=C3=A4rber Tested-by: Aneesh Kumar K.V > --- > gdbstub.c | 6 ++++-- > include/qom/cpu.h | 2 ++ > qom/cpu.c | 2 +- > 3 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/gdbstub.c b/gdbstub.c > index 1af25a6..9d067d6 100644 > --- a/gdbstub.c > +++ b/gdbstub.c > @@ -621,6 +621,8 @@ void gdb_register_coprocessor(CPUState *cpu, > if (g_pos !=3D s->base_reg) { > fprintf(stderr, "Error: Bad gdb register numbering for '%s'\= n" > "Expected %d got %d\n", xml, g_pos, s->base_reg); > + } else { > + cpu->gdb_num_g_regs =3D cpu->gdb_num_regs; > } > } > } > @@ -902,7 +904,7 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) > case 'g': > cpu_synchronize_state(s->g_cpu); > len =3D 0; > - for (addr =3D 0; addr < s->g_cpu->gdb_num_regs; addr++) { > + for (addr =3D 0; addr < s->g_cpu->gdb_num_g_regs; addr++) { > reg_size =3D gdb_read_register(s->g_cpu, mem_buf + len, addr= ); > len +=3D reg_size; > } > @@ -914,7 +916,7 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) > registers =3D mem_buf; > len =3D strlen(p) / 2; > hextomem((uint8_t *)registers, p, len); > - for (addr =3D 0; addr < s->g_cpu->gdb_num_regs && len > 0; addr+= +) { > + for (addr =3D 0; addr < s->g_cpu->gdb_num_g_regs && len > 0; add= r++) { > reg_size =3D gdb_write_register(s->g_cpu, registers, addr); > len -=3D reg_size; > registers +=3D reg_size; > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 0d6e95c..3e49936 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -152,6 +152,7 @@ struct kvm_run; > * @current_tb: Currently executing TB. > * @gdb_regs: Additional GDB registers. > * @gdb_num_regs: Number of total registers accessible to GDB. > + * @gdb_num_g_regs: Number of registers in GDB 'g' packets. > * @next_cpu: Next CPU sharing TB cache. > * @kvm_fd: vCPU file descriptor for KVM. > * > @@ -188,6 +189,7 @@ struct CPUState { > struct TranslationBlock *current_tb; > struct GDBRegisterState *gdb_regs; > int gdb_num_regs; > + int gdb_num_g_regs; > CPUState *next_cpu; > > int kvm_fd; > diff --git a/qom/cpu.c b/qom/cpu.c > index aa95108..e71e57b 100644 > --- a/qom/cpu.c > +++ b/qom/cpu.c > @@ -240,7 +240,7 @@ static void cpu_common_initfn(Object *obj) > CPUState *cpu =3D CPU(obj); > CPUClass *cc =3D CPU_GET_CLASS(obj); > > - cpu->gdb_num_regs =3D cc->gdb_num_core_regs; > + cpu->gdb_num_regs =3D cpu->gdb_num_g_regs =3D cc->gdb_num_core_regs; > } > > static int64_t cpu_common_get_arch_id(CPUState *cpu) > --=20 > 1.8.1.4