|
@@ -777,6 +777,10 @@ typedef void (*GdbCmdHandler)(GArray *params, void *user_ctx);
|
|
/*
|
|
/*
|
|
* cmd_startswith -> cmd is compared using startswith
|
|
* cmd_startswith -> cmd is compared using startswith
|
|
*
|
|
*
|
|
|
|
+ * allow_stop_reply -> true iff the gdbstub can respond to this command with a
|
|
|
|
+ * "stop reply" packet. The list of commands that accept such response is
|
|
|
|
+ * defined at the GDB Remote Serial Protocol documentation. see:
|
|
|
|
+ * https://sourceware.org/gdb/onlinedocs/gdb/Stop-Reply-Packets.html#Stop-Reply-Packets.
|
|
*
|
|
*
|
|
* schema definitions:
|
|
* schema definitions:
|
|
* Each schema parameter entry consists of 2 chars,
|
|
* Each schema parameter entry consists of 2 chars,
|
|
@@ -802,6 +806,7 @@ typedef struct GdbCmdParseEntry {
|
|
const char *cmd;
|
|
const char *cmd;
|
|
bool cmd_startswith;
|
|
bool cmd_startswith;
|
|
const char *schema;
|
|
const char *schema;
|
|
|
|
+ bool allow_stop_reply;
|
|
} GdbCmdParseEntry;
|
|
} GdbCmdParseEntry;
|
|
|
|
|
|
static inline int startswith(const char *string, const char *pattern)
|
|
static inline int startswith(const char *string, const char *pattern)
|
|
@@ -835,6 +840,7 @@ static int process_string_cmd(void *user_ctx, const char *data,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ gdbserver_state.allow_stop_reply = cmd->allow_stop_reply;
|
|
cmd->handler(params, user_ctx);
|
|
cmd->handler(params, user_ctx);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -1283,11 +1289,14 @@ static void handle_v_attach(GArray *params, void *user_ctx)
|
|
gdbserver_state.g_cpu = cpu;
|
|
gdbserver_state.g_cpu = cpu;
|
|
gdbserver_state.c_cpu = cpu;
|
|
gdbserver_state.c_cpu = cpu;
|
|
|
|
|
|
- g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP);
|
|
|
|
- gdb_append_thread_id(cpu, gdbserver_state.str_buf);
|
|
|
|
- g_string_append_c(gdbserver_state.str_buf, ';');
|
|
|
|
|
|
+ if (gdbserver_state.allow_stop_reply) {
|
|
|
|
+ g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP);
|
|
|
|
+ gdb_append_thread_id(cpu, gdbserver_state.str_buf);
|
|
|
|
+ g_string_append_c(gdbserver_state.str_buf, ';');
|
|
|
|
+ gdbserver_state.allow_stop_reply = false;
|
|
cleanup:
|
|
cleanup:
|
|
- gdb_put_strbuf();
|
|
|
|
|
|
+ gdb_put_strbuf();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
static void handle_v_kill(GArray *params, void *user_ctx)
|
|
static void handle_v_kill(GArray *params, void *user_ctx)
|
|
@@ -1310,12 +1319,14 @@ static const GdbCmdParseEntry gdb_v_commands_table[] = {
|
|
.handler = handle_v_cont,
|
|
.handler = handle_v_cont,
|
|
.cmd = "Cont",
|
|
.cmd = "Cont",
|
|
.cmd_startswith = 1,
|
|
.cmd_startswith = 1,
|
|
|
|
+ .allow_stop_reply = true,
|
|
.schema = "s0"
|
|
.schema = "s0"
|
|
},
|
|
},
|
|
{
|
|
{
|
|
.handler = handle_v_attach,
|
|
.handler = handle_v_attach,
|
|
.cmd = "Attach;",
|
|
.cmd = "Attach;",
|
|
.cmd_startswith = 1,
|
|
.cmd_startswith = 1,
|
|
|
|
+ .allow_stop_reply = true,
|
|
.schema = "l0"
|
|
.schema = "l0"
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -1698,10 +1709,13 @@ static void handle_gen_set(GArray *params, void *user_ctx)
|
|
|
|
|
|
static void handle_target_halt(GArray *params, void *user_ctx)
|
|
static void handle_target_halt(GArray *params, void *user_ctx)
|
|
{
|
|
{
|
|
- g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP);
|
|
|
|
- gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf);
|
|
|
|
- g_string_append_c(gdbserver_state.str_buf, ';');
|
|
|
|
- gdb_put_strbuf();
|
|
|
|
|
|
+ if (gdbserver_state.allow_stop_reply) {
|
|
|
|
+ g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP);
|
|
|
|
+ gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf);
|
|
|
|
+ g_string_append_c(gdbserver_state.str_buf, ';');
|
|
|
|
+ gdb_put_strbuf();
|
|
|
|
+ gdbserver_state.allow_stop_reply = false;
|
|
|
|
+ }
|
|
/*
|
|
/*
|
|
* Remove all the breakpoints when this query is issued,
|
|
* Remove all the breakpoints when this query is issued,
|
|
* because gdb is doing an initial connect and the state
|
|
* because gdb is doing an initial connect and the state
|
|
@@ -1725,7 +1739,8 @@ static int gdb_handle_packet(const char *line_buf)
|
|
static const GdbCmdParseEntry target_halted_cmd_desc = {
|
|
static const GdbCmdParseEntry target_halted_cmd_desc = {
|
|
.handler = handle_target_halt,
|
|
.handler = handle_target_halt,
|
|
.cmd = "?",
|
|
.cmd = "?",
|
|
- .cmd_startswith = 1
|
|
|
|
|
|
+ .cmd_startswith = 1,
|
|
|
|
+ .allow_stop_reply = true,
|
|
};
|
|
};
|
|
cmd_parser = &target_halted_cmd_desc;
|
|
cmd_parser = &target_halted_cmd_desc;
|
|
}
|
|
}
|
|
@@ -1736,6 +1751,7 @@ static int gdb_handle_packet(const char *line_buf)
|
|
.handler = handle_continue,
|
|
.handler = handle_continue,
|
|
.cmd = "c",
|
|
.cmd = "c",
|
|
.cmd_startswith = 1,
|
|
.cmd_startswith = 1,
|
|
|
|
+ .allow_stop_reply = true,
|
|
.schema = "L0"
|
|
.schema = "L0"
|
|
};
|
|
};
|
|
cmd_parser = &continue_cmd_desc;
|
|
cmd_parser = &continue_cmd_desc;
|
|
@@ -1747,6 +1763,7 @@ static int gdb_handle_packet(const char *line_buf)
|
|
.handler = handle_cont_with_sig,
|
|
.handler = handle_cont_with_sig,
|
|
.cmd = "C",
|
|
.cmd = "C",
|
|
.cmd_startswith = 1,
|
|
.cmd_startswith = 1,
|
|
|
|
+ .allow_stop_reply = true,
|
|
.schema = "l0"
|
|
.schema = "l0"
|
|
};
|
|
};
|
|
cmd_parser = &cont_with_sig_cmd_desc;
|
|
cmd_parser = &cont_with_sig_cmd_desc;
|
|
@@ -1785,6 +1802,7 @@ static int gdb_handle_packet(const char *line_buf)
|
|
.handler = handle_step,
|
|
.handler = handle_step,
|
|
.cmd = "s",
|
|
.cmd = "s",
|
|
.cmd_startswith = 1,
|
|
.cmd_startswith = 1,
|
|
|
|
+ .allow_stop_reply = true,
|
|
.schema = "L0"
|
|
.schema = "L0"
|
|
};
|
|
};
|
|
cmd_parser = &step_cmd_desc;
|
|
cmd_parser = &step_cmd_desc;
|
|
@@ -1976,6 +1994,7 @@ void gdb_read_byte(uint8_t ch)
|
|
{
|
|
{
|
|
uint8_t reply;
|
|
uint8_t reply;
|
|
|
|
|
|
|
|
+ gdbserver_state.allow_stop_reply = false;
|
|
#ifndef CONFIG_USER_ONLY
|
|
#ifndef CONFIG_USER_ONLY
|
|
if (gdbserver_state.last_packet->len) {
|
|
if (gdbserver_state.last_packet->len) {
|
|
/* Waiting for a response to the last packet. If we see the start
|
|
/* Waiting for a response to the last packet. If we see the start
|