From patchwork Fri Jan 13 11:59:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandra Petlanova Hajkova X-Patchwork-Id: 63152 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 590DE3854806 for ; Fri, 13 Jan 2023 11:59:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 590DE3854806 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673611179; bh=07C+kRQ45iQ/kodPikRmym7m4FBKVT1V2WytuctkxPQ=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=VE2hsxuIv0/V/w4RCX3KxsX20zeOAV3IeJ8h06TEWLehK61gvdS5qCFytquf0a72O 8iEzjZwN50j2lA/akX+4dO+dXSGjd8EUGlHPOdyTswOm7J2a3y7bTrxw5X7vDO1zpv xVfGQ7MuhFyXmy8Fkmwcdf6UaQgKwUkR+3/9PLsE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6B044385482C for ; Fri, 13 Jan 2023 11:59:15 +0000 (GMT) Authentication-Results: sourceware.org; dkim=permerror (bad message/signature format) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673611155; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=07C+kRQ45iQ/kodPikRmym7m4FBKVT1V2WytuctkxPQ=; b=Nmhew/GrnnUFzq/SJUzs2v6jQ9bskwyK5N/UKW3kGnAQlngg0aoLVoPqiS7HX7k70A7kss bxgvdv8w7D5iaQT5E1Kz+plJjawc2zp9yVvT4bA808/HsV6PwVtwD5hxOn/Usll1POm46y 6iypZRzjaMrSsnYPpbNVgGrJbmI2OEE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-vgCZh_7GOQaFSPzjYFJmrw-1; Fri, 13 Jan 2023 06:59:14 -0500 X-MC-Unique: vgCZh_7GOQaFSPzjYFJmrw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD745380391D for ; Fri, 13 Jan 2023 11:59:13 +0000 (UTC) Received: from ovpn-208-17.brq.redhat.com (ovpn-208-17.brq.redhat.com [10.40.208.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 299ED14171B7 for ; Fri, 13 Jan 2023 11:59:12 +0000 (UTC) From: AlexandraH =?utf-8?b?w6E=?= jkov =?utf-8?b?w6E=?= @sourceware.org To: gdb-patches@sourceware.org Subject: [PATCH v2] remote.c: Allow inferior to reply with an error Date: Fri, 13 Jan 2023 12:59:10 +0100 Message-Id: <20230113115910.3215524-1-ahajkova@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FROM_EXCESS_BASE64, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From: Alexandra Hájková When gdb communicates with some kind of gdbserver or gdbserver stub over the remote protocol, the only possible response to the QSetWorkingDir packet is "OK". If the remote will reply with anything else, gdb will complain about the unexpected reply. [remote] Sending packet: $QSetWorkingDir:2f746d70#bb [remote] Packet received: E00 Remote replied unexpectedly while setting the inferior's working directory: E00 (gdb) Allow remote to send an error message over as a QSetWorkingDir packet reply. [remote] Sending packet: $QSetWorkingDir:2f746d70#bb [remote] Packet received: E.directory does not exist Remote failed to set working directory: directory does not exist. --- V2 does not change the behaviour of gdb in a case it wasn't possible to set the inferior's working directory. It just allows to pass the error message to gdb. gdb/doc/gdb.texinfo | 3 +++ gdb/remote.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 9c0018ea5c1..5df9a5a9178 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -42517,6 +42517,9 @@ Reply: @table @samp @item OK The request succeeded. + +@item E.errtext +An error occurred. Reply with an error message. @end table @item qfThreadInfo diff --git a/gdb/remote.c b/gdb/remote.c index 218bca30d04..ea89759e85a 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -10397,8 +10397,10 @@ remote_target::extended_remote_set_inferior_cwd () if (packet_support (PACKET_QSetWorkingDir) != PACKET_DISABLE) { const std::string &inferior_cwd = current_inferior ()->cwd (); + char *buf; remote_state *rs = get_remote_state (); + buf = rs->buf.data (); if (!inferior_cwd.empty ()) { std::string hexpath @@ -10420,11 +10422,15 @@ remote_target::extended_remote_set_inferior_cwd () getpkt (&rs->buf, 0); if (packet_ok (rs->buf, &remote_protocol_packets[PACKET_QSetWorkingDir]) - != PACKET_OK) - error (_("\ + != PACKET_OK) { + if (buf[0] == 'E' && buf[1] == '.') + error (_("Remote failed to set working directory: %s"), buf + 2); + else + error (_("\ Remote replied unexpectedly while setting the inferior's working\n\ -directory: %s"), +directory: %s."), rs->buf.data ()); + } } }