From patchwork Mon Apr 15 14:19:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 88492 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 4EF90384773A for ; Mon, 15 Apr 2024 14:20:09 +0000 (GMT) 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 962233858D37 for ; Mon, 15 Apr 2024 14:19:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 962233858D37 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 962233858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713190782; cv=none; b=CO7Ahdfe2bBsu8ZJJHzkAfssX8iQ8MM9erzrfydhi3oDIFHtMMLys/EuCLgH8rsF4QycYI6bmCVsoLSbFBgr/aZdLEnDqayaml5sM4G/jSXnzAmZW17guVi2oJWW7R/INGC0ODkGVi2ve2rxoA9AI68gPFQECVpQPrA7XsBocnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713190782; c=relaxed/simple; bh=yVnpXMpqRqBlchfRAcwAaM/T/l/75x2M/NlwQLm3GgE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=XQk8IO4gcQ1myUBYiJPZxBQ266EANiUF/HuWKpuQwXcrP82AuD9ANp1Th66wTgx5hxsEWW0fwnOj+PgiMTCMIRT0ALbE7KLaKbSUia8hhjE56PHjslOMNLVC+cj6q9oV96h3ZU8u+Ag+zmFH1s8cKfuH/sjTeAhyCtRgltKFW7Y= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713190779; 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: in-reply-to:in-reply-to:references:references; bh=D80y33uN0Nw5r2LtQ4UtMjnNLwvLNybBzxtfw5BMlzE=; b=gFrSYT4etmFmRJL+WdHu8pKw5wOlw1MyRa8NrZSIlY1LqYN3wMM1nB2uHcSdBdrtC3LBJO L7Uotm6TiuclTbqItc0V+cM935yUZbFPGfM/EynHf+O6GazSwIpt6u4skwl6myMKtQexXm BPrywNfemRY2ShUbaplNSTPKxT6boxs= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-sAL05gEzNfmxPMGL7xSGkA-1; Mon, 15 Apr 2024 10:19:37 -0400 X-MC-Unique: sAL05gEzNfmxPMGL7xSGkA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-417de456340so16700385e9.2 for ; Mon, 15 Apr 2024 07:19:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713190776; x=1713795576; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D80y33uN0Nw5r2LtQ4UtMjnNLwvLNybBzxtfw5BMlzE=; b=n0VO0vFLSn3ymibQu5bTnwxQBH4xjiBbc6Rhcw+RjunrJpNdgQlHeX2r5/I4flO1iQ xKD3UZcKU0p/rERH+ZzVBkOJu3DJViR9lXtBDgVIZBT3h7plE9jtnlBno8OeMPwx5aiC KBzYHiMIRhrPKiHz224Dt6A2aARWhxrKRqOSUfLYsjJuRBfup37si4l8UtMSc33Vjb3h UDV5dtHpM/8uSiFp/d1dfR0lUITNnjr3sgETHdjVdW7+gWDUHKZgXanTWUeB4OVVoPyc vDrmsawj8Zv7nZaSb4PzxU/EH3x7cySlSUUmZXuEIb42RdeHAA8j/gwtAp+x+Ot1qv5A ewqA== X-Gm-Message-State: AOJu0YyccREM8ZkjN9Ncg2QMNX3dSD1afP1bSf/pwKc33lCNU5YDDMjB KCEy4b73sFo9pVfLKX3gDQpasHPPQSWc+TXUnaVB9HcewwXBxqMwIu501nZXOW+qkyJarrZmKqh knrlRKFe23DeC4x6RA66c3mzA+KjCcrDN98T8h6vgdCtogLat/i9XVs2ErGgIL8VVTRvO3/5tom OZvyj2jWYiNa8TZcVZXZOKqKTpsEjVBvgNk1fDrWHoeo0= X-Received: by 2002:a05:6000:92e:b0:343:44db:6153 with SMTP id cx14-20020a056000092e00b0034344db6153mr6560637wrb.42.1713190776151; Mon, 15 Apr 2024 07:19:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdhC925NfANW/YNknGI+OGettlupG12I70WJwR6Li3UWZ0mTBwZ6wpcfRQBJ/0swjJW19zLA== X-Received: by 2002:a05:6000:92e:b0:343:44db:6153 with SMTP id cx14-20020a056000092e00b0034344db6153mr6560622wrb.42.1713190775586; Mon, 15 Apr 2024 07:19:35 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id u8-20020a5d4348000000b00347c187a3a0sm3618856wrr.24.2024.04.15.07.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 07:19:34 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 3/3] gdb/record: minor clean, remove some unneeded arguments Date: Mon, 15 Apr 2024 15:19:28 +0100 Message-Id: <4f18fd17db2a5c6f39fa8b8587e3a5fe8fe75379.1713190701.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 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 I spotted that the two functions: record_full_open_1 record_full_core_open_1 both took two arguments, neither of which are used. I stumbled onto this while reviewing how filename_completer is used. The 'record full restore' command uses filename_completer and invokes the cmd_record_full_restore function. The cmd_record_full_restore function calls core_file_command and then record_full_open, which then calls one of the above functions. As 'record full restore' takes a filename, this is passed to cmd_record_full_restore, which forwards the filename to both core_file_command and record_full_open. However, record_full_open never actually uses the filename that is passed in. The record_full_open function is also used for 'target record-full'. I propose that record_full_open should no longer expect to see any user supplied arguments passed in (it doesn't use any). In fact, I've added a check that if we do get any user supplied arguments we'll throw an error. Now that we know record_full_open isn't being passed any user arguments we can stop passing the arguments to record_full_open_1 and record_full_core_open_1, this will make no user visible difference as these arguments were not used. It is possible that a user was previously doing: (gdb) target record-full blah blah blah And this previously would work fine, the 'blah blah blah' was ignored. Now this will give an error. Other than this case there should be no user visible changes after this commit. Reviewed-By: Eli Zaretskii --- gdb/NEWS | 4 ++++ gdb/record-full.c | 15 +++++++----- gdb/testsuite/gdb.base/record-full-error.exp | 24 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 gdb/testsuite/gdb.base/record-full-error.exp diff --git a/gdb/NEWS b/gdb/NEWS index feb3a37393a..942453c7064 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -36,6 +36,10 @@ set unwindonsignal on|off show unwindonsignal These commands are now aliases for the new set/show unwind-on-signal. +target record-full + This command now gives an error if any unexpected arguments are + found after the command. + * New commands info missing-debug-handler diff --git a/gdb/record-full.c b/gdb/record-full.c index 4c3667f48ba..4ef85b0cdb6 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -910,7 +910,7 @@ record_full_async_inferior_event_handler (gdb_client_data data) /* Open the process record target for 'core' files. */ static void -record_full_core_open_1 (const char *name, int from_tty) +record_full_core_open_1 () { regcache *regcache = get_thread_regcache (inferior_thread ()); int regnum = gdbarch_num_regs (regcache->arch ()); @@ -933,7 +933,7 @@ record_full_core_open_1 (const char *name, int from_tty) /* Open the process record target for 'live' processes. */ static void -record_full_open_1 (const char *name, int from_tty) +record_full_open_1 () { if (record_debug) gdb_printf (gdb_stdlog, "Process record: record_full_open_1\n"); @@ -957,11 +957,14 @@ static void record_full_init_record_breakpoints (void); /* Open the process record target. */ static void -record_full_open (const char *name, int from_tty) +record_full_open (const char *args, int from_tty) { if (record_debug) gdb_printf (gdb_stdlog, "Process record: record_full_open\n"); + if (args != nullptr) + error (_("trailing junk: '%s'"), args); + record_preopen (); /* Reset */ @@ -971,9 +974,9 @@ record_full_open (const char *name, int from_tty) record_full_list->next = NULL; if (current_program_space->core_bfd ()) - record_full_core_open_1 (name, from_tty); + record_full_core_open_1 (); else - record_full_open_1 (name, from_tty); + record_full_open_1 (); /* Register extra event sources in the event loop. */ record_full_async_inferior_event_token @@ -2520,7 +2523,7 @@ static void cmd_record_full_restore (const char *args, int from_tty) { core_file_command (args, from_tty); - record_full_open (args, from_tty); + record_full_open (nullptr, from_tty); } /* Save the execution log to a file. We use a modified elf corefile diff --git a/gdb/testsuite/gdb.base/record-full-error.exp b/gdb/testsuite/gdb.base/record-full-error.exp new file mode 100644 index 00000000000..63ef03dcc0e --- /dev/null +++ b/gdb/testsuite/gdb.base/record-full-error.exp @@ -0,0 +1,24 @@ +# This testcase is part of GDB, the GNU debugger. +# +# Copyright 2024 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check an error when passing unexpected arguments to 'target +# record-full'. + +gdb_start + +gdb_test "target record-full blah" \ + "trailing junk: 'blah'"