From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id E6A193858D33 for ; Mon, 28 Aug 2023 20:05:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E6A193858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-34cacab5e33so12832255ab.2 for ; Mon, 28 Aug 2023 13:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1693253155; x=1693857955; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HxfSHFy8gTZZS0EwWe5ddKPPxWDhJQzt60nhfhyYtzw=; b=OcYbkss5vTE+W+yacJ6SHTmyveWA/Y1rhJDSfc7Rd0MteFpeRR1CS2WF9Pcg3kMwfg 51vw9Oj1oXy3zg1FTtQte0nxXPVKQRX2Yik90Fb6CjYeurYhrEAVd/Tt0QpGhWpMr3O0 /IFdOGsDxPYtDnhQ6rIdMkw34mXwPu085pMjvDXen1/5BKpjNFAlbaj8xBA9W7PTQtqC 8gQh0cH42jTi07xRl4d9CT1lMC+gJ2KTNljfsY8J1NGfJFkIcCCSfFbzRV2473Q93w3n kF9ERNdcwziIMNP1qYHX+vk2h+xzCWi4eCWM4MNxEUYMFuzSOiQbdJXZa3E3bKKCVJr8 qZTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693253155; x=1693857955; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HxfSHFy8gTZZS0EwWe5ddKPPxWDhJQzt60nhfhyYtzw=; b=G3ao2oAHnyheeMct72cftqpgg/hbQ81s+tsp8kActtNqywjZrLR9EKtHSLMHqZqDqk 2rRYQx5LQfKX6i6/fJDfXVzo96fZKdG/l72x2H11DAUeKcBA+22pkzRlQBRb8rx+7pS+ +ajdlJEBnBqvK+S9F3Vo0lg6/7oSW1rbGpZmIQowBwNfZ8ba+K3XAHMuZM2Im2A2E02y g3MJrir8qbm8MbfcA0Th1EZ5Aw/eBpW4866rhZuX6HsM2sVy4V8dhthCZVVrbXxj60jG br/CLxML0WMRi2W4DcR4Ug+4Z7AsTjNULcYF37W8PmHA47iwwDDS5qPLOzqNHohVURG2 gR2g== X-Gm-Message-State: AOJu0Yxse12jYGijB7kk/ND1912CB2zNEVQvjyaTEl4TPVcOqbjE5XNE iu83KLH3lb2bZXchLcK8D9J3cGn56J1E6DKR+Uos2Q== X-Google-Smtp-Source: AGHT+IGd8StlefST6yMA5ygbGUtd3qtHQpj01KvIKDHXyKB0SwPAQ4JeoMGlB3aqyQeQMhXbV+Dm0Q== X-Received: by 2002:a05:6e02:d51:b0:349:865d:a06 with SMTP id h17-20020a056e020d5100b00349865d0a06mr14580306ilj.4.1693253154914; Mon, 28 Aug 2023 13:05:54 -0700 (PDT) Received: from localhost.localdomain (75-166-150-212.hlrn.qwest.net. [75.166.150.212]) by smtp.gmail.com with ESMTPSA id b13-20020a920b0d000000b00345cce526cdsm2629817ilf.54.2023.08.28.13.05.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 13:05:54 -0700 (PDT) From: Tom Tromey Date: Mon, 28 Aug 2023 14:05:52 -0600 Subject: [PATCH v2 1/5] Remove getpkt_sane MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230828-getpkt-cleanup-v2-1-7dd1a6974b94@adacore.com> References: <20230828-getpkt-cleanup-v2-0-7dd1a6974b94@adacore.com> In-Reply-To: <20230828-getpkt-cleanup-v2-0-7dd1a6974b94@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: I noticed that getpkt is just a wrapper around getpk_sane, so this patch unifies the two of them. --- gdb/remote.c | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 5af40bd704c..29aff714ca5 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1213,10 +1213,9 @@ class remote_target : public process_stratum_target void skip_frame (); long read_frame (gdb::char_vector *buf_p); - void getpkt (gdb::char_vector *buf, int forever); int getpkt_or_notif_sane_1 (gdb::char_vector *buf, int forever, int expecting_notif, int *is_notif); - int getpkt_sane (gdb::char_vector *buf, int forever); + int getpkt (gdb::char_vector *buf, int forever); int getpkt_or_notif_sane (gdb::char_vector *buf, int forever, int *is_notif); int remote_vkill (int pid); @@ -10044,23 +10043,6 @@ show_watchdog (struct ui_file *file, int from_tty, gdb_printf (file, _("Watchdog timer is %s.\n"), value); } -/* Read a packet from the remote machine, with error checking, and - store it in *BUF. Resize *BUF if necessary to hold the result. If - FOREVER, wait forever rather than timing out; this is used (in - synchronous mode) to wait for a target that is is executing user - code to stop. */ -/* FIXME: ezannoni 2000-02-01 this wrapper is necessary so that we - don't have to change all the calls to getpkt to deal with the - return value, because at the moment I don't know what the right - thing to do it for those. */ - -void -remote_target::getpkt (gdb::char_vector *buf, int forever) -{ - getpkt_sane (buf, forever); -} - - /* Read a packet from the remote machine, with error checking, and store it in *BUF. Resize *BUF if necessary to hold the result. If FOREVER, wait forever rather than timing out; this is used (in @@ -10212,8 +10194,14 @@ remote_target::getpkt_or_notif_sane_1 (gdb::char_vector *buf, } } +/* Read a packet from the remote machine, with error checking, and + store it in *BUF. Resize *BUF if necessary to hold the result. If + FOREVER, wait forever rather than timing out; this is used (in + synchronous mode) to wait for a target that is is executing user + code to stop. */ + int -remote_target::getpkt_sane (gdb::char_vector *buf, int forever) +remote_target::getpkt (gdb::char_vector *buf, int forever) { return getpkt_or_notif_sane_1 (buf, forever, 0, NULL); } @@ -11289,7 +11277,7 @@ remote_target::remote_write_qxfer (const char *object_name, (writebuf, len, 1, (gdb_byte *) rs->buf.data () + i, &max_size, max_size); if (putpkt_binary (rs->buf.data (), i + buf_len) < 0 - || getpkt_sane (&rs->buf, 0) < 0 + || getpkt (&rs->buf, 0) < 0 || m_features.packet_ok (rs->buf, which_packet) != PACKET_OK) return TARGET_XFER_E_IO; @@ -11353,7 +11341,7 @@ remote_target::remote_read_qxfer (const char *object_name, return TARGET_XFER_E_IO; rs->buf[0] = '\0'; - packet_len = getpkt_sane (&rs->buf, 0); + packet_len = getpkt (&rs->buf, 0); if (packet_len < 0 || m_features.packet_ok (rs->buf, which_packet) != PACKET_OK) return TARGET_XFER_E_IO; @@ -11658,7 +11646,7 @@ remote_target::search_memory (CORE_ADDR start_addr, ULONGEST search_space_len, error (_("Pattern is too large to transmit to remote target.")); if (putpkt_binary (rs->buf.data (), i + escaped_pattern_len) < 0 - || getpkt_sane (&rs->buf, 0) < 0 + || getpkt (&rs->buf, 0) < 0 || m_features.packet_ok (rs->buf, PACKET_qSearch_memory) != PACKET_OK) { /* The request may not have worked because the command is not @@ -11722,7 +11710,7 @@ remote_target::rcmd (const char *command, struct ui_file *outbuf) /* XXX - see also remote_get_noisy_reply(). */ QUIT; /* Allow user to bail out with ^C. */ rs->buf[0] = '\0'; - if (getpkt_sane (&rs->buf, 0) == -1) + if (getpkt (&rs->buf, 0) == -1) { /* Timeout. Continue to (try to) read responses. This is better than stopping with an error, assuming the stub @@ -11833,7 +11821,7 @@ send_remote_packet (gdb::array_view &buf, remote->putpkt_binary (buf.data (), buf.size ()); remote_state *rs = remote->get_remote_state (); - int bytes = remote->getpkt_sane (&rs->buf, 0); + int bytes = remote->getpkt (&rs->buf, 0); if (bytes < 0) error (_("error while fetching packet from remote target")); @@ -12366,7 +12354,7 @@ remote_target::remote_hostio_send_command (int command_bytes, int which_packet, } putpkt_binary (rs->buf.data (), command_bytes); - bytes_read = getpkt_sane (&rs->buf, 0); + bytes_read = getpkt (&rs->buf, 0); /* If it timed out, something is wrong. Don't try to parse the buffer. */ -- 2.40.1