Compare commits
2 Commits
05f7a713a3
...
d79f526ce2
Author | SHA1 | Date |
---|---|---|
|
d79f526ce2 | |
|
cc67856279 |
|
@ -56,6 +56,7 @@
|
||||||
"typeinfo": "cpp",
|
"typeinfo": "cpp",
|
||||||
"internals.h": "c",
|
"internals.h": "c",
|
||||||
"stdint.h": "c",
|
"stdint.h": "c",
|
||||||
"ctype.h": "c"
|
"ctype.h": "c",
|
||||||
|
"gdbstub.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -101,10 +101,4 @@ void gdb_extend_set_table(GPtrArray *table);
|
||||||
*/
|
*/
|
||||||
void gdb_extend_qsupported_features(char *qsupported_features);
|
void gdb_extend_qsupported_features(char *qsupported_features);
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a hex string to bytes. Conversion is done per byte, so 2 hex digits
|
|
||||||
* are converted to 1 byte. Invalid hex digits are treated as 0 digits.
|
|
||||||
*/
|
|
||||||
void gdb_hextomem(GByteArray *mem, const char *buf, int len);
|
|
||||||
|
|
||||||
#endif /* GDBSTUB_COMMANDS_H */
|
#endif /* GDBSTUB_COMMANDS_H */
|
||||||
|
|
|
@ -796,17 +796,6 @@ enum CPUDumpFlags {
|
||||||
*/
|
*/
|
||||||
CPUState *cpu_create(const char *tname);
|
CPUState *cpu_create(const char *tname);
|
||||||
|
|
||||||
/**
|
|
||||||
* parse_cpu_option:
|
|
||||||
* @cpu_option: The -cpu option including optional parameters.
|
|
||||||
*
|
|
||||||
* processes optional parameters and registers them as global properties
|
|
||||||
*
|
|
||||||
* Returns: type of CPU to create or prints error and terminates process
|
|
||||||
* if an error occurred.
|
|
||||||
*/
|
|
||||||
const char *parse_cpu_option(const char *cpu_option);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemu_cpu_is_self:
|
* qemu_cpu_is_self:
|
||||||
* @cpu: The vCPU to check against.
|
* @cpu: The vCPU to check against.
|
||||||
|
|
|
@ -23,27 +23,6 @@
|
||||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #include "qemu/osdep.h"
|
|
||||||
// #include "qemu/ctype.h"
|
|
||||||
// #include "qemu/cutils.h"
|
|
||||||
// #include "qemu/module.h"
|
|
||||||
// #include "qemu/error-report.h"
|
|
||||||
// #include "qemu/target-info.h"
|
|
||||||
// #include "trace.h"
|
|
||||||
// #include "exec/gdbstub.h"
|
|
||||||
// #include "gdbstub/commands.h"
|
|
||||||
// #include "gdbstub/syscalls.h"
|
|
||||||
// #include "hw/cpu/cluster.h"
|
|
||||||
// #include "hw/boards.h"
|
|
||||||
// #include "hw/core/cpu.h"
|
|
||||||
|
|
||||||
// #include "system/hw_accel.h"
|
|
||||||
// #include "system/runstate.h"
|
|
||||||
// #include "exec/replay-core.h"
|
|
||||||
// #include "exec/hwaddr.h"
|
|
||||||
|
|
||||||
#include "gdbstub.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
@ -51,15 +30,6 @@
|
||||||
#include "enums.h"
|
#include "enums.h"
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
|
|
||||||
// #include "trace.h"
|
|
||||||
|
|
||||||
typedef struct GDBRegisterState {
|
|
||||||
int base_reg;
|
|
||||||
gdb_get_reg_cb get_reg;
|
|
||||||
gdb_set_reg_cb set_reg;
|
|
||||||
const GDBFeature *feature;
|
|
||||||
} GDBRegisterState;
|
|
||||||
|
|
||||||
GDBState gdbserver_state;
|
GDBState gdbserver_state;
|
||||||
|
|
||||||
void gdb_init_gdbserver_state(void) {
|
void gdb_init_gdbserver_state(void) {
|
||||||
|
@ -101,43 +71,10 @@ void gdb_hextomem(GByteArray *mem, const char *buf, int len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hexdump(const char *buf, int len, void (*trace_fn)(size_t ofs, char const *text)) {
|
|
||||||
char line_buffer[3 * 16 + 4 + 16 + 1];
|
|
||||||
|
|
||||||
size_t i;
|
|
||||||
for (i = 0; i < len || (i & 0xF); ++i) {
|
|
||||||
size_t byte_ofs = i & 15;
|
|
||||||
|
|
||||||
if (byte_ofs == 0) {
|
|
||||||
memset(line_buffer, ' ', 3 * 16 + 4 + 16);
|
|
||||||
line_buffer[3 * 16 + 4 + 16] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t col_group = (i >> 2) & 3;
|
|
||||||
size_t hex_col = byte_ofs * 3 + col_group;
|
|
||||||
size_t txt_col = 3 * 16 + 4 + byte_ofs;
|
|
||||||
|
|
||||||
if (i < len) {
|
|
||||||
char value = buf[i];
|
|
||||||
|
|
||||||
line_buffer[hex_col + 0] = tohex((value >> 4) & 0xF);
|
|
||||||
line_buffer[hex_col + 1] = tohex((value >> 0) & 0xF);
|
|
||||||
line_buffer[txt_col + 0] = (value >= ' ' && value < 127) ? value : '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (byte_ofs == 0xF) trace_fn(i & -16, line_buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return -1 if error, 0 if OK */
|
|
||||||
int gdb_put_packet_binary(const char *buf, int len, bool dump) {
|
int gdb_put_packet_binary(const char *buf, int len, bool dump) {
|
||||||
int csum, i;
|
int csum, i;
|
||||||
uint8_t footer[3];
|
uint8_t footer[3];
|
||||||
|
|
||||||
// if (dump && trace_event_get_state_backends(TRACE_GDBSTUB_IO_BINARYREPLY)) {
|
|
||||||
// hexdump(buf, len, trace_gdbstub_io_binaryreply);
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
g_byte_array_set_size(gdbserver_state.last_packet, 0);
|
g_byte_array_set_size(gdbserver_state.last_packet, 0);
|
||||||
g_byte_array_append(gdbserver_state.last_packet, (const uint8_t *)"$", 1);
|
g_byte_array_append(gdbserver_state.last_packet, (const uint8_t *)"$", 1);
|
||||||
|
@ -160,16 +97,10 @@ int gdb_put_packet_binary(const char *buf, int len, bool dump) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return -1 if error, 0 if OK */
|
int gdb_put_packet(const char *buf) { return gdb_put_packet_binary(buf, strlen(buf), false); }
|
||||||
int gdb_put_packet(const char *buf) {
|
|
||||||
// trace_gdbstub_io_reply(buf);
|
|
||||||
|
|
||||||
return gdb_put_packet_binary(buf, strlen(buf), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdb_put_strbuf(void) { gdb_put_packet(gdbserver_state.str_buf->str); }
|
void gdb_put_strbuf(void) { gdb_put_packet(gdbserver_state.str_buf->str); }
|
||||||
|
|
||||||
/* Encode data using the encoding for 'x' packets. */
|
|
||||||
void gdb_memtox(GString *buf, const char *mem, int len) {
|
void gdb_memtox(GString *buf, const char *mem, int len) {
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
|
@ -190,207 +121,6 @@ void gdb_memtox(GString *buf, const char *mem, int len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t gdb_get_cpu_pid(CPUState *cpu) {
|
|
||||||
if (cpu->cluster_index == UNASSIGNED_CLUSTER_INDEX) {
|
|
||||||
/* Return the default process' PID */
|
|
||||||
int index = gdbserver_state.process_num - 1;
|
|
||||||
return gdbserver_state.processes[index].pid;
|
|
||||||
}
|
|
||||||
return cpu->cluster_index + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
GDBProcess *gdb_get_process(uint32_t pid) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!pid) {
|
|
||||||
/* 0 means any process, we take the first one */
|
|
||||||
return &gdbserver_state.processes[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < gdbserver_state.process_num; i++) {
|
|
||||||
if (gdbserver_state.processes[i].pid == pid) {
|
|
||||||
return &gdbserver_state.processes[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GDBProcess *gdb_get_cpu_process(CPUState *cpu) { return gdb_get_process(gdb_get_cpu_pid(cpu)); }
|
|
||||||
|
|
||||||
static CPUState *find_cpu(uint32_t thread_id) {
|
|
||||||
CPUState *cpu;
|
|
||||||
|
|
||||||
CPU_FOREACH(cpu) {
|
|
||||||
if (gdb_get_cpu_index(c) == thread_id) {
|
|
||||||
return cpu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
CPUState *gdb_get_first_cpu_in_process(GDBProcess *process) {
|
|
||||||
CPUState *cpu;
|
|
||||||
|
|
||||||
CPU_FOREACH(cpu) {
|
|
||||||
if (gdb_get_cpu_pid(c) == process->pid) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static CPUState *gdb_next_cpu_in_process(CPUState *cpu) {
|
|
||||||
uint32_t pid = gdb_get_cpu_pid(cpu);
|
|
||||||
cpu = cpu_next(cpu);
|
|
||||||
|
|
||||||
while (cpu) {
|
|
||||||
if (gdb_get_cpu_pid(cpu) == pid) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cpu = cpu_next(cpu);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the cpu following @cpu, while ignoring unattached processes. */
|
|
||||||
static CPUState *gdb_next_attached_cpu(CPUState *cpu) {
|
|
||||||
cpu = cpu_next(cpu);
|
|
||||||
|
|
||||||
while (cpu) {
|
|
||||||
if (gdb_get_cpu_process(cpu)->attached) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cpu = cpu_next(cpu);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the first attached cpu */
|
|
||||||
CPUState *gdb_first_attached_cpu(void) {
|
|
||||||
CPUState *cpu = get_cpu();
|
|
||||||
GDBProcess *process = gdb_get_cpu_process(cpu);
|
|
||||||
|
|
||||||
if (!process->attached) {
|
|
||||||
return gdb_next_attached_cpu(cpu);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
static CPUState *gdb_get_cpu(uint32_t pid, uint32_t tid) {
|
|
||||||
GDBProcess *process;
|
|
||||||
CPUState *cpu;
|
|
||||||
|
|
||||||
if (!pid && !tid) {
|
|
||||||
/* 0 means any process/thread, we take the first attached one */
|
|
||||||
return gdb_first_attached_cpu();
|
|
||||||
} else if (pid && !tid) {
|
|
||||||
/* any thread in a specific process */
|
|
||||||
process = gdb_get_process(pid);
|
|
||||||
|
|
||||||
if (process == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!process->attached) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return gdb_get_first_cpu_in_process(process);
|
|
||||||
} else {
|
|
||||||
/* a specific thread */
|
|
||||||
cpu = find_cpu(tid);
|
|
||||||
|
|
||||||
if (cpu == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
process = gdb_get_cpu_process(cpu);
|
|
||||||
|
|
||||||
if (pid && process->pid != pid) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!process->attached) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cpu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *get_feature_xml(const char *p, const char **newp, GDBProcess *process) {
|
|
||||||
CPUState *cpu = gdb_get_first_cpu_in_process(process);
|
|
||||||
GDBRegisterState *r;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* qXfer:features:read:ANNEX:OFFSET,LENGTH'
|
|
||||||
* ^p ^newp
|
|
||||||
*/
|
|
||||||
const char *term = strchr(p, ':');
|
|
||||||
*newp = term + 1;
|
|
||||||
len = term - p;
|
|
||||||
|
|
||||||
/* Is it the main target xml? */
|
|
||||||
if (strncmp(p, "target.xml", len) == 0) {
|
|
||||||
if (!process->target_xml) {
|
|
||||||
g_autoptr(GPtrArray) xml = g_ptr_array_new_with_free_func(g_free);
|
|
||||||
|
|
||||||
g_ptr_array_add(xml, g_strdup("<?xml version=\"1.0\"?>"
|
|
||||||
"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
|
|
||||||
"<target>"));
|
|
||||||
|
|
||||||
if (cpu->cc->gdb_arch_name) {
|
|
||||||
g_ptr_array_add(xml, g_markup_printf_escaped("<architecture>%s</architecture>", cpu->cc->gdb_arch_name(cpu)));
|
|
||||||
}
|
|
||||||
for (guint i = 0; i < cpu->gdb_regs->len; i++) {
|
|
||||||
r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i);
|
|
||||||
g_ptr_array_add(xml, g_markup_printf_escaped("<xi:include href=\"%s\"/>", r->feature->xmlname));
|
|
||||||
}
|
|
||||||
g_ptr_array_add(xml, g_strdup("</target>"));
|
|
||||||
g_ptr_array_add(xml, NULL);
|
|
||||||
|
|
||||||
process->target_xml = g_strjoinv(NULL, (gchar **)xml->pdata);
|
|
||||||
}
|
|
||||||
return process->target_xml;
|
|
||||||
}
|
|
||||||
/* Is it one of the features? */
|
|
||||||
for (guint i = 0; i < cpu->gdb_regs->len; i++) {
|
|
||||||
r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i);
|
|
||||||
if (strncmp(p, r->feature->xmlname, len) == 0) {
|
|
||||||
return r->feature->xml;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* failed */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature, const char *name, const char *xmlname,
|
|
||||||
int base_reg) {
|
|
||||||
char *header = g_markup_printf_escaped(
|
|
||||||
"<?xml version=\"1.0\"?>"
|
|
||||||
"<!DOCTYPE feature SYSTEM \"gdb-target.dtd\">"
|
|
||||||
"<feature name=\"%s\">",
|
|
||||||
name);
|
|
||||||
|
|
||||||
builder->feature = feature;
|
|
||||||
builder->xml = g_ptr_array_new();
|
|
||||||
g_ptr_array_add(builder->xml, header);
|
|
||||||
builder->regs = g_ptr_array_new();
|
|
||||||
builder->base_reg = base_reg;
|
|
||||||
feature->xmlname = xmlname;
|
|
||||||
feature->name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, const char *format, ...) {
|
void gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, const char *format, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
@ -495,87 +225,8 @@ int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdb_register_feature(CPUState *cpu, int base_reg, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
|
static void gdb_process_breakpoint_remove_all() {
|
||||||
const GDBFeature *feature) {
|
CPUState *cpu = get_cpu();
|
||||||
GDBRegisterState s = {.base_reg = base_reg, .get_reg = get_reg, .set_reg = set_reg, .feature = feature};
|
|
||||||
|
|
||||||
g_array_append_val(cpu->gdb_regs, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *gdb_get_core_xml_file(CPUState *cpu) {
|
|
||||||
CPUClass *cc = cpu->cc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The CPU class can provide the XML filename via a method,
|
|
||||||
* or as a simple fixed string field.
|
|
||||||
*/
|
|
||||||
if (cc->gdb_get_core_xml_file) {
|
|
||||||
return cc->gdb_get_core_xml_file(cpu);
|
|
||||||
}
|
|
||||||
return cc->gdb_core_xml_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdb_init_cpu(CPUState *cpu) {
|
|
||||||
CPUClass *cc = cpu->cc;
|
|
||||||
const GDBFeature *feature;
|
|
||||||
const char *xmlfile = gdb_get_core_xml_file(cpu);
|
|
||||||
|
|
||||||
cpu->gdb_regs = g_array_new(false, false, sizeof(GDBRegisterState));
|
|
||||||
|
|
||||||
if (xmlfile) {
|
|
||||||
feature = gdb_find_static_feature(xmlfile);
|
|
||||||
gdb_register_feature(cpu, 0, cc->gdb_read_register, cc->gdb_write_register, feature);
|
|
||||||
cpu->gdb_num_regs = cpu->gdb_num_g_regs = feature->num_regs;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cc->gdb_num_core_regs) {
|
|
||||||
cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, const GDBFeature *feature,
|
|
||||||
int g_pos) {
|
|
||||||
GDBRegisterState *s;
|
|
||||||
guint i;
|
|
||||||
int base_reg = cpu->gdb_num_regs;
|
|
||||||
|
|
||||||
for (i = 0; i < cpu->gdb_regs->len; i++) {
|
|
||||||
/* Check for duplicates. */
|
|
||||||
s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i);
|
|
||||||
if (s->feature == feature) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gdb_register_feature(cpu, base_reg, get_reg, set_reg, feature);
|
|
||||||
|
|
||||||
/* Add to end of list. */
|
|
||||||
cpu->gdb_num_regs += feature->num_regs;
|
|
||||||
if (g_pos) {
|
|
||||||
if (g_pos != base_reg) {
|
|
||||||
std::cout << "Error: Bad gdb register numbering for" << feature->xml << ", xpected " << g_pos << " got "
|
|
||||||
<< base_reg << std::endl;
|
|
||||||
} else {
|
|
||||||
cpu->gdb_num_g_regs = cpu->gdb_num_regs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdb_unregister_coprocessor_all(CPUState *cpu) {
|
|
||||||
/*
|
|
||||||
* Safe to nuke everything. GDBRegisterState::xml is static const char so
|
|
||||||
* it won't be freed
|
|
||||||
*/
|
|
||||||
g_array_free(cpu->gdb_regs, true);
|
|
||||||
|
|
||||||
cpu->gdb_regs = NULL;
|
|
||||||
cpu->gdb_num_regs = 0;
|
|
||||||
cpu->gdb_num_g_regs = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gdb_process_breakpoint_remove_all(GDBProcess *p) {
|
|
||||||
CPUState *cpu = gdb_get_first_cpu_in_process(p);
|
|
||||||
|
|
||||||
while (cpu) {
|
while (cpu) {
|
||||||
gdb_breakpoint_remove_all(cpu);
|
gdb_breakpoint_remove_all(cpu);
|
||||||
cpu = gdb_next_cpu_in_process(cpu);
|
cpu = gdb_next_cpu_in_process(cpu);
|
||||||
|
@ -589,13 +240,7 @@ static void gdb_set_cpu_pc(vaddr pc) {
|
||||||
cpu_set_pc(cpu, pc);
|
cpu_set_pc(cpu, pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gdb_append_thread_id(CPUState *cpu, GString *buf) {
|
void gdb_append_thread_id(CPUState *cpu, GString *buf) { g_string_append_printf(buf, "%02x", gdb_get_cpu_index(cpu)); }
|
||||||
if (gdbserver_state.multiprocess) {
|
|
||||||
g_string_append_printf(buf, "p%02x.%02x", gdb_get_cpu_pid(cpu), gdb_get_cpu_index(cpu));
|
|
||||||
} else {
|
|
||||||
g_string_append_printf(buf, "%02x", gdb_get_cpu_index(cpu));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, uint32_t *pid, uint32_t *tid) {
|
static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, uint32_t *pid, uint32_t *tid) {
|
||||||
unsigned long p, t;
|
unsigned long p, t;
|
||||||
|
@ -642,11 +287,6 @@ static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, uin
|
||||||
return GDB_ONE_THREAD;
|
return GDB_ONE_THREAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_handle_vcont - Parses and handles a vCont packet.
|
|
||||||
* returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if there is
|
|
||||||
* a format error, 0 on success.
|
|
||||||
*/
|
|
||||||
static int gdb_handle_vcont(const char *p) {
|
static int gdb_handle_vcont(const char *p) {
|
||||||
int res, signal = 0;
|
int res, signal = 0;
|
||||||
char cur_action;
|
char cur_action;
|
||||||
|
@ -659,8 +299,7 @@ static int gdb_handle_vcont(const char *p) {
|
||||||
/* uninitialised CPUs stay 0 */
|
/* uninitialised CPUs stay 0 */
|
||||||
g_autofree char *newstates = g_new0(char, max_cpus);
|
g_autofree char *newstates = g_new0(char, max_cpus);
|
||||||
|
|
||||||
/* mark valid CPUs with 1 */
|
newstates[get_cpu()->cpu_index] = 1;
|
||||||
CPU_FOREACH(cpu) { newstates[c->cpu_index] = 1; }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* res keeps track of what error we are returning, with -ENOTSUP meaning
|
* res keeps track of what error we are returning, with -ENOTSUP meaning
|
||||||
|
@ -729,27 +368,22 @@ static int gdb_handle_vcont(const char *p) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDB_ALL_THREADS:
|
case GDB_ALL_THREADS:
|
||||||
process = gdb_get_process(pid);
|
process = gdb_get_process();
|
||||||
|
|
||||||
if (!process->attached) {
|
if (!process->attached) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
cpu = get_cpu();
|
||||||
cpu = gdb_get_first_cpu_in_process(process);
|
if (cpu) {
|
||||||
while (cpu) {
|
|
||||||
if (newstates[cpu->cpu_index] == 1) {
|
if (newstates[cpu->cpu_index] == 1) {
|
||||||
newstates[cpu->cpu_index] = cur_action;
|
newstates[cpu->cpu_index] = cur_action;
|
||||||
|
|
||||||
target_count++;
|
target_count++;
|
||||||
last_target = cpu;
|
last_target = cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu = gdb_next_cpu_in_process(cpu);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDB_ONE_THREAD:
|
case GDB_ONE_THREAD:
|
||||||
cpu = gdb_get_cpu(pid, tid);
|
cpu = gdb_get_cpu();
|
||||||
|
|
||||||
/* invalid CPU/thread specified */
|
/* invalid CPU/thread specified */
|
||||||
if (!cpu) {
|
if (!cpu) {
|
||||||
|
@ -917,30 +551,16 @@ static void run_cmd_parser(const char *data, const GdbCmdParseEntry *cmd) {
|
||||||
static void handle_detach(GArray *params, void *user_ctx) {
|
static void handle_detach(GArray *params, void *user_ctx) {
|
||||||
GDBProcess *process;
|
GDBProcess *process;
|
||||||
uint32_t pid = 1;
|
uint32_t pid = 1;
|
||||||
|
process = gdb_get_process();
|
||||||
if (gdbserver_state.multiprocess) {
|
gdb_process_breakpoint_remove_all();
|
||||||
if (!params->len) {
|
|
||||||
gdb_put_packet("E22");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pid = gdb_get_cmd_param(params, 0)->val_ul;
|
|
||||||
}
|
|
||||||
|
|
||||||
process = gdb_get_process(pid);
|
|
||||||
gdb_process_breakpoint_remove_all(process);
|
|
||||||
process->attached = false;
|
process->attached = false;
|
||||||
|
|
||||||
if (pid == gdb_get_cpu_pid(gdbserver_state.c_cpu)) {
|
if (pid == gdb_get_cpu_pid(gdbserver_state.c_cpu)) {
|
||||||
gdbserver_state.c_cpu = gdb_first_attached_cpu();
|
gdbserver_state.c_cpu = gdb_first_attached_cpu();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pid == gdb_get_cpu_pid(gdbserver_state.g_cpu)) {
|
if (pid == gdb_get_cpu_pid(gdbserver_state.g_cpu)) {
|
||||||
gdbserver_state.g_cpu = gdb_first_attached_cpu();
|
gdbserver_state.g_cpu = gdb_first_attached_cpu();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gdbserver_state.c_cpu) {
|
if (!gdbserver_state.c_cpu) {
|
||||||
/* No more process attached */
|
|
||||||
gdb_disable_syscalls();
|
gdb_disable_syscalls();
|
||||||
gdb_continue();
|
gdb_continue();
|
||||||
}
|
}
|
||||||
|
@ -949,23 +569,19 @@ static void handle_detach(GArray *params, void *user_ctx) {
|
||||||
|
|
||||||
static void handle_thread_alive(GArray *params, void *user_ctx) {
|
static void handle_thread_alive(GArray *params, void *user_ctx) {
|
||||||
CPUState *cpu;
|
CPUState *cpu;
|
||||||
|
|
||||||
if (!params->len) {
|
if (!params->len) {
|
||||||
gdb_put_packet("E22");
|
gdb_put_packet("E22");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gdb_get_cmd_param(params, 0)->thread_id.kind == GDB_READ_THREAD_ERR) {
|
if (gdb_get_cmd_param(params, 0)->thread_id.kind == GDB_READ_THREAD_ERR) {
|
||||||
gdb_put_packet("E22");
|
gdb_put_packet("E22");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
cpu = gdb_get_cpu();
|
||||||
cpu = gdb_get_cpu(gdb_get_cmd_param(params, 0)->thread_id.pid, gdb_get_cmd_param(params, 0)->thread_id.tid);
|
|
||||||
if (!cpu) {
|
if (!cpu) {
|
||||||
gdb_put_packet("E22");
|
gdb_put_packet("E22");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdb_put_packet("OK");
|
gdb_put_packet("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -973,14 +589,12 @@ static void handle_continue(GArray *params, void *user_ctx) {
|
||||||
if (params->len) {
|
if (params->len) {
|
||||||
gdb_set_cpu_pc(gdb_get_cmd_param(params, 0)->val_ull);
|
gdb_set_cpu_pc(gdb_get_cmd_param(params, 0)->val_ull);
|
||||||
}
|
}
|
||||||
|
|
||||||
gdbserver_state.signal = 0;
|
gdbserver_state.signal = 0;
|
||||||
gdb_continue();
|
gdb_continue();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_cont_with_sig(GArray *params, void *user_ctx) {
|
static void handle_cont_with_sig(GArray *params, void *user_ctx) {
|
||||||
unsigned long signal = 0;
|
unsigned long signal = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: C sig;[addr] is currently unsupported and we simply
|
* Note: C sig;[addr] is currently unsupported and we simply
|
||||||
* omit the addr parameter
|
* omit the addr parameter
|
||||||
|
@ -988,7 +602,6 @@ static void handle_cont_with_sig(GArray *params, void *user_ctx) {
|
||||||
if (params->len) {
|
if (params->len) {
|
||||||
signal = gdb_get_cmd_param(params, 0)->val_ul;
|
signal = gdb_get_cmd_param(params, 0)->val_ul;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdbserver_state.signal = gdb_signal_to_target(signal);
|
gdbserver_state.signal = gdb_signal_to_target(signal);
|
||||||
if (gdbserver_state.signal == -1) {
|
if (gdbserver_state.signal == -1) {
|
||||||
gdbserver_state.signal = 0;
|
gdbserver_state.signal = 0;
|
||||||
|
@ -999,31 +612,25 @@ static void handle_cont_with_sig(GArray *params, void *user_ctx) {
|
||||||
static void handle_set_thread(GArray *params, void *user_ctx) {
|
static void handle_set_thread(GArray *params, void *user_ctx) {
|
||||||
uint32_t pid, tid;
|
uint32_t pid, tid;
|
||||||
CPUState *cpu;
|
CPUState *cpu;
|
||||||
|
|
||||||
if (params->len != 2) {
|
if (params->len != 2) {
|
||||||
gdb_put_packet("E22");
|
gdb_put_packet("E22");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gdb_get_cmd_param(params, 1)->thread_id.kind == GDB_READ_THREAD_ERR) {
|
if (gdb_get_cmd_param(params, 1)->thread_id.kind == GDB_READ_THREAD_ERR) {
|
||||||
gdb_put_packet("E22");
|
gdb_put_packet("E22");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gdb_get_cmd_param(params, 1)->thread_id.kind != GDB_ONE_THREAD) {
|
if (gdb_get_cmd_param(params, 1)->thread_id.kind != GDB_ONE_THREAD) {
|
||||||
gdb_put_packet("OK");
|
gdb_put_packet("OK");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid = gdb_get_cmd_param(params, 1)->thread_id.pid;
|
pid = gdb_get_cmd_param(params, 1)->thread_id.pid;
|
||||||
tid = gdb_get_cmd_param(params, 1)->thread_id.tid;
|
tid = gdb_get_cmd_param(params, 1)->thread_id.tid;
|
||||||
|
cpu = gdb_get_cpu();
|
||||||
cpu = gdb_get_cpu(pid, tid);
|
|
||||||
if (!cpu) {
|
if (!cpu) {
|
||||||
gdb_put_packet("E22");
|
gdb_put_packet("E22");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: This command is deprecated and modern gdb's will be using the
|
* Note: This command is deprecated and modern gdb's will be using the
|
||||||
* vCont command instead.
|
* vCont command instead.
|
||||||
|
@ -1085,17 +692,6 @@ static void handle_remove_bp(GArray *params, void *user_ctx) {
|
||||||
gdb_put_packet("E22");
|
gdb_put_packet("E22");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* handle_set/get_reg
|
|
||||||
*
|
|
||||||
* Older gdb are really dumb, and don't use 'G/g' if 'P/p' is available.
|
|
||||||
* This works, but can be very slow. Anything new enough to understand
|
|
||||||
* XML also knows how to use this properly. However to use this we
|
|
||||||
* need to define a local XML file as well as be talking to a
|
|
||||||
* reasonably modern gdb. Responding with an empty packet will cause
|
|
||||||
* the remote gdb to fallback to older methods.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void handle_set_reg(GArray *params, void *user_ctx) {
|
static void handle_set_reg(GArray *params, void *user_ctx) {
|
||||||
int reg_size;
|
int reg_size;
|
||||||
|
|
||||||
|
@ -1218,37 +814,11 @@ static void handle_step(GArray *params, void *user_ctx) {
|
||||||
if (params->len) {
|
if (params->len) {
|
||||||
gdb_set_cpu_pc(gdb_get_cmd_param(params, 0)->val_ull);
|
gdb_set_cpu_pc(gdb_get_cmd_param(params, 0)->val_ull);
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu_single_step(gdbserver_state.c_cpu, gdbserver_state.sstep_flags);
|
cpu_single_step(gdbserver_state.c_cpu, gdbserver_state.sstep_flags);
|
||||||
gdb_continue();
|
gdb_continue();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_backward(GArray *params, void *user_ctx) {
|
static void handle_backward(GArray *params, void *user_ctx) { gdb_put_packet("E22"); }
|
||||||
if (!gdb_can_reverse()) {
|
|
||||||
gdb_put_packet("E22");
|
|
||||||
}
|
|
||||||
if (params->len == 1) {
|
|
||||||
switch (gdb_get_cmd_param(params, 0)->opcode) {
|
|
||||||
case 's':
|
|
||||||
// if (replay_reverse_step()) {
|
|
||||||
// gdb_continue();
|
|
||||||
// } else {
|
|
||||||
gdb_put_packet("E14");
|
|
||||||
// }
|
|
||||||
return;
|
|
||||||
case 'c':
|
|
||||||
// if (replay_reverse_continue()) {
|
|
||||||
// gdb_continue();
|
|
||||||
// } else {
|
|
||||||
gdb_put_packet("E14");
|
|
||||||
// }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Default invalid command */
|
|
||||||
gdb_put_packet("");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_v_cont_query(GArray *params, void *user_ctx) { gdb_put_packet("vCont;c;C;s;S"); }
|
static void handle_v_cont_query(GArray *params, void *user_ctx) { gdb_put_packet("vCont;c;C;s;S"); }
|
||||||
|
|
||||||
|
@ -1276,12 +846,12 @@ static void handle_v_attach(GArray *params, void *user_ctx) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
process = gdb_get_process(gdb_get_cmd_param(params, 0)->val_ul);
|
process = gdb_get_process();
|
||||||
if (!process) {
|
if (!process) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu = gdb_get_first_cpu_in_process(process);
|
cpu = get_cpu();
|
||||||
if (!cpu) {
|
if (!cpu) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -1372,8 +942,8 @@ static void handle_query_curr_tid(GArray *params, void *user_ctx) {
|
||||||
* the first thread of the current process (gdb returns the
|
* the first thread of the current process (gdb returns the
|
||||||
* first thread).
|
* first thread).
|
||||||
*/
|
*/
|
||||||
process = gdb_get_cpu_process(gdbserver_state.g_cpu);
|
process = gdb_get_process();
|
||||||
cpu = gdb_get_first_cpu_in_process(process);
|
cpu = get_cpu();
|
||||||
g_string_assign(gdbserver_state.str_buf, "QC");
|
g_string_assign(gdbserver_state.str_buf, "QC");
|
||||||
gdb_append_thread_id(cpu, gdbserver_state.str_buf);
|
gdb_append_thread_id(cpu, gdbserver_state.str_buf);
|
||||||
gdb_put_strbuf();
|
gdb_put_strbuf();
|
||||||
|
@ -1404,21 +974,16 @@ static void handle_query_first_threads(GArray *params, void *user_ctx) {
|
||||||
static void handle_query_thread_extra(GArray *params, void *user_ctx) {
|
static void handle_query_thread_extra(GArray *params, void *user_ctx) {
|
||||||
g_autoptr(GString) rs = g_string_new(NULL);
|
g_autoptr(GString) rs = g_string_new(NULL);
|
||||||
CPUState *cpu;
|
CPUState *cpu;
|
||||||
|
|
||||||
if (!params->len || gdb_get_cmd_param(params, 0)->thread_id.kind == GDB_READ_THREAD_ERR) {
|
if (!params->len || gdb_get_cmd_param(params, 0)->thread_id.kind == GDB_READ_THREAD_ERR) {
|
||||||
gdb_put_packet("E22");
|
gdb_put_packet("E22");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
cpu = gdb_get_cpu();
|
||||||
cpu = gdb_get_cpu(gdb_get_cmd_param(params, 0)->thread_id.pid, gdb_get_cmd_param(params, 0)->thread_id.tid);
|
|
||||||
if (!cpu) {
|
if (!cpu) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu_synchronize_state(cpu);
|
cpu_synchronize_state(cpu);
|
||||||
|
|
||||||
g_string_printf(rs, "CPU#%d [%s]", cpu->cpu_index, cpu->halted ? "halted " : "running");
|
g_string_printf(rs, "CPU#%d [%s]", cpu->cpu_index, cpu->halted ? "halted " : "running");
|
||||||
// trace_gdbstub_op_extra_info(rs->str);
|
|
||||||
gdb_memtohex(gdbserver_state.str_buf, (uint8_t *)rs->str, rs->len);
|
gdb_memtohex(gdbserver_state.str_buf, (uint8_t *)rs->str, rs->len);
|
||||||
gdb_put_strbuf();
|
gdb_put_strbuf();
|
||||||
}
|
}
|
||||||
|
@ -1441,20 +1006,6 @@ static void handle_query_supported(GArray *params, void *user_ctx) {
|
||||||
if (gdb_get_core_xml_file(get_cpu())) {
|
if (gdb_get_core_xml_file(get_cpu())) {
|
||||||
g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+");
|
g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gdb_can_reverse()) {
|
|
||||||
g_string_append(gdbserver_state.str_buf, ";ReverseStep+;ReverseContinue+");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params->len) {
|
|
||||||
const char *gdb_supported = gdb_get_cmd_param(params, 0)->data;
|
|
||||||
if (strstr(gdb_supported, "multiprocess+")) {
|
|
||||||
gdbserver_state.multiprocess = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_string_append(gdbserver_state.str_buf, ";vContSupported+;multiprocess+");
|
|
||||||
|
|
||||||
if (extra_query_flags) {
|
if (extra_query_flags) {
|
||||||
int extras = g_strv_length(extra_query_flags);
|
int extras = g_strv_length(extra_query_flags);
|
||||||
for (int i = 0; i < extras; i++) {
|
for (int i = 0; i < extras; i++) {
|
||||||
|
@ -1476,7 +1027,7 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
process = gdb_get_cpu_process(gdbserver_state.g_cpu);
|
process = gdb_get_process();
|
||||||
if (!gdb_get_core_xml_file(gdbserver_state.g_cpu)) {
|
if (!gdb_get_core_xml_file(gdbserver_state.g_cpu)) {
|
||||||
gdb_put_packet("");
|
gdb_put_packet("");
|
||||||
return;
|
return;
|
||||||
|
@ -1531,17 +1082,6 @@ static const GdbCmdParseEntry gdb_gen_query_set_common_table[] = {
|
||||||
{.handler = handle_set_qemu_sstep, .cmd = "qemu.sstep=", .cmd_startswith = true, .schema = "l0"},
|
{.handler = handle_set_qemu_sstep, .cmd = "qemu.sstep=", .cmd_startswith = true, .schema = "l0"},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* extend_table() - extend one of the command tables
|
|
||||||
* @table: the command table to extend (or NULL)
|
|
||||||
* @extensions: a list of GdbCmdParseEntry pointers
|
|
||||||
*
|
|
||||||
* The entries themselves should be pointers to static const
|
|
||||||
* GdbCmdParseEntry entries. If the entry is already in the table we
|
|
||||||
* skip adding it again.
|
|
||||||
*
|
|
||||||
* Returns (a potentially freshly allocated) GPtrArray of GdbCmdParseEntry
|
|
||||||
*/
|
|
||||||
static GPtrArray *extend_table(GPtrArray *table, GPtrArray *extensions) {
|
static GPtrArray *extend_table(GPtrArray *table, GPtrArray *extensions) {
|
||||||
if (!table) {
|
if (!table) {
|
||||||
table = g_ptr_array_new();
|
table = g_ptr_array_new();
|
||||||
|
@ -1557,13 +1097,6 @@ static GPtrArray *extend_table(GPtrArray *table, GPtrArray *extensions) {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* process_extended_table() - run through an extended command table
|
|
||||||
* @table: the command table to check
|
|
||||||
* @data: parameters
|
|
||||||
*
|
|
||||||
* returns true if the command was found and executed
|
|
||||||
*/
|
|
||||||
static bool process_extended_table(GPtrArray *table, const char *data) {
|
static bool process_extended_table(GPtrArray *table, const char *data) {
|
||||||
for (int i = 0; i < table->len; i++) {
|
for (int i = 0; i < table->len; i++) {
|
||||||
const GdbCmdParseEntry *entry = (GdbCmdParseEntry *)g_ptr_array_index(table, i);
|
const GdbCmdParseEntry *entry = (GdbCmdParseEntry *)g_ptr_array_index(table, i);
|
||||||
|
@ -1574,7 +1107,6 @@ static bool process_extended_table(GPtrArray *table, const char *data) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ptr to GdbCmdParseEntry */
|
|
||||||
static GPtrArray *extended_query_table;
|
static GPtrArray *extended_query_table;
|
||||||
|
|
||||||
void gdb_extend_query_table(GPtrArray *new_queries) {
|
void gdb_extend_query_table(GPtrArray *new_queries) {
|
||||||
|
@ -1618,7 +1150,6 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Ptr to GdbCmdParseEntry */
|
|
||||||
static GPtrArray *extended_set_table;
|
static GPtrArray *extended_set_table;
|
||||||
|
|
||||||
void gdb_extend_set_table(GPtrArray *new_set) { extended_set_table = extend_table(extended_set_table, new_set); }
|
void gdb_extend_set_table(GPtrArray *new_set) { extended_set_table = extend_table(extended_set_table, new_set); }
|
||||||
|
@ -1830,21 +1361,6 @@ static RSState gdb_handle_packet(const char *line_buf) {
|
||||||
return RS_IDLE;
|
return RS_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gdb_set_stop_cpu(CPUState *cpu) {
|
|
||||||
GDBProcess *p = gdb_get_cpu_process(cpu);
|
|
||||||
|
|
||||||
if (!p->attached) {
|
|
||||||
/*
|
|
||||||
* Having a stop CPU corresponding to a process that is not attached
|
|
||||||
* confuses GDB. So we ignore the request.
|
|
||||||
*/
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdbserver_state.c_cpu = cpu;
|
|
||||||
gdbserver_state.g_cpu = cpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdb_read_byte(uint8_t ch) {
|
void gdb_read_byte(uint8_t ch) {
|
||||||
uint8_t reply;
|
uint8_t reply;
|
||||||
|
|
||||||
|
@ -2001,28 +1517,3 @@ void gdb_read_byte(uint8_t ch) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Create the process that will contain all the "orphan" CPUs (that are not
|
|
||||||
* part of a CPU cluster). Note that if this process contains no CPUs, it won't
|
|
||||||
* be attachable and thus will be invisible to the user.
|
|
||||||
*/
|
|
||||||
void gdb_create_default_process(GDBState *s) {
|
|
||||||
GDBProcess *process;
|
|
||||||
int pid;
|
|
||||||
|
|
||||||
if (gdbserver_state.process_num) {
|
|
||||||
pid = s->processes[s->process_num - 1].pid;
|
|
||||||
} else {
|
|
||||||
pid = 0;
|
|
||||||
}
|
|
||||||
/* We need an available PID slot for this process */
|
|
||||||
assert(pid < UINT32_MAX);
|
|
||||||
pid++;
|
|
||||||
|
|
||||||
s->processes = g_renew(GDBProcess, s->processes, ++s->process_num);
|
|
||||||
process = &s->processes[s->process_num - 1];
|
|
||||||
process->pid = pid;
|
|
||||||
process->attached = false;
|
|
||||||
process->target_xml = NULL;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,157 +0,0 @@
|
||||||
#ifndef GDBSTUB_H
|
|
||||||
#define GDBSTUB_H
|
|
||||||
|
|
||||||
#include "cpu.h"
|
|
||||||
|
|
||||||
typedef struct GDBFeature {
|
|
||||||
const char *xmlname;
|
|
||||||
const char *xml;
|
|
||||||
const char *name;
|
|
||||||
const char *const *regs;
|
|
||||||
int num_regs;
|
|
||||||
} GDBFeature;
|
|
||||||
|
|
||||||
typedef struct GDBFeatureBuilder {
|
|
||||||
GDBFeature *feature;
|
|
||||||
GPtrArray *xml;
|
|
||||||
GPtrArray *regs;
|
|
||||||
int base_reg;
|
|
||||||
} GDBFeatureBuilder;
|
|
||||||
|
|
||||||
/* Get or set a register. Returns the size of the register. */
|
|
||||||
typedef int (*gdb_get_reg_cb)(CPUState *cpu, GByteArray *buf, int reg);
|
|
||||||
typedef int (*gdb_set_reg_cb)(CPUState *cpu, uint8_t *buf, int reg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_init_cpu(): Initialize the CPU for gdbstub.
|
|
||||||
* @cpu: The CPU to be initialized.
|
|
||||||
*/
|
|
||||||
void gdb_init_cpu(CPUState *cpu);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_register_coprocessor() - register a supplemental set of registers
|
|
||||||
* @cpu - the CPU associated with registers
|
|
||||||
* @get_reg - get function (gdb reading)
|
|
||||||
* @set_reg - set function (gdb modifying)
|
|
||||||
* @num_regs - number of registers in set
|
|
||||||
* @xml - xml name of set
|
|
||||||
* @gpos - non-zero to append to "general" register set at @gpos
|
|
||||||
*/
|
|
||||||
void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, const GDBFeature *feature,
|
|
||||||
int g_pos);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_unregister_coprocessor_all() - unregisters supplemental set of registers
|
|
||||||
* @cpu - the CPU associated with registers
|
|
||||||
*/
|
|
||||||
void gdb_unregister_coprocessor_all(CPUState *cpu);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdbserver_start: start the gdb server
|
|
||||||
* @port_or_device: connection spec for gdb
|
|
||||||
* @errp: error handle
|
|
||||||
*
|
|
||||||
* For CONFIG_USER this is either a tcp port or a path to a fifo. For
|
|
||||||
* system emulation you can use a full chardev spec for your gdbserver
|
|
||||||
* port.
|
|
||||||
*
|
|
||||||
* The error handle should be either &error_fatal (for start-up) or
|
|
||||||
* &error_warn (for QMP/HMP initiated sessions).
|
|
||||||
*
|
|
||||||
* Returns true when server successfully started.
|
|
||||||
*/
|
|
||||||
bool gdbserver_start(const char *port_or_device, Error **errp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_feature_builder_init() - Initialize GDBFeatureBuilder.
|
|
||||||
* @builder: The builder to be initialized.
|
|
||||||
* @feature: The feature to be filled.
|
|
||||||
* @name: The name of the feature.
|
|
||||||
* @xmlname: The name of the XML.
|
|
||||||
* @base_reg: The base number of the register ID.
|
|
||||||
*/
|
|
||||||
void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature, const char *name, const char *xmlname,
|
|
||||||
int base_reg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_feature_builder_append_tag() - Append a tag.
|
|
||||||
* @builder: The builder.
|
|
||||||
* @format: The format of the tag.
|
|
||||||
* @...: The values to be formatted.
|
|
||||||
*/
|
|
||||||
void G_GNUC_PRINTF(2, 3) gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, const char *format, ...);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_feature_builder_append_reg() - Append a register.
|
|
||||||
* @builder: The builder.
|
|
||||||
* @name: The register's name; it must be unique within a CPU.
|
|
||||||
* @bitsize: The register's size, in bits.
|
|
||||||
* @regnum: The offset of the register's number in the feature.
|
|
||||||
* @type: The type of the register.
|
|
||||||
* @group: The register group to which this register belongs; it can be NULL.
|
|
||||||
*/
|
|
||||||
void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder, const char *name, int bitsize, int regnum,
|
|
||||||
const char *type, const char *group);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_feature_builder_end() - End building GDBFeature.
|
|
||||||
* @builder: The builder.
|
|
||||||
*/
|
|
||||||
void gdb_feature_builder_end(const GDBFeatureBuilder *builder);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_find_static_feature() - Find a static feature.
|
|
||||||
* @xmlname: The name of the XML.
|
|
||||||
*
|
|
||||||
* Return: The static feature.
|
|
||||||
*/
|
|
||||||
const GDBFeature *gdb_find_static_feature(const char *xmlname);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_read_register() - Read a register associated with a CPU.
|
|
||||||
* @cpu: The CPU associated with the register.
|
|
||||||
* @buf: The buffer that the read register will be appended to.
|
|
||||||
* @reg: The register's number returned by gdb_find_feature_register().
|
|
||||||
*
|
|
||||||
* Return: The number of read bytes.
|
|
||||||
*/
|
|
||||||
int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_write_register() - Write a register associated with a CPU.
|
|
||||||
* @cpu: The CPU associated with the register.
|
|
||||||
* @buf: The buffer that the register contents will be set to.
|
|
||||||
* @reg: The register's number returned by gdb_find_feature_register().
|
|
||||||
*
|
|
||||||
* The size of @buf must be at least the size of the register being
|
|
||||||
* written.
|
|
||||||
*
|
|
||||||
* Return: The number of written bytes, or 0 if an error occurred (for
|
|
||||||
* example, an unknown register was provided).
|
|
||||||
*/
|
|
||||||
int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* typedef GDBRegDesc - a register description from gdbstub
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
int gdb_reg;
|
|
||||||
const char *name;
|
|
||||||
const char *feature_name;
|
|
||||||
} GDBRegDesc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_get_register_list() - Return list of all registers for CPU
|
|
||||||
* @cpu: The CPU being searched
|
|
||||||
*
|
|
||||||
* Returns a GArray of GDBRegDesc, caller frees array but not the
|
|
||||||
* const strings.
|
|
||||||
*/
|
|
||||||
GArray *gdb_get_register_list(CPUState *cpu);
|
|
||||||
|
|
||||||
void gdb_set_stop_cpu(CPUState *cpu);
|
|
||||||
|
|
||||||
/* in gdbstub-xml.c, generated by scripts/feature_to_c.py */
|
|
||||||
extern const GDBFeature gdb_static_features[];
|
|
||||||
|
|
||||||
#endif /* GDBSTUB_H */
|
|
|
@ -9,35 +9,10 @@
|
||||||
#ifndef GDBSTUB_INTERNALS_H
|
#ifndef GDBSTUB_INTERNALS_H
|
||||||
#define GDBSTUB_INTERNALS_H
|
#define GDBSTUB_INTERNALS_H
|
||||||
|
|
||||||
// #include "exec/cpu-common.h"
|
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* Most "large" transfers (e.g. memory reads, feature XML
|
|
||||||
* transfer) have mechanisms in the gdb protocol for splitting
|
|
||||||
* them. However, register values in particular cannot currently
|
|
||||||
* be split. This packet size must therefore be at least big enough
|
|
||||||
* for the worst-case register size. Currently that is Arm SME
|
|
||||||
* ZA storage with a 256x256 byte value. We also must account
|
|
||||||
* for the conversion from raw data to hex in gdb_memtohex(),
|
|
||||||
* which writes 2 * size bytes, and for other protocol overhead
|
|
||||||
* including command, register number and checksum which add
|
|
||||||
* another 4 bytes of overhead. However, to be consistent with
|
|
||||||
* the changes made in gdbserver to address this same requirement,
|
|
||||||
* we add a total of 32 bytes to account for protocol overhead
|
|
||||||
* (unclear why specifically 32 bytes), bringing the value of
|
|
||||||
* MAX_PACKET_LENGTH to 2 * 256 * 256 + 32 = 131104.
|
|
||||||
*
|
|
||||||
* The commit making this change for gdbserver can be found here:
|
|
||||||
* https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=
|
|
||||||
* b816042e88583f280ad186ff124ab84d31fb592b
|
|
||||||
*/
|
|
||||||
#define MAX_PACKET_LENGTH 131104
|
#define MAX_PACKET_LENGTH 131104
|
||||||
|
|
||||||
/*
|
|
||||||
* Shared structures and definitions
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
GDB_SIGNAL_0 = 0,
|
GDB_SIGNAL_0 = 0,
|
||||||
GDB_SIGNAL_INT = 2,
|
GDB_SIGNAL_INT = 2,
|
||||||
|
@ -67,6 +42,32 @@ enum RSState {
|
||||||
RS_CHKSUM2,
|
RS_CHKSUM2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct GDBFeature {
|
||||||
|
const char *xmlname;
|
||||||
|
const char *xml;
|
||||||
|
const char *name;
|
||||||
|
const char *const *regs;
|
||||||
|
int num_regs;
|
||||||
|
} GDBFeature;
|
||||||
|
|
||||||
|
typedef struct GDBFeatureBuilder {
|
||||||
|
GDBFeature *feature;
|
||||||
|
GPtrArray *xml;
|
||||||
|
GPtrArray *regs;
|
||||||
|
int base_reg;
|
||||||
|
} GDBFeatureBuilder;
|
||||||
|
|
||||||
|
/* Get or set a register. Returns the size of the register. */
|
||||||
|
typedef int (*gdb_get_reg_cb)(CPUState *cpu, GByteArray *buf, int reg);
|
||||||
|
typedef int (*gdb_set_reg_cb)(CPUState *cpu, uint8_t *buf, int reg);
|
||||||
|
|
||||||
|
typedef struct GDBRegisterState {
|
||||||
|
int base_reg;
|
||||||
|
gdb_get_reg_cb get_reg;
|
||||||
|
gdb_set_reg_cb set_reg;
|
||||||
|
const GDBFeature *feature;
|
||||||
|
} GDBRegisterState;
|
||||||
|
|
||||||
typedef struct GDBState {
|
typedef struct GDBState {
|
||||||
bool init; /* have we been initialised? */
|
bool init; /* have we been initialised? */
|
||||||
CPUState *c_cpu; /* current CPU for step/continue ops */
|
CPUState *c_cpu; /* current CPU for step/continue ops */
|
||||||
|
@ -79,7 +80,6 @@ typedef struct GDBState {
|
||||||
int line_csum; /* checksum at the end of the packet */
|
int line_csum; /* checksum at the end of the packet */
|
||||||
GByteArray *last_packet;
|
GByteArray *last_packet;
|
||||||
int signal;
|
int signal;
|
||||||
bool multiprocess;
|
|
||||||
GDBProcess *processes;
|
GDBProcess *processes;
|
||||||
int process_num;
|
int process_num;
|
||||||
GString *str_buf;
|
GString *str_buf;
|
||||||
|
@ -125,71 +125,77 @@ static inline int tohex(int v) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void gdb_put_strbuf(void);
|
void gdb_put_strbuf(void);
|
||||||
int gdb_put_packet_binary(const char *buf, int len, bool dump);
|
void gdb_hextomem(GByteArray *mem, const char *buf, int len);
|
||||||
void gdb_memtohex(GString *buf, const uint8_t *mem, int len);
|
|
||||||
void gdb_memtox(GString *buf, const char *mem, int len);
|
|
||||||
void gdb_read_byte(uint8_t ch);
|
void gdb_read_byte(uint8_t ch);
|
||||||
|
|
||||||
/*
|
void gdb_init_cpu(CPUState *cpu);
|
||||||
* Packet acknowledgement - we handle this slightly differently
|
|
||||||
* between user and system mode, mainly to deal with the differences
|
void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, const GDBFeature *feature,
|
||||||
* between the flexible chardev and the direct fd approaches.
|
int g_pos);
|
||||||
*
|
|
||||||
* We currently don't support a negotiated QStartNoAckMode
|
void gdb_unregister_coprocessor_all(CPUState *cpu);
|
||||||
*/
|
|
||||||
|
bool gdbserver_start(const char *port_or_device, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdb_got_immediate_ack() - check ok to continue
|
* gdb_feature_builder_append_tag() - Append a tag.
|
||||||
*
|
* @builder: The builder.
|
||||||
* Returns true to continue, false to re-transmit for user only, the
|
* @format: The format of the tag.
|
||||||
* system stub always returns true.
|
* @...: The values to be formatted.
|
||||||
*/
|
*/
|
||||||
|
void G_GNUC_PRINTF(2, 3) gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, const char *format, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdb_feature_builder_append_reg() - Append a register.
|
||||||
|
* @builder: The builder.
|
||||||
|
* @name: The register's name; it must be unique within a CPU.
|
||||||
|
* @bitsize: The register's size, in bits.
|
||||||
|
* @regnum: The offset of the register's number in the feature.
|
||||||
|
* @type: The type of the register.
|
||||||
|
* @group: The register group to which this register belongs; it can be NULL.
|
||||||
|
*/
|
||||||
|
void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder, const char *name, int bitsize, int regnum,
|
||||||
|
const char *type, const char *group);
|
||||||
|
|
||||||
|
void gdb_feature_builder_end(const GDBFeatureBuilder *builder);
|
||||||
|
|
||||||
|
const GDBFeature *gdb_find_static_feature(const char *xmlname);
|
||||||
|
|
||||||
|
int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
|
||||||
|
|
||||||
|
int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int gdb_reg;
|
||||||
|
const char *name;
|
||||||
|
const char *feature_name;
|
||||||
|
} GDBRegDesc;
|
||||||
|
|
||||||
|
GArray *gdb_get_register_list(CPUState *cpu);
|
||||||
|
|
||||||
|
/* in gdbstub-xml.c, generated by scripts/feature_to_c.py */
|
||||||
|
extern const GDBFeature gdb_static_features[];
|
||||||
|
|
||||||
|
void gdb_chr_receive(const uint8_t *buf, int size);
|
||||||
bool gdb_got_immediate_ack(void);
|
bool gdb_got_immediate_ack(void);
|
||||||
|
|
||||||
/* utility helpers */
|
/* utility helpers */
|
||||||
GDBProcess *gdb_get_process(uint32_t pid);
|
GDBProcess *gdb_get_process();
|
||||||
CPUState *gdb_get_first_cpu_in_process(GDBProcess *process);
|
|
||||||
CPUState *gdb_first_attached_cpu(void);
|
|
||||||
void gdb_append_thread_id(CPUState *cpu, GString *buf);
|
void gdb_append_thread_id(CPUState *cpu, GString *buf);
|
||||||
int gdb_get_cpu_index(CPUState *cpu);
|
int gdb_get_cpu_index(CPUState *cpu);
|
||||||
unsigned int gdb_get_max_cpus(void); /* both */
|
unsigned int gdb_get_max_cpus(void); /* both */
|
||||||
bool gdb_can_reverse(void); /* system emulation, stub for user */
|
|
||||||
// int gdb_target_sigtrap(void); /* user */
|
|
||||||
|
|
||||||
void gdb_create_default_process(GDBState *s);
|
void gdb_create_default_process(GDBState *s);
|
||||||
|
|
||||||
/* signal mapping, common for system, specialised for user-mode */
|
|
||||||
int gdb_signal_to_target(int sig);
|
int gdb_signal_to_target(int sig);
|
||||||
// int gdb_target_signal_to_gdb(int sig);
|
|
||||||
|
|
||||||
int gdb_get_char(void); /* user only */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_continue() - handle continue in mode specific way.
|
|
||||||
*/
|
|
||||||
void gdb_continue(void);
|
void gdb_continue(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_continue_partial() - handle partial continue in mode specific way.
|
|
||||||
*/
|
|
||||||
int gdb_continue_partial(char *newstates);
|
int gdb_continue_partial(char *newstates);
|
||||||
|
|
||||||
/*
|
|
||||||
* Command handlers - either specialised or system or user only
|
|
||||||
*/
|
|
||||||
void gdb_init_gdbserver_state(void);
|
void gdb_init_gdbserver_state(void);
|
||||||
|
|
||||||
void gdb_handle_query_rcmd(GArray *params, void *ctx); /* system */
|
void gdb_handle_query_rcmd(GArray *params, void *ctx); /* system */
|
||||||
// void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */
|
|
||||||
// void gdb_handle_query_xfer_siginfo(GArray *params, void *user_ctx); /*user */
|
|
||||||
// void gdb_handle_v_file_open(GArray *params, void *user_ctx); /* user */
|
|
||||||
// void gdb_handle_v_file_close(GArray *params, void *user_ctx); /* user */
|
|
||||||
// void gdb_handle_v_file_pread(GArray *params, void *user_ctx); /* user */
|
|
||||||
// void gdb_handle_v_file_readlink(GArray *params, void *user_ctx); /* user */
|
|
||||||
// void gdb_handle_query_xfer_exec_file(GArray *params, void *user_ctx); /* user */
|
|
||||||
// void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx); /* user */
|
|
||||||
// void gdb_handle_query_supported_user(const char *gdb_supported); /* user */
|
|
||||||
// bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid); /* user */
|
|
||||||
// bool gdb_handle_detach_user(uint32_t pid); /* user */
|
|
||||||
|
|
||||||
void gdb_handle_query_attached(GArray *params, void *ctx); /* both */
|
void gdb_handle_query_attached(GArray *params, void *ctx); /* both */
|
||||||
|
|
||||||
|
@ -201,11 +207,6 @@ void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *ctx);
|
||||||
void gdb_handle_file_io(GArray *params, void *user_ctx);
|
void gdb_handle_file_io(GArray *params, void *user_ctx);
|
||||||
void gdb_disable_syscalls(void);
|
void gdb_disable_syscalls(void);
|
||||||
|
|
||||||
/*
|
|
||||||
* Break/Watch point support - there is an implementation for system
|
|
||||||
* and user mode.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
bool runstate_is_running();
|
bool runstate_is_running();
|
||||||
void vm_stop(RunState rs);
|
void vm_stop(RunState rs);
|
||||||
|
@ -232,20 +233,23 @@ void vm_start();
|
||||||
bool vm_prepare_start(bool step_requested);
|
bool vm_prepare_start(bool step_requested);
|
||||||
void qemu_clock_enable();
|
void qemu_clock_enable();
|
||||||
|
|
||||||
|
uint32_t gdb_get_cpu_pid(CPUState *cpu);
|
||||||
|
|
||||||
#define CPU_FOREACH(cpu) for (auto c = get_cpu(); false;)
|
#define CPU_FOREACH(cpu) for (auto c = get_cpu(); false;)
|
||||||
|
|
||||||
/**
|
|
||||||
* gdb_target_memory_rw_debug() - handle debug access to memory
|
|
||||||
* @cs: CPUState
|
|
||||||
* @addr: nominal address, could be an entire physical address
|
|
||||||
* @buf: data
|
|
||||||
* @len: length of access
|
|
||||||
* @is_write: is it a write operation
|
|
||||||
*
|
|
||||||
* This function is specialised depending on the mode we are running
|
|
||||||
* in. For system guests we can switch the interpretation of the
|
|
||||||
* address to a physical address.
|
|
||||||
*/
|
|
||||||
int gdb_target_memory_rw_debug(CPUState *cs, hwaddr addr, uint8_t *buf, int len, bool is_write);
|
int gdb_target_memory_rw_debug(CPUState *cs, hwaddr addr, uint8_t *buf, int len, bool is_write);
|
||||||
|
|
||||||
|
CPUState *find_cpu(uint32_t thread_id);
|
||||||
|
CPUState *gdb_next_cpu_in_process(CPUState *cpu);
|
||||||
|
CPUState *gdb_next_attached_cpu(CPUState *cpu);
|
||||||
|
CPUState *gdb_first_attached_cpu(void);
|
||||||
|
CPUState *gdb_get_cpu();
|
||||||
|
const char *get_feature_xml(const char *p, const char **newp, GDBProcess *process);
|
||||||
|
|
||||||
|
void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, const GDBFeature *feature,
|
||||||
|
int g_pos);
|
||||||
|
|
||||||
|
void gdb_unregister_coprocessor_all(CPUState *cpu);
|
||||||
|
const char *gdb_get_core_xml_file(CPUState *cpu);
|
||||||
|
|
||||||
#endif /* GDBSTUB_INTERNALS_H */
|
#endif /* GDBSTUB_INTERNALS_H */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "gdbstub.h"
|
#include "internals.h"
|
||||||
|
|
||||||
const GDBFeature gdb_static_features[] = {
|
const GDBFeature gdb_static_features[] = {
|
||||||
{
|
{
|
||||||
|
@ -47,73 +47,12 @@ const GDBFeature gdb_static_features[] = {
|
||||||
" <reg name=\"pc\" bitsize=\"64\" type=\"code_ptr\"/>\n"
|
" <reg name=\"pc\" bitsize=\"64\" type=\"code_ptr\"/>\n"
|
||||||
"</feature>\n",
|
"</feature>\n",
|
||||||
"org.gnu.gdb.riscv.cpu",
|
"org.gnu.gdb.riscv.cpu",
|
||||||
(const char * const []) {
|
(const char* const[]){
|
||||||
[0] =
|
[0] = "zero", [1] = "ra", [2] = "sp", [3] = "gp", [4] = "tp", [5] = "t0", [6] = "t1",
|
||||||
"zero",
|
[7] = "t2", [8] = "fp", [9] = "s1", [10] = "a0", [11] = "a1", [12] = "a2", [13] = "a3",
|
||||||
[1] =
|
[14] = "a4", [15] = "a5", [16] = "a6", [17] = "a7", [18] = "s2", [19] = "s3", [20] = "s4",
|
||||||
"ra",
|
[21] = "s5", [22] = "s6", [23] = "s7", [24] = "s8", [25] = "s9", [26] = "s10", [27] = "s11",
|
||||||
[2] =
|
[28] = "t3", [29] = "t4", [30] = "t5", [31] = "t6", [32] = "pc",
|
||||||
"sp",
|
|
||||||
[3] =
|
|
||||||
"gp",
|
|
||||||
[4] =
|
|
||||||
"tp",
|
|
||||||
[5] =
|
|
||||||
"t0",
|
|
||||||
[6] =
|
|
||||||
"t1",
|
|
||||||
[7] =
|
|
||||||
"t2",
|
|
||||||
[8] =
|
|
||||||
"fp",
|
|
||||||
[9] =
|
|
||||||
"s1",
|
|
||||||
[10] =
|
|
||||||
"a0",
|
|
||||||
[11] =
|
|
||||||
"a1",
|
|
||||||
[12] =
|
|
||||||
"a2",
|
|
||||||
[13] =
|
|
||||||
"a3",
|
|
||||||
[14] =
|
|
||||||
"a4",
|
|
||||||
[15] =
|
|
||||||
"a5",
|
|
||||||
[16] =
|
|
||||||
"a6",
|
|
||||||
[17] =
|
|
||||||
"a7",
|
|
||||||
[18] =
|
|
||||||
"s2",
|
|
||||||
[19] =
|
|
||||||
"s3",
|
|
||||||
[20] =
|
|
||||||
"s4",
|
|
||||||
[21] =
|
|
||||||
"s5",
|
|
||||||
[22] =
|
|
||||||
"s6",
|
|
||||||
[23] =
|
|
||||||
"s7",
|
|
||||||
[24] =
|
|
||||||
"s8",
|
|
||||||
[25] =
|
|
||||||
"s9",
|
|
||||||
[26] =
|
|
||||||
"s10",
|
|
||||||
[27] =
|
|
||||||
"s11",
|
|
||||||
[28] =
|
|
||||||
"t3",
|
|
||||||
[29] =
|
|
||||||
"t4",
|
|
||||||
[30] =
|
|
||||||
"t5",
|
|
||||||
[31] =
|
|
||||||
"t6",
|
|
||||||
[32] =
|
|
||||||
"pc",
|
|
||||||
},
|
},
|
||||||
33,
|
33,
|
||||||
},
|
},
|
||||||
|
@ -162,71 +101,12 @@ const GDBFeature gdb_static_features[] = {
|
||||||
" <reg name=\"ft11\" bitsize=\"32\" type=\"ieee_single\"/>\n"
|
" <reg name=\"ft11\" bitsize=\"32\" type=\"ieee_single\"/>\n"
|
||||||
"</feature>\n",
|
"</feature>\n",
|
||||||
"org.gnu.gdb.riscv.fpu",
|
"org.gnu.gdb.riscv.fpu",
|
||||||
(const char * const []) {
|
(const char* const[]){
|
||||||
[0] =
|
[0] = "ft0", [1] = "ft1", [2] = "ft2", [3] = "ft3", [4] = "ft4", [5] = "ft5", [6] = "ft6",
|
||||||
"ft0",
|
[7] = "ft7", [8] = "fs0", [9] = "fs1", [10] = "fa0", [11] = "fa1", [12] = "fa2", [13] = "fa3",
|
||||||
[1] =
|
[14] = "fa4", [15] = "fa5", [16] = "fa6", [17] = "fa7", [18] = "fs2", [19] = "fs3", [20] = "fs4",
|
||||||
"ft1",
|
[21] = "fs5", [22] = "fs6", [23] = "fs7", [24] = "fs8", [25] = "fs9", [26] = "fs10", [27] = "fs11",
|
||||||
[2] =
|
[28] = "ft8", [29] = "ft9", [30] = "ft10", [31] = "ft11",
|
||||||
"ft2",
|
|
||||||
[3] =
|
|
||||||
"ft3",
|
|
||||||
[4] =
|
|
||||||
"ft4",
|
|
||||||
[5] =
|
|
||||||
"ft5",
|
|
||||||
[6] =
|
|
||||||
"ft6",
|
|
||||||
[7] =
|
|
||||||
"ft7",
|
|
||||||
[8] =
|
|
||||||
"fs0",
|
|
||||||
[9] =
|
|
||||||
"fs1",
|
|
||||||
[10] =
|
|
||||||
"fa0",
|
|
||||||
[11] =
|
|
||||||
"fa1",
|
|
||||||
[12] =
|
|
||||||
"fa2",
|
|
||||||
[13] =
|
|
||||||
"fa3",
|
|
||||||
[14] =
|
|
||||||
"fa4",
|
|
||||||
[15] =
|
|
||||||
"fa5",
|
|
||||||
[16] =
|
|
||||||
"fa6",
|
|
||||||
[17] =
|
|
||||||
"fa7",
|
|
||||||
[18] =
|
|
||||||
"fs2",
|
|
||||||
[19] =
|
|
||||||
"fs3",
|
|
||||||
[20] =
|
|
||||||
"fs4",
|
|
||||||
[21] =
|
|
||||||
"fs5",
|
|
||||||
[22] =
|
|
||||||
"fs6",
|
|
||||||
[23] =
|
|
||||||
"fs7",
|
|
||||||
[24] =
|
|
||||||
"fs8",
|
|
||||||
[25] =
|
|
||||||
"fs9",
|
|
||||||
[26] =
|
|
||||||
"fs10",
|
|
||||||
[27] =
|
|
||||||
"fs11",
|
|
||||||
[28] =
|
|
||||||
"ft8",
|
|
||||||
[29] =
|
|
||||||
"ft9",
|
|
||||||
[30] =
|
|
||||||
"ft10",
|
|
||||||
[31] =
|
|
||||||
"ft11",
|
|
||||||
},
|
},
|
||||||
32,
|
32,
|
||||||
},
|
},
|
||||||
|
@ -281,71 +161,12 @@ const GDBFeature gdb_static_features[] = {
|
||||||
" <reg name=\"ft11\" bitsize=\"64\" type=\"riscv_double\"/>\n"
|
" <reg name=\"ft11\" bitsize=\"64\" type=\"riscv_double\"/>\n"
|
||||||
"</feature>\n",
|
"</feature>\n",
|
||||||
"org.gnu.gdb.riscv.fpu",
|
"org.gnu.gdb.riscv.fpu",
|
||||||
(const char * const []) {
|
(const char* const[]){
|
||||||
[0] =
|
[0] = "ft0", [1] = "ft1", [2] = "ft2", [3] = "ft3", [4] = "ft4", [5] = "ft5", [6] = "ft6",
|
||||||
"ft0",
|
[7] = "ft7", [8] = "fs0", [9] = "fs1", [10] = "fa0", [11] = "fa1", [12] = "fa2", [13] = "fa3",
|
||||||
[1] =
|
[14] = "fa4", [15] = "fa5", [16] = "fa6", [17] = "fa7", [18] = "fs2", [19] = "fs3", [20] = "fs4",
|
||||||
"ft1",
|
[21] = "fs5", [22] = "fs6", [23] = "fs7", [24] = "fs8", [25] = "fs9", [26] = "fs10", [27] = "fs11",
|
||||||
[2] =
|
[28] = "ft8", [29] = "ft9", [30] = "ft10", [31] = "ft11",
|
||||||
"ft2",
|
|
||||||
[3] =
|
|
||||||
"ft3",
|
|
||||||
[4] =
|
|
||||||
"ft4",
|
|
||||||
[5] =
|
|
||||||
"ft5",
|
|
||||||
[6] =
|
|
||||||
"ft6",
|
|
||||||
[7] =
|
|
||||||
"ft7",
|
|
||||||
[8] =
|
|
||||||
"fs0",
|
|
||||||
[9] =
|
|
||||||
"fs1",
|
|
||||||
[10] =
|
|
||||||
"fa0",
|
|
||||||
[11] =
|
|
||||||
"fa1",
|
|
||||||
[12] =
|
|
||||||
"fa2",
|
|
||||||
[13] =
|
|
||||||
"fa3",
|
|
||||||
[14] =
|
|
||||||
"fa4",
|
|
||||||
[15] =
|
|
||||||
"fa5",
|
|
||||||
[16] =
|
|
||||||
"fa6",
|
|
||||||
[17] =
|
|
||||||
"fa7",
|
|
||||||
[18] =
|
|
||||||
"fs2",
|
|
||||||
[19] =
|
|
||||||
"fs3",
|
|
||||||
[20] =
|
|
||||||
"fs4",
|
|
||||||
[21] =
|
|
||||||
"fs5",
|
|
||||||
[22] =
|
|
||||||
"fs6",
|
|
||||||
[23] =
|
|
||||||
"fs7",
|
|
||||||
[24] =
|
|
||||||
"fs8",
|
|
||||||
[25] =
|
|
||||||
"fs9",
|
|
||||||
[26] =
|
|
||||||
"fs10",
|
|
||||||
[27] =
|
|
||||||
"fs11",
|
|
||||||
[28] =
|
|
||||||
"ft8",
|
|
||||||
[29] =
|
|
||||||
"ft9",
|
|
||||||
[30] =
|
|
||||||
"ft10",
|
|
||||||
[31] =
|
|
||||||
"ft11",
|
|
||||||
},
|
},
|
||||||
32,
|
32,
|
||||||
},
|
},
|
||||||
|
@ -363,9 +184,8 @@ const GDBFeature gdb_static_features[] = {
|
||||||
" <reg name=\"priv\" bitsize=\"64\"/>\n"
|
" <reg name=\"priv\" bitsize=\"64\"/>\n"
|
||||||
"</feature>\n",
|
"</feature>\n",
|
||||||
"org.gnu.gdb.riscv.virtual",
|
"org.gnu.gdb.riscv.virtual",
|
||||||
(const char * const []) {
|
(const char* const[]){
|
||||||
[0] =
|
[0] = "priv",
|
||||||
"priv",
|
|
||||||
},
|
},
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
|
@ -415,73 +235,12 @@ const GDBFeature gdb_static_features[] = {
|
||||||
" <reg name=\"pc\" bitsize=\"32\" type=\"code_ptr\"/>\n"
|
" <reg name=\"pc\" bitsize=\"32\" type=\"code_ptr\"/>\n"
|
||||||
"</feature>\n",
|
"</feature>\n",
|
||||||
"org.gnu.gdb.riscv.cpu",
|
"org.gnu.gdb.riscv.cpu",
|
||||||
(const char * const []) {
|
(const char* const[]){
|
||||||
[0] =
|
[0] = "zero", [1] = "ra", [2] = "sp", [3] = "gp", [4] = "tp", [5] = "t0", [6] = "t1",
|
||||||
"zero",
|
[7] = "t2", [8] = "fp", [9] = "s1", [10] = "a0", [11] = "a1", [12] = "a2", [13] = "a3",
|
||||||
[1] =
|
[14] = "a4", [15] = "a5", [16] = "a6", [17] = "a7", [18] = "s2", [19] = "s3", [20] = "s4",
|
||||||
"ra",
|
[21] = "s5", [22] = "s6", [23] = "s7", [24] = "s8", [25] = "s9", [26] = "s10", [27] = "s11",
|
||||||
[2] =
|
[28] = "t3", [29] = "t4", [30] = "t5", [31] = "t6", [32] = "pc",
|
||||||
"sp",
|
|
||||||
[3] =
|
|
||||||
"gp",
|
|
||||||
[4] =
|
|
||||||
"tp",
|
|
||||||
[5] =
|
|
||||||
"t0",
|
|
||||||
[6] =
|
|
||||||
"t1",
|
|
||||||
[7] =
|
|
||||||
"t2",
|
|
||||||
[8] =
|
|
||||||
"fp",
|
|
||||||
[9] =
|
|
||||||
"s1",
|
|
||||||
[10] =
|
|
||||||
"a0",
|
|
||||||
[11] =
|
|
||||||
"a1",
|
|
||||||
[12] =
|
|
||||||
"a2",
|
|
||||||
[13] =
|
|
||||||
"a3",
|
|
||||||
[14] =
|
|
||||||
"a4",
|
|
||||||
[15] =
|
|
||||||
"a5",
|
|
||||||
[16] =
|
|
||||||
"a6",
|
|
||||||
[17] =
|
|
||||||
"a7",
|
|
||||||
[18] =
|
|
||||||
"s2",
|
|
||||||
[19] =
|
|
||||||
"s3",
|
|
||||||
[20] =
|
|
||||||
"s4",
|
|
||||||
[21] =
|
|
||||||
"s5",
|
|
||||||
[22] =
|
|
||||||
"s6",
|
|
||||||
[23] =
|
|
||||||
"s7",
|
|
||||||
[24] =
|
|
||||||
"s8",
|
|
||||||
[25] =
|
|
||||||
"s9",
|
|
||||||
[26] =
|
|
||||||
"s10",
|
|
||||||
[27] =
|
|
||||||
"s11",
|
|
||||||
[28] =
|
|
||||||
"t3",
|
|
||||||
[29] =
|
|
||||||
"t4",
|
|
||||||
[30] =
|
|
||||||
"t5",
|
|
||||||
[31] =
|
|
||||||
"t6",
|
|
||||||
[32] =
|
|
||||||
"pc",
|
|
||||||
},
|
},
|
||||||
33,
|
33,
|
||||||
},
|
},
|
||||||
|
@ -499,11 +258,9 @@ const GDBFeature gdb_static_features[] = {
|
||||||
" <reg name=\"priv\" bitsize=\"32\"/>\n"
|
" <reg name=\"priv\" bitsize=\"32\"/>\n"
|
||||||
"</feature>\n",
|
"</feature>\n",
|
||||||
"org.gnu.gdb.riscv.virtual",
|
"org.gnu.gdb.riscv.virtual",
|
||||||
(const char * const []) {
|
(const char* const[]){
|
||||||
[0] =
|
[0] = "priv",
|
||||||
"priv",
|
|
||||||
},
|
},
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
{ NULL }
|
{NULL}};
|
||||||
};
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "conn.h"
|
#include "conn.h"
|
||||||
#include "gdbstub.h"
|
#include "internals.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
conn_t conn;
|
conn_t conn;
|
||||||
|
|
602
gdbstub/system.c
602
gdbstub/system.c
|
@ -10,6 +10,8 @@
|
||||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "enums.h"
|
#include "enums.h"
|
||||||
|
@ -22,348 +24,16 @@ static void reset_gdbserver_state(void) {
|
||||||
gdbserver_state.allow_stop_reply = false;
|
gdbserver_state.allow_stop_reply = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the GDB index for a given vCPU state.
|
|
||||||
*
|
|
||||||
* In system mode GDB numbers CPUs from 1 as 0 is reserved as an "any
|
|
||||||
* cpu" index.
|
|
||||||
*/
|
|
||||||
int gdb_get_cpu_index(CPUState *cpu) { return 0; }
|
int gdb_get_cpu_index(CPUState *cpu) { return 0; }
|
||||||
|
|
||||||
/*
|
|
||||||
* We check the status of the last message in the chardev receive code
|
|
||||||
*/
|
|
||||||
bool gdb_got_immediate_ack(void) { return true; }
|
bool gdb_got_immediate_ack(void) { return true; }
|
||||||
|
|
||||||
/*
|
void gdb_chr_receive(const uint8_t *buf, int size) {
|
||||||
* GDB Connection management. For system emulation we do all of this
|
for (int i = 0; i < size; i++) {
|
||||||
* via our existing Chardev infrastructure which allows us to support
|
|
||||||
* network and unix sockets.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// static void gdb_chr_event(void *opaque, QEMUChrEvent event) {
|
|
||||||
// int i;
|
|
||||||
// GDBState *s = (GDBState *)opaque;
|
|
||||||
|
|
||||||
// switch (event) {
|
|
||||||
// case CHR_EVENT_OPENED:
|
|
||||||
// /* Start with first process attached, others detached */
|
|
||||||
// for (i = 0; i < s->process_num; i++) {
|
|
||||||
// s->processes[i].attached = !i;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// s->c_cpu = gdb_first_attached_cpu();
|
|
||||||
// s->g_cpu = s->c_cpu;
|
|
||||||
|
|
||||||
// vm_stop(RUN_STATE_PAUSED);
|
|
||||||
// replay_gdb_attached();
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * In system-mode we stop the VM and wait to send the syscall packet
|
|
||||||
// * until notification that the CPU has stopped. This must be done
|
|
||||||
// * because if the packet is sent now the reply from the syscall
|
|
||||||
// * request could be received while the CPU is still in the running
|
|
||||||
// * state, which can cause packets to be dropped and state transition
|
|
||||||
// * 'T' packets to be sent while the syscall is still being processed.
|
|
||||||
// */
|
|
||||||
// void gdb_syscall_handling(const char *syscall_packet) {
|
|
||||||
// vm_stop(RUN_STATE_DEBUG);
|
|
||||||
// qemu_cpu_kick(gdbserver_state.c_cpu);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static void gdb_vm_state_change(void *opaque, bool running, RunState state) {
|
|
||||||
// CPUState *cpu = gdbserver_state.c_cpu;
|
|
||||||
// g_autoptr(GString) buf = g_string_new(NULL);
|
|
||||||
// g_autoptr(GString) tid = g_string_new(NULL);
|
|
||||||
// const char *type;
|
|
||||||
// int ret;
|
|
||||||
|
|
||||||
// if (running || gdbserver_state.state == RS_INACTIVE) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /* Is there a GDB syscall waiting to be sent? */
|
|
||||||
// if (gdb_handled_syscall()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (cpu == NULL) {
|
|
||||||
// /* No process attached */
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!gdbserver_state.allow_stop_reply) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// gdb_append_thread_id(cpu, tid);
|
|
||||||
|
|
||||||
// switch (state) {
|
|
||||||
// case RUN_STATE_DEBUG:
|
|
||||||
// if (cpu->watchpoint_hit) {
|
|
||||||
// switch (cpu->watchpoint_hit->flags & BP_MEM_ACCESS) {
|
|
||||||
// case BP_MEM_READ:
|
|
||||||
// type = "r";
|
|
||||||
// break;
|
|
||||||
// case BP_MEM_ACCESS:
|
|
||||||
// type = "a";
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// type = "";
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// trace_gdbstub_hit_watchpoint(type, gdb_get_cpu_index(cpu), cpu->watchpoint_hit->vaddr);
|
|
||||||
// g_string_printf(buf, "T%02xthread:%s;%swatch:%" VADDR_PRIx ";", GDB_SIGNAL_TRAP, tid->str, type,
|
|
||||||
// cpu->watchpoint_hit->vaddr);
|
|
||||||
// cpu->watchpoint_hit = NULL;
|
|
||||||
// goto send_packet;
|
|
||||||
// } else {
|
|
||||||
// trace_gdbstub_hit_break();
|
|
||||||
// }
|
|
||||||
// if (tcg_enabled()) {
|
|
||||||
// tb_flush(cpu);
|
|
||||||
// }
|
|
||||||
// ret = GDB_SIGNAL_TRAP;
|
|
||||||
// break;
|
|
||||||
// case RUN_STATE_PAUSED:
|
|
||||||
// trace_gdbstub_hit_paused();
|
|
||||||
// ret = GDB_SIGNAL_INT;
|
|
||||||
// break;
|
|
||||||
// case RUN_STATE_SHUTDOWN:
|
|
||||||
// trace_gdbstub_hit_shutdown();
|
|
||||||
// ret = GDB_SIGNAL_QUIT;
|
|
||||||
// break;
|
|
||||||
// case RUN_STATE_IO_ERROR:
|
|
||||||
// trace_gdbstub_hit_io_error();
|
|
||||||
// ret = GDB_SIGNAL_STOP;
|
|
||||||
// break;
|
|
||||||
// case RUN_STATE_WATCHDOG:
|
|
||||||
// trace_gdbstub_hit_watchdog();
|
|
||||||
// ret = GDB_SIGNAL_ALRM;
|
|
||||||
// break;
|
|
||||||
// case RUN_STATE_INTERNAL_ERROR:
|
|
||||||
// trace_gdbstub_hit_internal_error();
|
|
||||||
// ret = GDB_SIGNAL_ABRT;
|
|
||||||
// break;
|
|
||||||
// case RUN_STATE_SAVE_VM:
|
|
||||||
// case RUN_STATE_RESTORE_VM:
|
|
||||||
// return;
|
|
||||||
// case RUN_STATE_FINISH_MIGRATE:
|
|
||||||
// ret = GDB_SIGNAL_XCPU;
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// trace_gdbstub_hit_unknown(state);
|
|
||||||
// ret = GDB_SIGNAL_UNKNOWN;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// gdb_set_stop_cpu(cpu);
|
|
||||||
// g_string_printf(buf, "T%02xthread:%s;", ret, tid->str);
|
|
||||||
|
|
||||||
// send_packet:
|
|
||||||
// gdb_put_packet(buf->str);
|
|
||||||
// gdbserver_state.allow_stop_reply = false;
|
|
||||||
|
|
||||||
// /* disable single step if it was enabled */
|
|
||||||
// cpu_single_step(cpu, 0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) {
|
|
||||||
// g_autoptr(GString) hex_buf = g_string_new("O");
|
|
||||||
// gdb_memtohex(hex_buf, buf, len);
|
|
||||||
// gdb_put_packet(hex_buf->str);
|
|
||||||
// return len;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static void gdb_monitor_open(Chardev *chr, ChardevBackend *backend, bool *be_opened, Error **errp) {
|
|
||||||
// *be_opened = false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static void char_gdb_class_init(ObjectClass *oc, const void *data) {
|
|
||||||
// ChardevClass *cc = CHARDEV_CLASS(oc);
|
|
||||||
|
|
||||||
// cc->internal = true;
|
|
||||||
// cc->open = gdb_monitor_open;
|
|
||||||
// cc->chr_write = gdb_monitor_write;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #define TYPE_CHARDEV_GDB "chardev-gdb"
|
|
||||||
|
|
||||||
// static const TypeInfo char_gdb_type_info = {
|
|
||||||
// .name = TYPE_CHARDEV_GDB,
|
|
||||||
// .parent = TYPE_CHARDEV,
|
|
||||||
// .class_init = char_gdb_class_init,
|
|
||||||
// };
|
|
||||||
|
|
||||||
static int gdb_chr_can_receive(void *opaque) {
|
|
||||||
/*
|
|
||||||
* We can handle an arbitrarily large amount of data.
|
|
||||||
* Pick the maximum packet size, which is as good as anything.
|
|
||||||
*/
|
|
||||||
return MAX_PACKET_LENGTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
|
||||||
gdb_read_byte(buf[i]);
|
gdb_read_byte(buf[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static int find_cpu_clusters(Object *child, void *opaque) {
|
|
||||||
// if (object_dynamic_cast(child, TYPE_CPU_CLUSTER)) {
|
|
||||||
// GDBState *s = (GDBState *)opaque;
|
|
||||||
// CPUClusterState *cluster = CPU_CLUSTER(child);
|
|
||||||
// GDBProcess *process;
|
|
||||||
|
|
||||||
// s->processes = g_renew(GDBProcess, s->processes, ++s->process_num);
|
|
||||||
|
|
||||||
// process = &s->processes[s->process_num - 1];
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * GDB process IDs -1 and 0 are reserved. To avoid subtle errors at
|
|
||||||
// * runtime, we enforce here that the machine does not use a cluster ID
|
|
||||||
// * that would lead to PID 0.
|
|
||||||
// */
|
|
||||||
// assert(cluster->cluster_id != UINT32_MAX);
|
|
||||||
// process->pid = cluster->cluster_id + 1;
|
|
||||||
// process->attached = false;
|
|
||||||
// process->target_xml = NULL;
|
|
||||||
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return object_child_foreach(child, find_cpu_clusters, opaque);
|
|
||||||
// }
|
|
||||||
|
|
||||||
static int pid_order(const void *a, const void *b) {
|
|
||||||
GDBProcess *pa = (GDBProcess *)a;
|
|
||||||
GDBProcess *pb = (GDBProcess *)b;
|
|
||||||
|
|
||||||
if (pa->pid < pb->pid) {
|
|
||||||
return -1;
|
|
||||||
} else if (pa->pid > pb->pid) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// static void create_processes(GDBState *s) {
|
|
||||||
// object_child_foreach(object_get_root(), find_cpu_clusters, s);
|
|
||||||
|
|
||||||
// if (gdbserver_state.processes) {
|
|
||||||
// /* Sort by PID */
|
|
||||||
// qsort(gdbserver_state.processes, gdbserver_state.process_num, sizeof(gdbserver_state.processes[0]), pid_order);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// gdb_create_default_process(s);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// bool gdbserver_start(const char *device, Error **errp) {
|
|
||||||
// Chardev *chr = NULL;
|
|
||||||
// Chardev *mon_chr;
|
|
||||||
// g_autoptr(GString) cs = g_string_new(device);
|
|
||||||
|
|
||||||
// if (!get_cpu()) {
|
|
||||||
// error_setg(errp,
|
|
||||||
// "gdbstub: meaningless to attach gdb to a "
|
|
||||||
// "machine without any CPU.");
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!gdb_supports_guest_debug()) {
|
|
||||||
// error_setg(errp,
|
|
||||||
// "gdbstub: current accelerator doesn't "
|
|
||||||
// "support guest debugging");
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (cs->len == 0) {
|
|
||||||
// error_setg(errp, "gdbstub: missing connection string");
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// trace_gdbstub_op_start(cs->str);
|
|
||||||
|
|
||||||
// if (g_strcmp0(cs->str, "none") != 0) {
|
|
||||||
// if (g_str_has_prefix(cs->str, "tcp:")) {
|
|
||||||
// /* enforce required TCP attributes */
|
|
||||||
// g_string_append_printf(cs, ",wait=off,nodelay=on,server=on");
|
|
||||||
// }
|
|
||||||
// /*
|
|
||||||
// * FIXME: it's a bit weird to allow using a mux chardev here
|
|
||||||
// * and implicitly setup a monitor. We may want to break this.
|
|
||||||
// */
|
|
||||||
// chr = qemu_chr_new_noreplay("gdb", cs->str, true, NULL);
|
|
||||||
// if (!chr) {
|
|
||||||
// error_setg(errp, "gdbstub: couldn't create chardev");
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!gdbserver_state.init) {
|
|
||||||
// gdb_init_gdbserver_state();
|
|
||||||
|
|
||||||
// qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
|
|
||||||
|
|
||||||
// /* Initialize a monitor terminal for gdb */
|
|
||||||
// mon_chr = qemu_chardev_new(NULL, TYPE_CHARDEV_GDB, NULL, NULL, &error_abort);
|
|
||||||
// monitor_init_hmp(mon_chr, false, &error_abort);
|
|
||||||
// } else {
|
|
||||||
// qemu_chr_fe_deinit(&gdbserver_system_state.chr, true);
|
|
||||||
// mon_chr = gdbserver_system_state.mon_chr;
|
|
||||||
// reset_gdbserver_state();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// create_processes(&gdbserver_state);
|
|
||||||
|
|
||||||
// if (chr) {
|
|
||||||
// qemu_chr_fe_init(&gdbserver_system_state.chr, chr, &error_abort);
|
|
||||||
// qemu_chr_fe_set_handlers(&gdbserver_system_state.chr, gdb_chr_can_receive, gdb_chr_receive, gdb_chr_event, NULL,
|
|
||||||
// &gdbserver_state, NULL, true);
|
|
||||||
// }
|
|
||||||
// gdbserver_state.state = chr ? RS_IDLE : RS_INACTIVE;
|
|
||||||
// gdbserver_system_state.mon_chr = mon_chr;
|
|
||||||
// gdb_syscall_reset();
|
|
||||||
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static void register_types(void) { type_register_static(&char_gdb_type_info); }
|
|
||||||
|
|
||||||
// type_init(register_types);
|
|
||||||
|
|
||||||
/* Tell the remote gdb that the process has exited. */
|
|
||||||
// void gdb_exit(int code) {
|
|
||||||
// char buf[4];
|
|
||||||
|
|
||||||
// if (!gdbserver_state.init) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// trace_gdbstub_op_exiting((uint8_t)code);
|
|
||||||
|
|
||||||
// if (gdbserver_state.allow_stop_reply) {
|
|
||||||
// snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code);
|
|
||||||
// gdb_put_packet(buf);
|
|
||||||
// gdbserver_state.allow_stop_reply = false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// qemu_chr_fe_deinit(&gdbserver_system_state.chr, true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void gdb_qemu_exit(int code) { qemu_system_shutdown_request_with_code(SHUTDOWN_CAUSE_GUEST_SHUTDOWN, code); }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Memory access
|
|
||||||
*/
|
|
||||||
|
|
||||||
int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, uint8_t *buf, int len, bool is_write) {
|
int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, uint8_t *buf, int len, bool is_write) {
|
||||||
if (is_write) {
|
if (is_write) {
|
||||||
cpu_physical_memory_write(addr, buf, len);
|
cpu_physical_memory_write(addr, buf, len);
|
||||||
|
@ -373,18 +43,8 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, uint8_t *buf, int len
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* cpu helpers
|
|
||||||
*/
|
|
||||||
|
|
||||||
unsigned int gdb_get_max_cpus(void) { return 1; }
|
unsigned int gdb_get_max_cpus(void) { return 1; }
|
||||||
|
|
||||||
bool gdb_can_reverse(void) { return false; }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Softmmu specific command helpers
|
|
||||||
*/
|
|
||||||
|
|
||||||
void gdb_handle_query_qemu_phy_mem_mode(GArray *params, void *ctx) {
|
void gdb_handle_query_qemu_phy_mem_mode(GArray *params, void *ctx) {
|
||||||
g_string_printf(gdbserver_state.str_buf, "%d", 1);
|
g_string_printf(gdbserver_state.str_buf, "%d", 1);
|
||||||
gdb_put_strbuf();
|
gdb_put_strbuf();
|
||||||
|
@ -424,22 +84,14 @@ void gdb_handle_query_rcmd(GArray *params, void *ctx) {
|
||||||
gdb_put_packet("OK");
|
gdb_put_packet("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Execution state helpers
|
|
||||||
*/
|
|
||||||
|
|
||||||
void gdb_handle_query_attached(GArray *params, void *ctx) { gdb_put_packet("1"); }
|
void gdb_handle_query_attached(GArray *params, void *ctx) { gdb_put_packet("1"); }
|
||||||
|
|
||||||
void gdb_continue(void) {
|
void gdb_continue(void) {
|
||||||
if (!runstate_needs_reset()) {
|
if (!runstate_needs_reset()) {
|
||||||
// trace_gdbstub_op_continue();
|
|
||||||
vm_start();
|
vm_start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Resume execution, per CPU actions.
|
|
||||||
*/
|
|
||||||
int gdb_continue_partial(char *newstates) {
|
int gdb_continue_partial(char *newstates) {
|
||||||
CPUState *cpu;
|
CPUState *cpu;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
@ -447,37 +99,33 @@ int gdb_continue_partial(char *newstates) {
|
||||||
|
|
||||||
if (!runstate_needs_reset()) {
|
if (!runstate_needs_reset()) {
|
||||||
bool step_requested = false;
|
bool step_requested = false;
|
||||||
CPU_FOREACH(cpu) {
|
if (newstates[get_cpu()->cpu_index] == 's') {
|
||||||
if (newstates[c->cpu_index] == 's') {
|
step_requested = true;
|
||||||
step_requested = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm_prepare_start(step_requested)) {
|
if (vm_prepare_start(step_requested)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPU_FOREACH(cpu) {
|
auto c = get_cpu();
|
||||||
switch (newstates[c->cpu_index]) {
|
switch (newstates[c->cpu_index]) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
break; /* nothing to do here */
|
break; /* nothing to do here */
|
||||||
case 's':
|
case 's':
|
||||||
// trace_gdbstub_op_stepping(c->cpu_index);
|
// trace_gdbstub_op_stepping(c->cpu_index);
|
||||||
cpu_single_step(c, gdbserver_state.sstep_flags);
|
cpu_single_step(c, gdbserver_state.sstep_flags);
|
||||||
cpu_resume(c);
|
cpu_resume(c);
|
||||||
flag = 1;
|
flag = 1;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
// trace_gdbstub_op_continue_cpu(c->cpu_index);
|
// trace_gdbstub_op_continue_cpu(c->cpu_index);
|
||||||
cpu_resume(c);
|
cpu_resume(c);
|
||||||
flag = 1;
|
flag = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
res = -1;
|
res = -1;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flag) {
|
if (flag) {
|
||||||
|
@ -486,11 +134,6 @@ int gdb_continue_partial(char *newstates) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Signal Handling - in system mode we only need SIGINT and SIGTRAP; other
|
|
||||||
* signals are not yet supported.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum { TARGET_SIGINT = 2, TARGET_SIGTRAP = 5 };
|
enum { TARGET_SIGINT = 2, TARGET_SIGTRAP = 5 };
|
||||||
|
|
||||||
int gdb_signal_to_target(int sig) {
|
int gdb_signal_to_target(int sig) {
|
||||||
|
@ -537,4 +180,197 @@ void qemu_clock_enable() {}
|
||||||
void gdb_handle_file_io(GArray *params, void *user_ctx) {}
|
void gdb_handle_file_io(GArray *params, void *user_ctx) {}
|
||||||
void gdb_disable_syscalls(void) {}
|
void gdb_disable_syscalls(void) {}
|
||||||
|
|
||||||
void cpu_single_step(CPUState *cpu, int enabled) {}
|
void cpu_single_step(CPUState *cpu, int enabled) {}
|
||||||
|
|
||||||
|
uint32_t gdb_get_cpu_pid(CPUState *cpu) {
|
||||||
|
if (cpu->cluster_index == UNASSIGNED_CLUSTER_INDEX) {
|
||||||
|
/* Return the default process' PID */
|
||||||
|
int index = gdbserver_state.process_num - 1;
|
||||||
|
return gdbserver_state.processes[index].pid;
|
||||||
|
}
|
||||||
|
return cpu->cluster_index + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPUState *find_cpu(uint32_t thread_id) {
|
||||||
|
auto cpu = get_cpu();
|
||||||
|
if (gdb_get_cpu_index(cpu) == thread_id) {
|
||||||
|
return cpu;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPUState *gdb_next_cpu_in_process(CPUState *cpu) {
|
||||||
|
uint32_t pid = gdb_get_cpu_pid(cpu);
|
||||||
|
cpu = cpu_next(cpu);
|
||||||
|
|
||||||
|
while (cpu) {
|
||||||
|
if (gdb_get_cpu_pid(cpu) == pid) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cpu = cpu_next(cpu);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the cpu following @cpu, while ignoring unattached processes. */
|
||||||
|
CPUState *gdb_next_attached_cpu(CPUState *cpu) {
|
||||||
|
cpu = cpu_next(cpu);
|
||||||
|
while (cpu) {
|
||||||
|
if (gdb_get_process()->attached) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cpu = cpu_next(cpu);
|
||||||
|
}
|
||||||
|
return cpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the first attached cpu */
|
||||||
|
CPUState *gdb_first_attached_cpu(void) {
|
||||||
|
CPUState *cpu = get_cpu();
|
||||||
|
GDBProcess *process = gdb_get_process();
|
||||||
|
if (!process->attached) {
|
||||||
|
return gdb_next_attached_cpu(cpu);
|
||||||
|
}
|
||||||
|
return cpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPUState *gdb_get_cpu() { return gdb_first_attached_cpu(); }
|
||||||
|
|
||||||
|
const char *get_feature_xml(const char *p, const char **newp, GDBProcess *process) {
|
||||||
|
CPUState *cpu = get_cpu();
|
||||||
|
GDBRegisterState *r;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
const char *term = strchr(p, ':');
|
||||||
|
*newp = term + 1;
|
||||||
|
len = term - p;
|
||||||
|
|
||||||
|
/* Is it the main target xml? */
|
||||||
|
if (strncmp(p, "target.xml", len) == 0) {
|
||||||
|
if (!process->target_xml) {
|
||||||
|
g_autoptr(GPtrArray) xml = g_ptr_array_new_with_free_func(g_free);
|
||||||
|
|
||||||
|
g_ptr_array_add(xml, g_strdup("<?xml version=\"1.0\"?>"
|
||||||
|
"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
|
||||||
|
"<target>"));
|
||||||
|
|
||||||
|
if (cpu->cc->gdb_arch_name) {
|
||||||
|
g_ptr_array_add(xml, g_markup_printf_escaped("<architecture>%s</architecture>", cpu->cc->gdb_arch_name(cpu)));
|
||||||
|
}
|
||||||
|
for (guint i = 0; i < cpu->gdb_regs->len; i++) {
|
||||||
|
r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i);
|
||||||
|
g_ptr_array_add(xml, g_markup_printf_escaped("<xi:include href=\"%s\"/>", r->feature->xmlname));
|
||||||
|
}
|
||||||
|
g_ptr_array_add(xml, g_strdup("</target>"));
|
||||||
|
g_ptr_array_add(xml, NULL);
|
||||||
|
|
||||||
|
process->target_xml = g_strjoinv(NULL, (gchar **)xml->pdata);
|
||||||
|
}
|
||||||
|
return process->target_xml;
|
||||||
|
}
|
||||||
|
/* Is it one of the features? */
|
||||||
|
for (guint i = 0; i < cpu->gdb_regs->len; i++) {
|
||||||
|
r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i);
|
||||||
|
if (strncmp(p, r->feature->xmlname, len) == 0) {
|
||||||
|
return r->feature->xml;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GDBProcess *gdb_get_process() { return gdbserver_state.processes; }
|
||||||
|
|
||||||
|
void gdb_create_default_process(GDBState *s) {
|
||||||
|
GDBProcess *process;
|
||||||
|
s->processes = g_renew(GDBProcess, s->processes, ++s->process_num);
|
||||||
|
process = &s->processes[s->process_num - 1];
|
||||||
|
process->pid = 0;
|
||||||
|
process->attached = false;
|
||||||
|
process->target_xml = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gdb_register_feature(CPUState *cpu, int base_reg, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
|
||||||
|
const GDBFeature *feature) {
|
||||||
|
GDBRegisterState s = {.base_reg = base_reg, .get_reg = get_reg, .set_reg = set_reg, .feature = feature};
|
||||||
|
|
||||||
|
g_array_append_val(cpu->gdb_regs, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gdb_init_cpu(CPUState *cpu) {
|
||||||
|
CPUClass *cc = cpu->cc;
|
||||||
|
const GDBFeature *feature;
|
||||||
|
const char *xmlfile = gdb_get_core_xml_file(cpu);
|
||||||
|
|
||||||
|
cpu->gdb_regs = g_array_new(false, false, sizeof(GDBRegisterState));
|
||||||
|
|
||||||
|
if (xmlfile) {
|
||||||
|
feature = gdb_find_static_feature(xmlfile);
|
||||||
|
gdb_register_feature(cpu, 0, cc->gdb_read_register, cc->gdb_write_register, feature);
|
||||||
|
cpu->gdb_num_regs = cpu->gdb_num_g_regs = feature->num_regs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cc->gdb_num_core_regs) {
|
||||||
|
cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, const GDBFeature *feature,
|
||||||
|
int g_pos) {
|
||||||
|
GDBRegisterState *s;
|
||||||
|
guint i;
|
||||||
|
int base_reg = cpu->gdb_num_regs;
|
||||||
|
|
||||||
|
for (i = 0; i < cpu->gdb_regs->len; i++) {
|
||||||
|
/* Check for duplicates. */
|
||||||
|
s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i);
|
||||||
|
if (s->feature == feature) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gdb_register_feature(cpu, base_reg, get_reg, set_reg, feature);
|
||||||
|
|
||||||
|
/* Add to end of list. */
|
||||||
|
cpu->gdb_num_regs += feature->num_regs;
|
||||||
|
if (g_pos) {
|
||||||
|
if (g_pos != base_reg) {
|
||||||
|
std::cout << "Error: Bad gdb register numbering for" << feature->xml << ", xpected " << g_pos << " got "
|
||||||
|
<< base_reg << std::endl;
|
||||||
|
} else {
|
||||||
|
cpu->gdb_num_g_regs = cpu->gdb_num_regs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gdb_unregister_coprocessor_all(CPUState *cpu) {
|
||||||
|
/*
|
||||||
|
* Safe to nuke everything. GDBRegisterState::xml is static const char so
|
||||||
|
* it won't be freed
|
||||||
|
*/
|
||||||
|
g_array_free(cpu->gdb_regs, true);
|
||||||
|
|
||||||
|
cpu->gdb_regs = NULL;
|
||||||
|
cpu->gdb_num_regs = 0;
|
||||||
|
cpu->gdb_num_g_regs = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *gdb_get_core_xml_file(CPUState *cpu) {
|
||||||
|
CPUClass *cc = cpu->cc;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The CPU class can provide the XML filename via a method,
|
||||||
|
* or as a simple fixed string field.
|
||||||
|
*/
|
||||||
|
if (cc->gdb_get_core_xml_file) {
|
||||||
|
return cc->gdb_get_core_xml_file(cpu);
|
||||||
|
}
|
||||||
|
return cc->gdb_core_xml_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cpu_resume(CPUState *cpu) {
|
||||||
|
cpu->stop = false;
|
||||||
|
cpu->stopped = false;
|
||||||
|
// qemu_cpu_kick(cpu);
|
||||||
|
}
|
|
@ -1 +0,0 @@
|
||||||
#include "trace/trace-gdbstub.h"
|
|
Loading…
Reference in New Issue