From patchwork Tue Aug 27 19:48:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 11117445 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D8AD16B1 for ; Tue, 27 Aug 2019 19:49:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80CE220674 for ; Tue, 27 Aug 2019 19:49:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80CE220674 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:56418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2hTP-0008Hc-Nv for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 15:49:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40379) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2hSr-0007pk-At for qemu-devel@nongnu.org; Tue, 27 Aug 2019 15:49:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2hSp-00019o-Ii for qemu-devel@nongnu.org; Tue, 27 Aug 2019 15:49:12 -0400 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:16672) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i2hSp-00018N-AM for qemu-devel@nongnu.org; Tue, 27 Aug 2019 15:49:11 -0400 IronPort-SDR: 8I5F0v+UP/FF+34I5pZd5iGwyHeiU8oAwgAgxETTF+gOQBfJtD+YfZ9nd+6VWBATytybZUmtxw TFuQkuAcKsvF9apBY1LY4oHcdTWI68nOLJyJpPuxNg3o/DBSHy0S2RAjRMd/LAAV2EEZPwEX24 5VFHuNhYocV3kR2xCSX8WK41YBjM/j88bSiM/aAUspGEbh71ezxHyCPGDGv1s+5sjUXIDJQYUo QY+/698pACmQMmdXAIO42Jhlw2MFq0zm1Vpvpugk79iw6pBnlAvs5JehFzH4YtF/vwpaKIvDzX pOw= X-IronPort-AV: E=Sophos;i="5.64,438,1559548800"; d="scan'208";a="40811136" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 27 Aug 2019 11:49:06 -0800 IronPort-SDR: EVsW9KEHt0Wvn/tWc+u16rEtB3hmBpGKt8tTyI1wxTS+DygSgF/yL0FT7SHiLwiV0eBYf41sBv WwFk06Dd8ZoA1YXI1ZttKNubBusEfNKf0PSlIRrFyMtAO4NyLy4biKkuhclRodzJJIxJayA2TO AP/9F4JqkndcxkfxY8JcWHg0KrZwoUSt4HLOshe/Wad8ecb1KX/FEATgY/hkYjMxVmB8a1w83w BetWKWrdqQ6WstZUKWIHU0RqJu2iWZM0hyQdctLT8qj9MyKqzUSASERQWG18OvvB911uhfKgDy MSY= From: Sandra Loosemore To: Date: Tue, 27 Aug 2019 13:48:49 -0600 Message-ID: <20190827194849.7076-1-sandra@codesourcery.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-ClientProxiedBy: SVR-ORW-MBX-05.mgc.mentorg.com (147.34.90.205) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 68.232.137.180 Subject: [Qemu-devel] [PATCH] gdbstub: Fix handler for 'F' packet X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Jon Doron Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Handling of the 'F' packet has been broken since commit 4b20fab101b9e2d0fb47454209637a17fc7a13d5, which converted it to use the new packet parsing infrastructure. Per the GDB RSP specification https://sourceware.org/gdb/current/onlinedocs/gdb/The-F-Reply-Packet.html the second parameter may be omitted, but the rewritten implementation was failing to recognize this case. The result was that QEMU was repeatedly resending the fileio request and ignoring GDB's replies of successful completion. This patch restores the behavior of the previous code in allowing the errno parameter to be omitted and passing 0 to the callback in that case. Signed-off-by: Sandra Loosemore --- gdbstub.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index b92ba59..141568a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1820,11 +1820,15 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) { - if (gdb_ctx->num_params >= 2 && gdb_ctx->s->current_syscall_cb) { + if (gdb_ctx->num_params >= 1 && gdb_ctx->s->current_syscall_cb) { target_ulong ret, err; ret = (target_ulong)gdb_ctx->params[0].val_ull; - err = (target_ulong)gdb_ctx->params[1].val_ull; + if (gdb_ctx->num_params >= 2 ) { + err = (target_ulong)gdb_ctx->params[1].val_ull; + } else { + err = 0; + } gdb_ctx->s->current_syscall_cb(gdb_ctx->s->c_cpu, ret, err); gdb_ctx->s->current_syscall_cb = NULL; }