From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0DlmOo8TQ2jYaQMAWB0awg (envelope-from ) for ; Fri, 06 Jun 2025 12:13:03 -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=QY9647ii; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=kB6/wy2j; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E702E1E11C; Fri, 6 Jun 2025 12:13:03 -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 3AE201E0C2 for ; Fri, 6 Jun 2025 12:13:02 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BDE88385AC33 for ; Fri, 6 Jun 2025 16:13:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BDE88385AC33 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=QY9647ii; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=kB6/wy2j Received: from fout-b8-smtp.messagingengine.com (fout-b8-smtp.messagingengine.com [202.12.124.151]) by sourceware.org (Postfix) with ESMTPS id 5135A3858C50 for ; Fri, 6 Jun 2025 16:12:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5135A3858C50 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 5135A3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=202.12.124.151 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749226320; cv=none; b=ineA6ylMObS0l1gnwksEVNVKNawoCqxDl4HXBhi+cmQ1cxkcYQIpV6nsUTElS1m8ylQ2wwCp/pxXirfCdKKawwgibdJJBEQG0SZI5/ku5co4XM7nJb3LuQIIxSyY4NhC3oeVx+0yyBU1s4h64ObnauLIcHyv2KXAN7X16I1sXro= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749226320; c=relaxed/simple; bh=xW/qNBQEPTjJcT8b5Nv3bIwdq6Tbw7f6Vwosuw50LYw=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=wOXJLCmESY+Ku4snQaTaRSULZ4kovZVqn4o6ZO+V2FwDhDsZW05a4BATw3NGQzvbLjNiTkhT9Hey0YqviLwS1p2kilCmO5vVZ/ZBjjP79I4HG50qe3PrPk7LyLpFKAo5/5kAWiixeGqysmBR2UpuIMo1GwFhqZZZtbytr81MGc8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5135A3858C50 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id B5D141140096; Fri, 6 Jun 2025 12:11:59 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Fri, 06 Jun 2025 12:11:59 -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:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1749226319; x= 1749312719; bh=nigNS2emKchJ3H0/igQYi5bSYwSPJtMcxv1xGIufvKc=; b=Q Y9647ii57xkHXcNJEmyfg4o9ERdSuCBpolfJt8ZtCdzriIcF/P/GYX20PUZBKSFX ENWwjUNRCSNGdqjykvBZxzQCiAph6V3cZYTx8Ejj+AkJna4GSS74t3k9hW8Zdgxn E+aajNIagPNU1zkA8vYUIHtcxPSKrFRXVFPw4RxTjq3Cg1PWe+H515YFRi6Ow4oL VnDCuYwH0udcCRSfMdu1pqDATaUH3/YaYq0bw8FivHqRheGV3gOpFYpyrByLIZ12 4Q3/08Inc3/JxAcb+RVWJ1AWuVpJ3UY+LzfymYgsvEXX1BibkSBZRdaAKaCohEow ikQjSSWUJRkdx6Sd413QQ== 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:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1749226319; x=1749312719; bh=n igNS2emKchJ3H0/igQYi5bSYwSPJtMcxv1xGIufvKc=; b=kB6/wy2jZQEx+rITd ROticFF/w7KALfvB+e+ZrmSIbZs8rmi9CsjyhlcodBtUC6z4k0ZA7t3qqoR0MBxz FJE+HbhENeF1Q9griGCk76M1xyhHu/bOFtlBT8nIcpeVL8CFnCFLbSYC4nclRR3R UehFhrkkKcyRWrOievETwl3mP+0LFjblAnokWcdagyIx1a1DLWpzRY4CgFbskxR8 6gMVuvGhCEu+ZvurOtlAnVw/vDjm3QJmI//Ej/arvR9zXsWMaz8ZOtHZDQtaTpZx ZoM57RbX46Yo5Oki9e1BhVu91npNQcD5oOByPnghleQz5BjbkfONBUTAsv4iKdPU vC1XA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddugdehfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevuf ffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpedfmfgrrhhtihhkucfmrdcutehg rghrrghmfdcuoegrkhesrghkkhgrrhhtihhkrdgtohhmqeenucggtffrrghtthgvrhhnpe evkefgjeetueegteeiudeludetudelfeetjefhteejleelhfefjeelvdfhleethfenucff ohhmrghinhepshhouhhrtggvfigrrhgvrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheprghksegrkhhkrghrthhikhdrtghomhdpnhgs pghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghgusgdqph grthgthhgvshesshhouhhrtggvfigrrhgvrdhorhhgpdhrtghpthhtohepghhuihhnvghv vghrvgesrhgvughhrghtrdgtohhmpdhrtghpthhtoheprghksegrkhhkrghrthhikhdrtg homh X-ME-Proxy: Feedback-ID: id12946ff:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 6 Jun 2025 12:11:58 -0400 (EDT) From: "Kartik K. Agaram" To: gdb-patches@sourceware.org Cc: guinevere@redhat.com, "Kartik K. Agaram" Subject: [PATCH v4] gdb: redo whitespace-stripping from commands Date: Fri, 6 Jun 2025 09:10:15 -0700 Message-ID: <20250606161014.1367913-2-ak@akkartik.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250602233957.1130697-2-ak@akkartik.com> References: <20250602233957.1130697-2-ak@akkartik.com> 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' and 'complete' commands. Now I've added 'with' to that list of commands because it may contain one of those commands. To accomplish this, I'm fixing an ancient TODO to provide a per-command flag controlling whitespace-stripping. Any subcommands of 'with' besides 'complete' or 'set' will continue to strip whitespace as before, 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 Reviewed-By: Guinevere Larsen --- Changes for v4: * Ugh, removed a stray quote character from the commit description. 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 d812c493937..27e97d15938 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) { @@ -2717,8 +2711,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."), @@ -2741,6 +2737,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 25a2afe09c8..eacccd676f2 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