From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 83C3D384AB5F for ; Mon, 22 Apr 2024 08:45:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83C3D384AB5F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 83C3D384AB5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713775557; cv=none; b=GZqFae9Sd2ySW+4GancKwHJYeJsvZhppmW/OoxN2otCMdtVtX2LH0mN4uUypV7jgxQ60ImgjQOwpCaiLanVEg5977kE9BOXcNNqYUZ75iGtfSfM+EYylV5p800kiuz43W61LM1fwT5BuYMkXSlZg/p0LwRDCnK67DJ/9+VA0CDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713775557; c=relaxed/simple; bh=Ieaq4TxPEqUIsVNOqj+VLAOBwCcAc1dvn+NywPeRH5s=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=R9BnO3+kIhxeyA4idt6qxaBq3jSglDVl2sAV1AbDCNarQYOk+9AOqF9bbMZuq4LodMtus+CrPkFQqAuC65BpSvrHwj7fWQm+j6cuHKjn+gkZASKJOkfWT0sojun95oAcHw3gnuN6D5ZlGsJp8JuYwj6GDXq7DL7bq3s5mAnCi9M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713775555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OsXsU8ggMRkHvNR/QOXSZIh2S5M5h1EkFgXK0YLqIbM=; b=HvL/xWshl/Bd8UA6kPlIK95Vv4GkoqdHUojycoUsWd/O/Doy6WDVldbV2EpIHlLCoacyNT IvepUW6fZzMm8WGjFS2IkoQr26Ia09ZMqMmunATyMEXhxpiIi5aUPNkg0bmWAxbwDg9o5w b1Tyi1rysrN1sFWyw0K7ouBB1ptsPGY= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-dartlfYSOa6gc8k8WuYNJA-1; Mon, 22 Apr 2024 04:45:53 -0400 X-MC-Unique: dartlfYSOa6gc8k8WuYNJA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-41895b0a62cso32850185e9.2 for ; Mon, 22 Apr 2024 01:45:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713775551; x=1714380351; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OsXsU8ggMRkHvNR/QOXSZIh2S5M5h1EkFgXK0YLqIbM=; b=AS8NqHYAZDBEA4jzIIpgVDwqfYVIuHHY0w/3ejKwczSg3HfSeQ5Ov17fRpId4qzCdb NpK7RfBuagri7UOSowmTxQpm8mVcEABt/4tsoI/NOPNnQBxASkmAbnPGDhmIacLV9zEP BnZCI8//XrtfDVNWiilIajceqVHGKUrnX2N3GfU8rboYQMlbN0whZ+IRMwRDs7ZVQXVn sP6VsKjab8A5y0IkSXof8yj3d1kIvZm31fR/az+H1/s/DKLXBNOIH7mlW48N2NdjgjHQ Xjt10ydBHlKKzZN3nsWv/Ybu+A8dJCUvBhGAfQ86hc4MzgHfIW3WHWmra0KkVAJ8dTYk VmaA== X-Gm-Message-State: AOJu0YxKHQ8CXXuLM6qTDT3YblBoUVju1UfqXir3qI9YyvOpR6/9vVCB NVn3oXdEyj8D+K6UGsPMR8WiFextFSmfLzbvAebVWpx80AFlpkhx+st/tg/g0b5ZMtmjxAAi4Js BzdCVvKjsMaUNvKS/abA59FGm6WI5IvKOs3KBujDp8fQ4/9DWY7v60SiTJcDBIzszkF5XwrxHg8 ieblGCfPXDM5Lusl7myiYz2r5lyFQRtOaX30H52+LRLAg= X-Received: by 2002:a05:600c:1c21:b0:418:ee1e:3445 with SMTP id j33-20020a05600c1c2100b00418ee1e3445mr8602454wms.26.1713775551488; Mon, 22 Apr 2024 01:45:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDdm39mzIdVePZ/ls3xntH7R6YYl8DGoKPendT6zs60D4Lcu7nghfAyw513EMeOLoDVSl/QQ== X-Received: by 2002:a05:600c:1c21:b0:418:ee1e:3445 with SMTP id j33-20020a05600c1c2100b00418ee1e3445mr8602419wms.26.1713775550732; Mon, 22 Apr 2024 01:45:50 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id bg40-20020a05600c3ca800b0041624ddff48sm19783930wmb.28.2024.04.22.01.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 01:45:50 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb/remote: fix qRcmd error handling Date: Mon, 22 Apr 2024 09:45:47 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 List-Id: This commit: commit 3623271997a5c0d79609aa6a1f35ef61b4469054 Date: Tue Jan 30 15:55:47 2024 +0100 remote.c: Use packet_check_result Introduced a bug in the error handling of the qRcmd packet. Prior to this commit if a packet had status PACKET_OK then, if the packet contained the text "OK" we considered the packet handled. But, if the packet contained any other content (that was not an error message) then the content was printed to the user. After the above commit this was no longer the case, any non-error packet that didn't contain "OK" would be treated as an error. Currently, gdbserver doesn't exercise this path so it's not possible to write a simple test for this case. When gdbserver wishes to print output it sends back an 'O' string output packet, these packets are handled earlier in the process. Then once gdbserver has finished sending output an 'OK' packet is sent. --- gdb/remote.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index cfb54de157d..ee4b76e290b 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -11954,18 +11954,23 @@ remote_target::rcmd (const char *command, struct ui_file *outbuf) continue; } packet_result result = packet_check_result (buf, false); - if (strcmp (buf, "OK") == 0) - break; - else if (result.status () == PACKET_UNKNOWN) - error (_("Target does not support this command.")); - else - error (_("Protocol error with Rcmd: %s."), result.err_msg ()); - - for (p = buf; p[0] != '\0' && p[1] != '\0'; p += 2) + switch (result.status ()) { - char c = (fromhex (p[0]) << 4) + fromhex (p[1]); + case PACKET_UNKNOWN: + error (_("Target does not support this command.")); + case PACKET_ERROR: + error (_("Protocol error with Rcmd: %s."), result.err_msg ()); + case PACKET_OK: + break; + } - gdb_putc (c, outbuf); + if (strcmp (buf, "OK") != 0) + { + for (p = buf; p[0] != '\0' && p[1] != '\0'; p += 2) + { + char c = (fromhex (p[0]) << 4) + fromhex (p[1]); + gdb_putc (c, outbuf); + } } break; } base-commit: 1f984aabf17f558d04d3cf1c1b643fd44e8348e8 -- 2.25.4