cpu: Introduce CPUClass::gdb_core_xml_file for GDB_CORE_XML
Replace the GDB_CORE_XML define in gdbstub.c with a CPUClass field. Use first_cpu for qSupported and qXfer:features:read: for now. Add a stub for xml_builtin. Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
90431220be
commit
5b24c64188
42
gdbstub.c
42
gdbstub.c
|
@ -485,25 +485,6 @@ static int put_packet(GDBState *s, const char *buf)
|
||||||
return put_packet_binary(s, buf, strlen(buf));
|
return put_packet_binary(s, buf, strlen(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TARGET_PPC)
|
|
||||||
|
|
||||||
#if defined (TARGET_PPC64)
|
|
||||||
#define GDB_CORE_XML "power64-core.xml"
|
|
||||||
#else
|
|
||||||
#define GDB_CORE_XML "power-core.xml"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined (TARGET_ARM)
|
|
||||||
|
|
||||||
#define GDB_CORE_XML "arm-core.xml"
|
|
||||||
|
|
||||||
#elif defined (TARGET_M68K)
|
|
||||||
|
|
||||||
#define GDB_CORE_XML "cf-core.xml"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GDB_CORE_XML
|
|
||||||
/* Encode data using the encoding for 'x' packets. */
|
/* Encode data using the encoding for 'x' packets. */
|
||||||
static int memtox(char *buf, const char *mem, int len)
|
static int memtox(char *buf, const char *mem, int len)
|
||||||
{
|
{
|
||||||
|
@ -525,7 +506,8 @@ static int memtox(char *buf, const char *mem, int len)
|
||||||
return p - buf;
|
return p - buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *get_feature_xml(const char *p, const char **newp)
|
static const char *get_feature_xml(const char *p, const char **newp,
|
||||||
|
CPUClass *cc)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
int i;
|
int i;
|
||||||
|
@ -549,7 +531,7 @@ static const char *get_feature_xml(const char *p, const char **newp)
|
||||||
"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
|
"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
|
||||||
"<target>"
|
"<target>"
|
||||||
"<xi:include href=\"%s\"/>",
|
"<xi:include href=\"%s\"/>",
|
||||||
GDB_CORE_XML);
|
cc->gdb_core_xml_file);
|
||||||
|
|
||||||
for (r = cpu->gdb_regs; r; r = r->next) {
|
for (r = cpu->gdb_regs; r; r = r->next) {
|
||||||
pstrcat(target_xml, sizeof(target_xml), "<xi:include href=\"");
|
pstrcat(target_xml, sizeof(target_xml), "<xi:include href=\"");
|
||||||
|
@ -567,7 +549,6 @@ static const char *get_feature_xml(const char *p, const char **newp)
|
||||||
}
|
}
|
||||||
return name ? xml_builtin[i][1] : NULL;
|
return name ? xml_builtin[i][1] : NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int gdb_read_register(CPUState *cpu, uint8_t *mem_buf, int reg)
|
static int gdb_read_register(CPUState *cpu, uint8_t *mem_buf, int reg)
|
||||||
{
|
{
|
||||||
|
@ -773,6 +754,7 @@ static CPUState *find_cpu(uint32_t thread_id)
|
||||||
static int gdb_handle_packet(GDBState *s, const char *line_buf)
|
static int gdb_handle_packet(GDBState *s, const char *line_buf)
|
||||||
{
|
{
|
||||||
CPUState *cpu;
|
CPUState *cpu;
|
||||||
|
CPUClass *cc;
|
||||||
const char *p;
|
const char *p;
|
||||||
uint32_t thread;
|
uint32_t thread;
|
||||||
int ch, reg_size, type, res;
|
int ch, reg_size, type, res;
|
||||||
|
@ -1135,20 +1117,25 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
|
||||||
#endif /* !CONFIG_USER_ONLY */
|
#endif /* !CONFIG_USER_ONLY */
|
||||||
if (strncmp(p, "Supported", 9) == 0) {
|
if (strncmp(p, "Supported", 9) == 0) {
|
||||||
snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH);
|
snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH);
|
||||||
#ifdef GDB_CORE_XML
|
cc = CPU_GET_CLASS(first_cpu);
|
||||||
pstrcat(buf, sizeof(buf), ";qXfer:features:read+");
|
if (cc->gdb_core_xml_file != NULL) {
|
||||||
#endif
|
pstrcat(buf, sizeof(buf), ";qXfer:features:read+");
|
||||||
|
}
|
||||||
put_packet(s, buf);
|
put_packet(s, buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef GDB_CORE_XML
|
|
||||||
if (strncmp(p, "Xfer:features:read:", 19) == 0) {
|
if (strncmp(p, "Xfer:features:read:", 19) == 0) {
|
||||||
const char *xml;
|
const char *xml;
|
||||||
target_ulong total_len;
|
target_ulong total_len;
|
||||||
|
|
||||||
|
cc = CPU_GET_CLASS(first_cpu);
|
||||||
|
if (cc->gdb_core_xml_file == NULL) {
|
||||||
|
goto unknown_command;
|
||||||
|
}
|
||||||
|
|
||||||
gdb_has_xml = true;
|
gdb_has_xml = true;
|
||||||
p += 19;
|
p += 19;
|
||||||
xml = get_feature_xml(p, &p);
|
xml = get_feature_xml(p, &p, cc);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
snprintf(buf, sizeof(buf), "E00");
|
snprintf(buf, sizeof(buf), "E00");
|
||||||
put_packet(s, buf);
|
put_packet(s, buf);
|
||||||
|
@ -1180,7 +1167,6 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
|
||||||
put_packet_binary(s, buf, len + 1);
|
put_packet_binary(s, buf, len + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Unrecognised 'q' command. */
|
/* Unrecognised 'q' command. */
|
||||||
goto unknown_command;
|
goto unknown_command;
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@ struct TranslationBlock;
|
||||||
* @gdb_write_register: Callback for letting GDB write a register.
|
* @gdb_write_register: Callback for letting GDB write a register.
|
||||||
* @vmsd: State description for migration.
|
* @vmsd: State description for migration.
|
||||||
* @gdb_num_core_regs: Number of core registers accessible to GDB.
|
* @gdb_num_core_regs: Number of core registers accessible to GDB.
|
||||||
|
* @gdb_core_xml_file: File name for core registers GDB XML description.
|
||||||
*
|
*
|
||||||
* Represents a CPU family or model.
|
* Represents a CPU family or model.
|
||||||
*/
|
*/
|
||||||
|
@ -125,6 +126,7 @@ typedef struct CPUClass {
|
||||||
|
|
||||||
const struct VMStateDescription *vmsd;
|
const struct VMStateDescription *vmsd;
|
||||||
int gdb_num_core_regs;
|
int gdb_num_core_regs;
|
||||||
|
const char *gdb_core_xml_file;
|
||||||
} CPUClass;
|
} CPUClass;
|
||||||
|
|
||||||
struct KVMState;
|
struct KVMState;
|
||||||
|
|
|
@ -7,6 +7,7 @@ stub-obj-y += fdset-add-fd.o
|
||||||
stub-obj-y += fdset-find-fd.o
|
stub-obj-y += fdset-find-fd.o
|
||||||
stub-obj-y += fdset-get-fd.o
|
stub-obj-y += fdset-get-fd.o
|
||||||
stub-obj-y += fdset-remove-fd.o
|
stub-obj-y += fdset-remove-fd.o
|
||||||
|
stub-obj-y += gdbstub.o
|
||||||
stub-obj-y += get-fd.o
|
stub-obj-y += get-fd.o
|
||||||
stub-obj-y += get-vm-name.o
|
stub-obj-y += get-vm-name.o
|
||||||
stub-obj-y += iothread-lock.o
|
stub-obj-y += iothread-lock.o
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "qemu-common.h"
|
||||||
|
|
||||||
|
const char *const xml_builtin[][2] = {
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
|
@ -831,6 +831,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
|
||||||
cc->vmsd = &vmstate_arm_cpu;
|
cc->vmsd = &vmstate_arm_cpu;
|
||||||
#endif
|
#endif
|
||||||
cc->gdb_num_core_regs = 26;
|
cc->gdb_num_core_regs = 26;
|
||||||
|
cc->gdb_core_xml_file = "arm-core.xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cpu_register(const ARMCPUInfo *info)
|
static void cpu_register(const ARMCPUInfo *info)
|
||||||
|
|
|
@ -197,6 +197,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data)
|
||||||
#endif
|
#endif
|
||||||
dc->vmsd = &vmstate_m68k_cpu;
|
dc->vmsd = &vmstate_m68k_cpu;
|
||||||
cc->gdb_num_core_regs = 18;
|
cc->gdb_num_core_regs = 18;
|
||||||
|
cc->gdb_core_xml_file = "cf-core.xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void register_cpu_type(const M68kCPUInfo *info)
|
static void register_cpu_type(const M68kCPUInfo *info)
|
||||||
|
|
|
@ -8465,6 +8465,11 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cc->gdb_num_core_regs = 71;
|
cc->gdb_num_core_regs = 71;
|
||||||
|
#if defined(TARGET_PPC64)
|
||||||
|
cc->gdb_core_xml_file = "power64-core.xml";
|
||||||
|
#else
|
||||||
|
cc->gdb_core_xml_file = "power-core.xml";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo ppc_cpu_type_info = {
|
static const TypeInfo ppc_cpu_type_info = {
|
||||||
|
|
Loading…
Reference in New Issue