[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/38] gdbstub: Fix gdb_register_coprocessor() regis
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 02/38] gdbstub: Fix gdb_register_coprocessor() register counting |
Date: |
Wed, 25 Sep 2013 07:57:30 -0500 |
From: Andreas Färber <address@hidden>
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 <address@hidden>
Cc: address@hidden (stable-1.6)
Tested-by: Aneesh Kumar K.V <address@hidden>
Tested-by: Max Filippov <address@hidden>
Tested-by: Peter Maydell <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
(cherry picked from commit 35143f0164e6933a85c7c2b8a89a040d881a9151)
Signed-off-by: Michael Roth <address@hidden>
---
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 != 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 = 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 = 0;
- for (addr = 0; addr < s->g_cpu->gdb_num_regs; addr++) {
+ for (addr = 0; addr < s->g_cpu->gdb_num_g_regs; addr++) {
reg_size = gdb_read_register(s->g_cpu, mem_buf + len, addr);
len += reg_size;
}
@@ -914,7 +916,7 @@ static int gdb_handle_packet(GDBState *s, const char
*line_buf)
registers = mem_buf;
len = strlen(p) / 2;
hextomem((uint8_t *)registers, p, len);
- for (addr = 0; addr < s->g_cpu->gdb_num_regs && len > 0; addr++) {
+ for (addr = 0; addr < s->g_cpu->gdb_num_g_regs && len > 0; addr++) {
reg_size = gdb_write_register(s->g_cpu, registers, addr);
len -= reg_size;
registers += 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 = CPU(obj);
CPUClass *cc = CPU_GET_CLASS(obj);
- cpu->gdb_num_regs = cc->gdb_num_core_regs;
+ cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs;
}
static int64_t cpu_common_get_arch_id(CPUState *cpu)
--
1.7.9.5
- [Qemu-devel] Patch Round-up for stable 1.6.1, freeze on 2013-09-30, Michael Roth, 2013/09/25
- [Qemu-devel] [PATCH 02/38] gdbstub: Fix gdb_register_coprocessor() register counting,
Michael Roth <=
- [Qemu-devel] [PATCH 01/38] block: ensure bdrv_drain_all() works during bdrv_delete(), Michael Roth, 2013/09/25
- [Qemu-devel] [PATCH 03/38] target-ppc: fix bit extraction for FPBF and FPL, Michael Roth, 2013/09/25
- [Qemu-devel] [PATCH 06/38] usb/dev-hid: Modified usb-tablet category from Misc to Input, Michael Roth, 2013/09/25
- [Qemu-devel] [PATCH 05/38] scripts/qapi.py: Avoid syntax not supported by Python 2.4, Michael Roth, 2013/09/25
- [Qemu-devel] [PATCH 04/38] rdma: silly ipv6 bugfix, Michael Roth, 2013/09/25
- [Qemu-devel] [PATCH 07/38] scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial, Michael Roth, 2013/09/25
- [Qemu-devel] [PATCH 09/38] pseries: Fix stalls on hypervisor virtual console, Michael Roth, 2013/09/25
- [Qemu-devel] [PATCH 08/38] pc: fix regression for 64 bit PCI memory, Michael Roth, 2013/09/25
- [Qemu-devel] [PATCH 10/38] virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over the indirect descriptor table, Michael Roth, 2013/09/25
- [Qemu-devel] [PATCH 11/38] xhci: fix endpoint interval calculation, Michael Roth, 2013/09/25