@@ -76,6 +76,9 @@
set_thread = ('H' any* @{cmd = SET_THREAD;});
+ disconnect = ('D' @{cmd = DISCONNECT;}
+ xdigit+ $hex_digit %push);
+
# TODO: We don't actually listen to what's supported
q_attached = ('qAttached:' xdigit* @{rsp = "1";});
q_C = ('qC' @{rsp = "QC1";});
@@ -91,7 +94,7 @@
commands = (get_mem | get_gprs | get_spr | stop_reason | set_thread |
q_attached | q_C | q_supported | qf_threadinfo | q_C |
- v_contq | v_contc | v_conts | put_mem );
+ v_contq | v_contc | v_conts | put_mem | disconnect );
cmd = ((commands & ^'#'*) | ^'#'*) $crc
('#' xdigit{2} $hex_digit @end);
@@ -36,6 +36,8 @@ static int fd = -1;
enum client_state {IDLE, SIGNAL_WAIT};
static enum client_state state = IDLE;
+static void destroy_client(int dead_fd);
+
static uint8_t gdbcrc(char *data)
{
uint8_t crc = 0;
@@ -80,6 +82,12 @@ static void stop_reason(uint64_t *stack, void *priv)
send_response(fd, "S05");
}
+static void disconnect(uint64_t *stack, void *priv)
+{
+ printf("Terminating connection with client. pid %16" PRIi64 "\n", stack[0]);
+ send_response(fd, "OK");
+}
+
/* 32 registers represented as 16 char hex numbers with null-termination */
#define REG_DATA_SIZE (32*16+1)
static void get_gprs(uint64_t *stack, void *priv)
@@ -413,6 +421,7 @@ command_cb callbacks[LAST_CMD + 1] = {
v_conts,
put_mem,
interrupt,
+ disconnect,
NULL};
int gdbserver_start(struct pdbg_target *target, uint16_t port)
@@ -3,7 +3,7 @@
enum gdb_command {NONE, GET_GPRS, GET_SPR, GET_MEM,
STOP_REASON, SET_THREAD, V_CONTC, V_CONTS,
- PUT_MEM, INTERRUPT, LAST_CMD};
+ PUT_MEM, INTERRUPT, DISCONNECT, LAST_CMD};
typedef void (*command_cb)(uint64_t *stack, void *priv);
void parser_init(command_cb *callbacks);
Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com> --- src/gdb_parser.rl | 5 ++++- src/pdbgproxy.c | 9 +++++++++ src/pdbgproxy.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-)