Received: from eggs.gnu.org ([209.51.188.92]:43876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJIzI-0004gC-9O for qemu-devel@nongnu.org; Wed, 24 Apr 2019 10:35:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJIsV-000133-8d for qemu-devel@nongnu.org; Wed, 24 Apr 2019 10:28:05 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:54595) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hJIsT-0000yU-AN for qemu-devel@nongnu.org; Wed, 24 Apr 2019 10:28:02 -0400 Received: by mail-wm1-x343.google.com with SMTP id c1so4877209wml.4 for ; Wed, 24 Apr 2019 07:28:00 -0700 (PDT) From: arilou@gmail.com Date: Wed, 24 Apr 2019 17:27:09 +0300 Message-Id: <20190424142714.28460-15-arilou@gmail.com> In-Reply-To: <20190424142714.28460-1-arilou@gmail.com> References: <20190424142714.28460-1-arilou@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v3 15/20] 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: Jon Doron From: 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 b3278a66c7..a71fbc800d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1788,6 +1788,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; @@ -1928,28 +1961,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 GdbCmdParseEntry file_io_cmd_desc = { + .handler = handle_file_io, + .cmd = "F", + .cmd_startswith = 1, + .schema = "s0" + }; + process_string_cmd(s, NULL, line_buf, &file_io_cmd_desc, 1); } break; case 'g': -- 2.20.1