From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id a/L/IaxYOGjRSzkAWB0awg (envelope-from ) for ; Thu, 29 May 2025 08:53:00 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=akkartik.com header.i=@akkartik.com header.a=rsa-sha256 header.s=fm2 header.b=kpCQf1xn; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=MKNDzvrY; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 752481E11C; Thu, 29 May 2025 08:53:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,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 362731E100 for ; Thu, 29 May 2025 08:52:59 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C2F203858C54 for ; Thu, 29 May 2025 12:52:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2F203858C54 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=akkartik.com header.i=@akkartik.com header.a=rsa-sha256 header.s=fm2 header.b=kpCQf1xn; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=MKNDzvrY Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) by sourceware.org (Postfix) with ESMTPS id 75D4A3857C5F for ; Thu, 29 May 2025 12:52:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75D4A3857C5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=akkartik.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=akkartik.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 75D4A3857C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748523125; cv=none; b=E8q95YHglj5dSq6YJnwxp8zmoh9qmxu2gmaXJmFzeNfer8Te9m/yDlg/LT0JDtIEX0D2OjB4ygSoIjT1OtXkQWNefQ1g+FM6UolF2xOztJOxixNbqhlaBxdZSj5ubSkMIlCPr3V4jJDonOLSzo2W3/t+jYdRfBeJd4ojDooTA5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748523125; c=relaxed/simple; bh=iz7RTUyeQysn3lTZIOLqZiqnxcnDNOnk5jcB4Jvbwbw=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=PuIFJXYQnv2WizG86nt7yqfyEnxuxFYz4+fhz92C/eQeE1v91l/G7FfY+HM4+jYoHB/vAkVUuM23Hn9ZJkdoUUsK0obzFa2B6J2b9Q1J1C+8xGsJy4FGYD4Y0PhVRsvg8baVFu4DxlYN7hEtXzBq1wnkiiFi9FFcEGZJKeO4sy4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75D4A3857C5F Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id F370C114011E; Thu, 29 May 2025 08:52:04 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Thu, 29 May 2025 08:52:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkartik.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to; s=fm2; t=1748523124; x=1748609524; bh=hkdAepXUOwnj4ziGscQBL 7xMR+5SJGDS+VH3xmK73/8=; b=kpCQf1xnbHhaXWoKLNkHAu29rubIYhHBzjdI4 HHb95L4fcPtTEKH2kSS4vd+9onx2LWx+lCpu6CMQfRhqmOzom3/4LLA7Payz6ZU4 qXmadxja9p7nZHyDNw2+/7UP4uIeZHb1sNCd/QZ0u+9kC/7Um6vLGnNurnSdUOcV RjhIQf6Iz+O0/w2EZkceLiRGqxXHQ+sDfI7ecEShoj6HceXBF0URXwRExiZOPSx/ x7piEdeuGQRknMSj8v2meFZ7mPOfxdLr6OxnHltl5mgVkFhcMEGmFMP8csP+g5OE 7HQrswK2C5xDCbXChjvx3QSXdttggfnH8Be4bKTIzx3pCJ/1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1748523124; x=1748609524; bh=hkdAepXUOwnj4ziGscQBL7xMR+5SJGDS+VH 3xmK73/8=; b=MKNDzvrYyBvMd1vetojDLLty5J4MnigvaZLImAj6960Jslb39yF dJS9e9ZECnZofsRL1lr73DJL7npSa3fQaVghvy2PUyb4ul1IgFkX+H9j/qQ+May9 N13FOWwrTbg6cTU4WXJiN/SOHlPKvgtywn64jZ41vLRaE7F2GuDoIkjdRkYTlRqr 2IUgzhcfgCQIlB3zKqlrvsQTRIoi3CADoWD+zisGqGR4JTrIZrJK1F6zpiU+qiu6 F8lliu1XuqUHVJhrrm2qOBLVl42nHhmXQqnViIDF8wSMwQzsUu7wku7aFJxx0v5c gDU7FXdhl6nhZ0MCyGUsX4GuNhK2OTBNOBg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddtgddviedujeculddtuddrgeefvddrtd dtmdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggft fghnshhusghstghrihgsvgdpuffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftd dtnecunecujfgurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomhepfdfm rghrthhikhcumfdrucetghgrrhgrmhdfuceorghksegrkhhkrghrthhikhdrtghomheqne cuggftrfgrthhtvghrnhepledtjeffudeuleehheefhedvjefhuddvieeujeeutdfftefg leefleeglefhfeevnecuffhomhgrihhnpehsohhurhgtvgifrghrvgdrohhrghenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrkhesrghkkhgr rhhtihhkrdgtohhmpdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprh gtphhtthhopehguggsqdhprghttghhvghssehsohhurhgtvgifrghrvgdrohhrghdprhgt phhtthhopehguhhinhgvvhgvrhgvsehrvgguhhgrthdrtghomhdprhgtphhtthhopegrkh esrghkkhgrrhhtihhkrdgtohhm X-ME-Proxy: Feedback-ID: id12946ff:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 May 2025 08:52:03 -0400 (EDT) From: "Kartik K. Agaram" To: gdb-patches@sourceware.org Cc: guinevere@redhat.com, "Kartik K. Agaram" Subject: [PATCH] RFC: gdb: redo whitespace-stripping from commands Date: Thu, 29 May 2025 05:51:38 -0700 Message-ID: <20250529125138.1118538-1-ak@akkartik.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Before this patch, trailing whitespace was not stripped: - from 'set'/'show' commands - from 'complete' commands Now I've added the 'with' commands to that list because it contains a 'complete' subcommand. To accomplish this, I'm trying to fix a TODO to provide a per-command flag controlling whitespace-stripping. I've also cleaned up some seemingly TODOs that are either fixed by this patch or obsolete. Open question: This patch stops stripping trailing whitespace from all 'with' commands. Might that create issues with other 'with' commands besides 'with ... -- complete'? Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29784 --- gdb/cli/cli-cmds.c | 12 +++++------- gdb/cli/cli-cmds.h | 4 ---- gdb/cli/cli-decode.h | 8 ++++---- gdb/top.c | 12 +----------- 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 9a5021f9d08..2cb7471dda8 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,14 +2696,17 @@ 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 = 0; c = add_show_prefix_cmd ("show", class_info, _("\ Generic command for showing things about the debugger."), &showlist, 0, &cmdlist); /* Another way to get at the same thing. */ add_alias_cmd ("set", c, class_info, 0, &infolist); + c->strip_trailing_white_space_p = 0; cmd_list_element *with_cmd = add_com ("with", class_vars, with_command, _("\ @@ -2726,6 +2723,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 = 0; 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.h b/gdb/cli/cli-decode.h index 9be446fb641..f794e3c45f6 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 (1), doc (doc_) { gdb_assert (name != nullptr); @@ -175,11 +176,10 @@ struct cmd_list_element or "show"). */ ENUM_BITFIELD (cmd_types) type : 2; + unsigned int strip_trailing_white_space_p : 1; + /* 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; -- 2.49.0