From patchwork Mon Apr 15 14:19:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 88491 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 6ADFC3858C62 for ; Mon, 15 Apr 2024 14:20:07 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id A38883858D32 for ; Mon, 15 Apr 2024 14:19:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A38883858D32 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 A38883858D32 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=1713190781; cv=none; b=dscSEVS0ache8MYqMeOOf/G18VcNTHfWJkotzWlg5iklG5PMeDUbr+UDPSCH/MiR67S9MEuUGnyp7vhtv+NxtuZsXPDZCHm0NTpzlxH94N6EHCVFV+WojNHFlD+Kxd9DT9pCatky0Ghk+ZlOK4KZ2uYx5uuYqfljmLb0GwR/mbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713190781; c=relaxed/simple; bh=txuy2klL5LENHOlVAFAtGXqftSaiaNiJhs0vo7vYJGU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=w+sNVfcJvAZSIhJvl3QgJu7aSoZCm3G1vlSiSAm9A35Z7qDcMaK/tBgapZ+r415FLYKwJ/k3hz7uEVIh+dAeY7V/XKjvz//HXqtZshir3M9S6KtiynewA388YOdWwAGq1rCylh9EORsWWgcojodsCAK6zKTRyi5H5CSq48h4a2M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713190776; 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=K9nSQhMv3gI4inVxbm3Jbh7g7aL3VcsQlsxzAEogU0E=; b=B1+fW7v+ffHGk9kJs7+o59VuLGLUDtmtZcAg+5x79MOJWXILnTecicJcMk2NLymJhCp1nO I6pViZrodPEvHkOEl6N3btJuQ8hpI2NEUemoyOctC6Fhz/rD23PhCS9DeCo/KezBBzJ/Wl FXpkb83YGWYhmLWfTM7oQQUMPm/Fe0s= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-uD5xUG7gN4GvqdTuGTY4XQ-1; Mon, 15 Apr 2024 10:19:34 -0400 X-MC-Unique: uD5xUG7gN4GvqdTuGTY4XQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-343cd240b2dso2200739f8f.2 for ; Mon, 15 Apr 2024 07:19:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713190772; x=1713795572; 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=K9nSQhMv3gI4inVxbm3Jbh7g7aL3VcsQlsxzAEogU0E=; b=xGXSWpyd5ditd0TwMTgByBM6nu34eX7aec/5G8+lomYUgtOrGZwOgOnaXASw8Jhzoc WyAFeCYqyOMJSytda5oXaEir9Ps3dnai0YgAbJygitnTAtOoI9vYOS9IJErXrWUj2LmD 8ez/V6s157+UYOL6zj1tXFIUXStwJTCNrQEo/mDASXDVaEBhHzoiwQgwCO2F2DIkhoqF y5yFbtR2gkGfTJDeCcL1/Zp+wEGdO3fxXrnk1MkMomvpPykTPutJxAMODAFWWJiX747g RF11ZKI1AD0/5G3ljqqTJ3EUQSzo/+EzLr3/DU8j35qRorefiQHFZSxHTH+2fXRhskGw AapA== X-Gm-Message-State: AOJu0Yxex/h9PNFpYoUHniDFBcgDZYa9hHo8BLsi9dg1QfMuPHCK9/pX jl9kCYp8Sg3fMoWrHCQjXn24VTo1kLGKTmMwdiCtlYrCLHHP3LV//40TNS4tlAfG6TV5nd4YEBP /+RtYST0ooqqlUm/d64QQ8cA0FxEEvGt1HV0Mxlndc6ElRhwwxFfJHG+sdJk6loF9pvuEINz/0E TfTPHFdjVmR6D+vlnoVANEoPYBGXN5mIeT16aAtMChkhI= X-Received: by 2002:adf:ef0a:0:b0:33e:7c9a:9368 with SMTP id e10-20020adfef0a000000b0033e7c9a9368mr5538026wro.63.1713190772315; Mon, 15 Apr 2024 07:19:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQSp4GPxBxmz9CwVftyFBWHDyHRVPhPBOfFt7GohIX3QZbLZL6NbaZOswnAMJd1/lKrZGeWA== X-Received: by 2002:adf:ef0a:0:b0:33e:7c9a:9368 with SMTP id e10-20020adfef0a000000b0033e7c9a9368mr5538008wro.63.1713190771736; Mon, 15 Apr 2024 07:19:31 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id x13-20020a5d60cd000000b0033e7b05edf3sm12269478wrt.44.2024.04.15.07.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 07:19:31 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/3] gdb/record: remove unnecessary use of filename_completer Date: Mon, 15 Apr 2024 15:19:26 +0100 Message-Id: <754ab2b77ccc626c0d9684fced83bfd514a5b836.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, 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 Spotted that the 'record' command has its completer set to filename_completer. The problem is that 'record' is a prefix command, as such, its completer is hard-coded to complete on sub-commands. The attempt to use filename_completer is irrelevant. The 'record' command is itself a command though, that is, a user can do this: (gdb) record which is really just an alias for: (gdb) target record-full Nowhere does cmd_record_start (which is called when 'record' is used) expect a filename, and 'target record-full' doesn't expect a filename either. So lets just drop the line which sets filename_completer as the completer for 'record'. --- gdb/record.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/gdb/record.c b/gdb/record.c index 1843969c2c9..25a4c1e71b6 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -791,8 +791,6 @@ A size of \"unlimited\" means unlimited lines. The default is 10."), = add_prefix_cmd ("record", class_obscure, cmd_record_start, _("Start recording."), &record_cmdlist, 0, &cmdlist); - set_cmd_completer (record_cmd, filename_completer); - add_com_alias ("rec", record_cmd, class_obscure, 1); set_show_commands setshow_record_cmds From patchwork Mon Apr 15 14:19:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 88493 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 81F6E3858C50 for ; Mon, 15 Apr 2024 14:20:14 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id F04963858D34 for ; Mon, 15 Apr 2024 14:19:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F04963858D34 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 F04963858D34 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=1713190785; cv=none; b=eSSYgJ+X0YIHvWKOQEqyg7e0u9JX7ddeQV6ghKtWndFg+1tovovZl795cmJud9RIdY5AJQeucINcQIQkmhpHQ5k3CN8OkJAYzVQnoXfGOfoamUudS9U/P3v8bAapq4arH90owMzCRUY2MtKi1u9xHpgElBdAgez5+TAn3B1bTNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713190785; c=relaxed/simple; bh=xZh+7Zpzo6DBetCSf2puwk5jlY5QDCgd/D60eL7bg34=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Sb2kpZ9bQyV91bwC0fKnih8YLq3uDC8QolLt7io/owEhRwg/JHKmLN0L7+ZnJ9mItgfUnCVu/RMwS5r5dIqZtsQthK8G6Wf/sWdB9wk40Np9qSjtfsWaE7zpyCeXuGt4FMAkSzJFlIdnCxIhgVX6d8D73+gmWaQJXZ8R9Wp8muE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713190778; 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=Qmrm/NDjmXB1O7ewTWqNB1ZCGSbfgNTP+oifzQf3Tkg=; b=iIVDgxnTvd2kms2Tbx96sXHq6L4SKKvdaJZYlNgp7nWBS0SepFZKYotvbL4HWZmhfNR0SI cY1dbk6RXT/YqlREPETpFs0fqXktpWhWj5Fg+sairdsFrgggge9zKQxi5F+knmm9Fmfh3q Jta2RkwsCtwUQPaOO6wVvpVwY0e4qM8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-BEn73pVOPxiG9mePtpbl0w-1; Mon, 15 Apr 2024 10:19:36 -0400 X-MC-Unique: BEn73pVOPxiG9mePtpbl0w-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4187293b96fso2984985e9.0 for ; Mon, 15 Apr 2024 07:19:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713190774; x=1713795574; 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=Qmrm/NDjmXB1O7ewTWqNB1ZCGSbfgNTP+oifzQf3Tkg=; b=P274d60mkLmuLMZQ76T9uoMc8evXizybnBrfYyL7NhXpxDVDIDSyfxNi9VKfErRUT2 P4wi35pIFOYykoYZa+drMOStQJpdEyGAOhm1xzqkPIyWJm0nx5MVkdXfGSNAlpeNNh0I m0ksqi1E4bWidB5zsTqQUuKlPXVNNkhLaGxl5eYtxEWNr3Z5RILMnkIWwXFbYTqjXpvX kWW2icxaCoHBY6o7qcNtwYfnF/I6/BQG7AGdGiu6tJ156zoi1zkGooc4/ZtWRWu9sfBY yYCMFfEZdBs6yJ5b17O4wLBqYXFwdKs9IJQuckGUx3vH3TicVpkohiTTMShix3v4yqYT gjPA== X-Gm-Message-State: AOJu0YwRWd9JWaMVOz1CpFFwg+nbZBoxtgIIgmY/jeD+17CXJyGw+zFF xqjmDj25/12UR/rZ33rw9EI9JPebauDdhxDLdXFo82a4kFcFP3Q+MDqFHp0PiTtD1/DRDUZK6bs D2mUJHG8IlblRvXuSbOgpQuISwHwA7CeQvfxie1wyn2Sw0Q2mnhhXZFqBGAM+lDN12mccA/S+M9 kwhlZKndnz2cnU9jtzkdMSiSzF6n5pgusmk4cAoxVMJtw= X-Received: by 2002:a05:600c:3d9b:b0:418:7c47:32c9 with SMTP id bi27-20020a05600c3d9b00b004187c4732c9mr749226wmb.29.1713190774190; Mon, 15 Apr 2024 07:19:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAKYPWOBTiQzJyTMQKRrsZS8B0pDoaCfVogw4DYK91Z4PQeaG5J1a61RdQXiQ283dfcNUXRA== X-Received: by 2002:a05:600c:3d9b:b0:418:7c47:32c9 with SMTP id bi27-20020a05600c3d9b00b004187c4732c9mr749203wmb.29.1713190773597; Mon, 15 Apr 2024 07:19:33 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id h6-20020a05600c350600b004163321790esm16354291wmq.19.2024.04.15.07.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 07:19:32 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/3] gdb/record: add an assert in cmd_record_start Date: Mon, 15 Apr 2024 15:19:27 +0100 Message-Id: <483ec76476d7b95641fa486c65249ce62d8690ca.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, 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 The 'record' command is both a prefix command AND an alias for 'target record-full'. As it is a prefix command, if a user types: (gdb) record blah Then GDB will look for, and try to invoke the 'blah' sub-command. This will either succeed (if blah is found) or throw an error (if blah is not found). As such, the only way to invoke the 'record' command is like: (gdb) record It is impossible to pass arguments to the 'record' command. As we know this is true then we can assert this in cmd_record_start. I added this assert because initially I was going to try forwarding ARGS from cmd_record_start to the 'target record-full' command, but then I realised passing arguments to 'record' was impossible. There should be no user visible changes after this commit. --- gdb/record.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/record.c b/gdb/record.c index 25a4c1e71b6..5b1093dd12e 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -260,11 +260,16 @@ show_record_debug (struct ui_file *file, int from_tty, value); } -/* Alias for "target record". */ +/* Alias for "target record-full". */ static void cmd_record_start (const char *args, int from_tty) { + /* As 'record' is a prefix command then if the user types 'record blah' + GDB will search for the 'blah' sub-command and either run that instead + of calling this function, or throw an error if 'blah' doesn't exist. + As a result, we only get here if no args are given. */ + gdb_assert (args == nullptr); execute_command ("target record-full", from_tty); } 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'"