From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cGOdGuHRPWiNWz4AWB0awg (envelope-from ) for ; Mon, 02 Jun 2025 12:31:29 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GyRltWP0; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 537FB1E102; Mon, 2 Jun 2025 12:31:29 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A3A031E0C2 for ; Mon, 2 Jun 2025 12:31:27 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 112983857C5F for ; Mon, 2 Jun 2025 16:31:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 112983857C5F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GyRltWP0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 61FFF3858D20 for ; Mon, 2 Jun 2025 16:30:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 61FFF3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 61FFF3858D20 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=1748881854; cv=none; b=T+5sfwPaSKRv48N0C1xf/82cYAweUhadbY2JEEzyI8nkshpGQtfP4QBwH7hqRJCkv5qr9toG+DHEetunlDlwQCYb+qBBr8oAGWwQ3DxoUllGnFLMIeqG1FwTH1lCV9ciqCYH+dm6F4VBZJLbfHlVyvyJlu+NiQMl8lDKrQZ6RqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748881854; c=relaxed/simple; bh=+sHHkQ9TlaqTKSpgDCul0PgAEL2UT0/hTvLWfuFhVEY=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=XTyykwM49vXrc1ZokKEoQbvlPTfvn0CwfL1gIoajn4LKUXCsVZ6+hBB/fCCseUgSGmL/EM8pC/HhedF0HGMDhUlT7wEP3ERulYIa2g7yY7JQd647DoHM1JJrTE2NAeG4kJI3Qh0zcqoWe5goDD1QXGan7S68PfZr/T0ieHnFYbg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61FFF3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748881854; 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: in-reply-to:in-reply-to:references:references; bh=5Hf8LSzc5KrySzdD7FJufCdDIfa95sab+Zdojbd7wq8=; b=GyRltWP0NnYwdSp0ffo2Uq/UG3iIc2QyFGlxDWb7Nv52ENkUu0iECkrKpcagClPq+EqC1a A/CobH4A763eyeSJFOGn6P1ceMWakFGpWn+Fr+ntpezQy5M3EeOetnV+wOC/1NRqK+4twX hbQLEvxOUkPb/BXps0SOa0iGEdzD60M= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-5-CZdmEppEPy6vF-NTgjHxIQ-1; Mon, 02 Jun 2025 12:30:53 -0400 X-MC-Unique: CZdmEppEPy6vF-NTgjHxIQ-1 X-Mimecast-MFC-AGG-ID: CZdmEppEPy6vF-NTgjHxIQ_1748881853 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6fae0df0b35so22597456d6.3 for ; Mon, 02 Jun 2025 09:30:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748881852; x=1749486652; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5Hf8LSzc5KrySzdD7FJufCdDIfa95sab+Zdojbd7wq8=; b=gu2gc12DA/i1OHB7Runclf2mCkBByJ9+RIztB9BnJaiN08zM0m9iXbPINe6HgL5XNH bEwyzb1E/YIeYP6ru38xGaH3GJlAPkQgvbHa+4R69eNlOMinmT/u1nU3uN4T99n6Xtx1 t+PwXYJWETjGAS+7LN8fW03nDevN0DA/1EKb/QWazXBT45JhwGCdJIn2h5DIKv0D9HAp 19GUcmQmgPgLIXfddOsD5z5SP/gZDuYlbSa1aBVQa+YpPEgH6igZySGMAmhAOyHL5mnI pRlBMvjYssgziUWgsZMejYWrU7tqDI2r4lzKAR2CHnjgF5tvFHRIzoPUozxCqrZEXoPO rW5Q== X-Forwarded-Encrypted: i=1; AJvYcCVGHw4EBXBjczeuaYiq8MbEOva89LepktC9LiCYc0pcJCjFmOffU4XT7qFSw6kO71zpYJaJZchzuvNqzw==@sourceware.org X-Gm-Message-State: AOJu0YwjEwEMYzFmKtJvD4i5ggvDjpzcWmZD1ueO2Srpd8/hGNlGF+5Y rStOONdEfpvqTsNZibEfaEmMxjHm/1e0R9AKBmPpBGMj2KWK60XFbw59KOADyrcSOoxhaYo4bUy O/HLiG3KUXFtIqIbDbCFrJ/D215g5NNH0t7XfonifWn9ogu3SI0zmhYhHagKYjYL9A+/TSBU= X-Gm-Gg: ASbGnctuRgVwfO9Ihj2MiJsESo9l8Y05mB4E6e1Wt93og8olKI1qfEIW85sZx+FWVBE PnXwHohsGpmneA4SrTSovr2fKamwRVJTS2295Ba2za7KyVK8PLaAv1OLQa/MYMm012e5HmvJEQn OlIqfZVy1RHOzaLGPRFBu1joRN0DgWQAbMWUwWcdXDAnnRtvrR9Ij6NQr6/aWAcCPrRwbqfJ1QZ Q4x9wgkUtam4KEujX8diQ8pN4+6+DVb9L9azBlw7ZtxD9OuNFekIpZVbyVj8arkHNVefY3bzazz J5UK3ieZPo0U3NEkZ0Sad2k= X-Received: by 2002:a05:6214:2583:b0:6fa:c81a:620b with SMTP id 6a1803df08f44-6fad1a79653mr193024276d6.20.1748881852029; Mon, 02 Jun 2025 09:30:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxsNN2F7io+gjPuyyVXtgC/5cKRruEEgq0RbZd1fDRzqI3VCbMgbNB2DREgX7m32ktkWn3Ww== X-Received: by 2002:a05:6214:2583:b0:6fa:c81a:620b with SMTP id 6a1803df08f44-6fad1a79653mr193023696d6.20.1748881851522; Mon, 02 Jun 2025 09:30:51 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:9a69::1000? ([2804:14d:8084:9a69::1000]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6fac6d5b04asm62884116d6.51.2025.06.02.09.30.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Jun 2025 09:30:50 -0700 (PDT) Message-ID: Date: Mon, 2 Jun 2025 13:30:48 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb: redo whitespace-stripping from commands To: "Kartik K. Agaram" , gdb-patches@sourceware.org References: <20250529125138.1118538-1-ak@akkartik.com> <20250601011941.204158-1-ak@akkartik.com> <20250601011941.204158-2-ak@akkartik.com> From: Guinevere Larsen In-Reply-To: <20250601011941.204158-2-ak@akkartik.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Wg5M2K2dIus6uoe6Euk1RKLKlr3I3yeA9slfRmYoXgA_1748881853 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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~public-inbox=simark.ca@sourceware.org Hi Kartik! I have one minor wording suggestion in the commit message, but otherwise I think this change is great! On 5/31/25 10:17 PM, Kartik K. Agaram wrote: > Before this patch, trailing whitespace was not stripped from 'set' and > 'complete' commands. Now I've added 'with' commands to that list because > they contain a 'complete' subcommand. To accomplish this, I'm fixing an I'd word it as "I've added 'with' to that list of commands because it may contain one of those commands". Feel free to add my review trailer to the end of your commit message, and I hope this gets approved by a global maintainer soon! Reviewed-By: Guinevere Larsen -- Cheers, Guinevere Larsen She/Her/Hers > ancient TODO to provide a per-command flag controlling > whitespace-stripping. > > Any subcommands of 'with' besides 'complete' or 'set' will continue to > work because they go through a recursive call to execute_command. The > outer call for 'with' won't strip whitespace, then the recursive call > will. > > I've also cleaned up 2 obsolete TODOs and NOTEs in related code. > > Tested on x86_64-linux. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29784 > --- > gdb/cli/cli-cmds.c | 11 ++++------- > gdb/cli/cli-cmds.h | 4 ---- > gdb/cli/cli-decode.c | 1 + > gdb/cli/cli-decode.h | 8 ++++---- > gdb/top.c | 12 +----------- > 5 files changed, 10 insertions(+), 26 deletions(-) > > diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c > index 9a5021f9d08..f2d6d576cb8 100644 > --- a/gdb/cli/cli-cmds.c > +++ b/gdb/cli/cli-cmds.c > @@ -427,12 +427,6 @@ complete_command (const char *arg, int from_tty) > } > } > > -int > -is_complete_command (struct cmd_list_element *c) > -{ > - return cmd_simple_func_eq (c, complete_command); > -} > - > static void > show_version (const char *args, int from_tty) > { > @@ -2702,8 +2696,10 @@ Generic command for showing things about the program being debugged."), > add_com_alias ("i", info_cmd, class_info, 1); > add_com_alias ("inf", info_cmd, class_info, 1); > > - add_com ("complete", class_obscure, complete_command, > + cmd_list_element *complete_cmd > + = add_com ("complete", class_obscure, complete_command, > _("List the completions for the rest of the line as a command.")); > + complete_cmd->strip_trailing_white_space_p = false; > > c = add_show_prefix_cmd ("show", class_info, _("\ > Generic command for showing things about the debugger."), > @@ -2726,6 +2722,7 @@ E.g.:\n\ > You can change multiple settings using nested with, and use\n\ > abbreviations for commands and/or values. E.g.:\n\ > w la p -- w p el u -- p obj")); > + with_cmd->strip_trailing_white_space_p = false; > set_cmd_completer_handle_brkchars (with_cmd, with_command_completer); > add_com_alias ("w", with_cmd, class_vars, 1); > > diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h > index 33d13fb8563..c3004a8e857 100644 > --- a/gdb/cli/cli-cmds.h > +++ b/gdb/cli/cli-cmds.h > @@ -149,10 +149,6 @@ extern struct cmd_list_element *showsourcelist; > > extern unsigned int max_user_call_depth; > > -/* Exported to gdb/top.c */ > - > -int is_complete_command (struct cmd_list_element *cmd); > - > /* Exported to gdb/main.c */ > > extern void cd_command (const char *, int); > diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c > index 48a34667c37..782d38f781f 100644 > --- a/gdb/cli/cli-decode.c > +++ b/gdb/cli/cli-decode.c > @@ -582,6 +582,7 @@ add_setshow_cmd_full_erased (const char *name, > extra_literals, args, > full_set_doc.release (), set_list); > set->doc_allocated = 1; > + set->strip_trailing_white_space_p = false; > > if (set_func != NULL) > set->func = set_func; > diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h > index 9be446fb641..d3d512adcd4 100644 > --- a/gdb/cli/cli-decode.h > +++ b/gdb/cli/cli-decode.h > @@ -60,6 +60,7 @@ struct cmd_list_element > allow_unknown (0), > abbrev_flag (0), > type (not_set_cmd), > + strip_trailing_white_space_p (true), > doc (doc_) > { > gdb_assert (name != nullptr); > @@ -175,11 +176,10 @@ struct cmd_list_element > or "show"). */ > ENUM_BITFIELD (cmd_types) type : 2; > > + bool strip_trailing_white_space_p; > + > /* Function definition of this command. NULL for command class > - names and for help topics that are not really commands. NOTE: > - cagney/2002-02-02: This function signature is evolving. For > - the moment suggest sticking with either set_cmd_cfunc() or > - set_cmd_sfunc(). */ > + names and for help topics that are not really commands. */ > cmd_func_ftype *func; > > /* The command's real callback. At present func() bounces through > diff --git a/gdb/top.c b/gdb/top.c > index 6adef467b90..8a1e586b4c1 100644 > --- a/gdb/top.c > +++ b/gdb/top.c > @@ -503,20 +503,10 @@ execute_command (const char *p, int from_tty) > arg = *p == '\0' ? nullptr : p; > } > > - /* FIXME: cagney/2002-02-02: The c->type test is pretty dodgy > - while the is_complete_command(cfunc) test is just plain > - bogus. They should both be replaced by a test of the form > - c->strip_trailing_white_space_p. */ > - /* NOTE: cagney/2002-02-02: The function.cfunc in the below > - can't be replaced with func. This is because it is the > - cfunc, and not the func, that has the value that the > - is_complete_command hack is testing for. */ > /* Clear off trailing whitespace, except for set and complete > command. */ > std::string without_whitespace; > - if (arg > - && c->type != set_cmd > - && !is_complete_command (c)) > + if (arg && c->strip_trailing_white_space_p) > { > const char *old_end = arg + strlen (arg) - 1; > p = old_end;