From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:42977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6tk-0003cX-RO for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6th-0008OM-A6 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:56 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34196) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6tg-0007Ww-Vp for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:53 -0400 Received: by mail-wr1-x442.google.com with SMTP id e9so2033576wrc.1 for ; Thu, 02 May 2019 01:16:31 -0700 (PDT) From: Jon Doron Date: Thu, 2 May 2019 11:15:42 +0300 Message-Id: <20190502081554.5521-16-arilou@gmail.com> In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v9 15/27] gdbstub: Implement file io (F pkt) with new infra List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Jon Doron Signed-off-by: Jon Doron --- gdbstub.c | 62 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 3478ac778d..9fe130f30d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1772,6 +1772,39 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } +static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + int num_syscall_params; + GdbCmdVariant syscall_params[3] = {}; + + if (!gdb_ctx->num_params) { + return; + } + + if (cmd_parse_params(gdb_ctx->params[0].data, "L,L,o0", syscall_params, + &num_syscall_params)) { + return; + } + + if (!num_syscall_params) { + return; + } + + if (gdb_ctx->s->current_syscall_cb) { + gdb_ctx->s->current_syscall_cb(gdb_ctx->s->c_cpu, + (target_ulong)syscall_params[0].val_ull, + (target_ulong)syscall_params[1].val_ull); + gdb_ctx->s->current_syscall_cb = NULL; + } + + if (syscall_params[2].opcode == (uint8_t)'C') { + put_packet(gdb_ctx->s, "T02"); + return; + } + + gdb_continue(gdb_ctx->s); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; @@ -1913,28 +1946,13 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) return RS_IDLE; case 'F': { - target_ulong ret; - target_ulong err; - - ret = strtoull(p, (char **)&p, 16); - if (*p == ',') { - p++; - err = strtoull(p, (char **)&p, 16); - } else { - err = 0; - } - if (*p == ',') - p++; - type = *p; - if (s->current_syscall_cb) { - s->current_syscall_cb(s->c_cpu, ret, err); - s->current_syscall_cb = NULL; - } - if (type == 'C') { - put_packet(s, "T02"); - } else { - gdb_continue(s); - } + static const GdbCmdParseEntry file_io_cmd_desc = { + .handler = handle_file_io, + .cmd = "F", + .cmd_startswith = 1, + .schema = "s0" + }; + cmd_parser = &file_io_cmd_desc; } break; case 'g': -- 2.20.1