From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yJ0BKj6MSWiiqgkAWB0awg (envelope-from ) for ; Wed, 11 Jun 2025 10:01:34 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Rb2A38cI; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A6BB51E11F; Wed, 11 Jun 2025 10:01:34 -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 D18FD1E089 for ; Wed, 11 Jun 2025 10:01:33 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 706AE3858C98 for ; Wed, 11 Jun 2025 14:01:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 706AE3858C98 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Rb2A38cI Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id E36AD385840F for ; Wed, 11 Jun 2025 13:58:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E36AD385840F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E36AD385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749650338; cv=none; b=WBru/FD3F6ovLCx3czwjXmz2afdDf+4p1hYvCmHWhtc45BQDnOEL5oTP9Wu4poT2zNKCxes6An5aMY0/aLZlw2JPGAf57GGzcxPytzzLfsdczO42u/07RapbPzt17YPpwmp7GECYXDu1/r1SlL3SlmCa3o8DhFComYdv+VzcCkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749650338; c=relaxed/simple; bh=XtSFW4htCk7zEaE9j5UZ/MH9bm39TgCxVO0ZARTMbhg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=QNyISXM7rb5ZIuBOzR3NO0/FL1oId+tWzEopLE8uTf9tU6zEXzfIU5XMrnUGPY3fD3Sp1yO29C2MbKXtPTS1YgTXZKYR7GsYAafJAmJg6EZExr2YaL62fWnz4lrNGiIxK664hXRY9fai0lrC8xgAxIlyHuF3cp2ghwo9paBFgjk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E36AD385840F Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-72c27166ab3so4718778a34.1 for ; Wed, 11 Jun 2025 06:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1749650337; x=1750255137; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ntNYMM4nmBxh15p18WbgJPOxwfvhuLv8CD8RvTzYC1Q=; b=Rb2A38cIBq7sW7kbJdrJad0p6hVBXvpOPzf/K0YtIpCY6jjLm7s8p3qJpX170sVO/+ EaV2Q490dNNE9A2iktXQSQYoNF0W2NuOBpxD223mpJ6ISeHKKkG5rDaUJef3oys/zT9v 6zSkfTR8Senw3sHYyyW0++laYzRaXncVMwpYvtvSSdGOFi4HB/HkMRIRHgDgtd4Gr8Y8 UBvqU/3PEtl1gjnMSWBVWmD5il8WyfF6vSUt0szggNBZHiyLwHyUS4+qlSe0Ehiq5/sw 7kvNUVsfovglOq/ihIQLFT7lEqnCt1l3xbIsVXWkDiYOkzGMaecP0vIGtvx+AYB1bscN Vwgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749650337; x=1750255137; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ntNYMM4nmBxh15p18WbgJPOxwfvhuLv8CD8RvTzYC1Q=; b=Nccd4Go6QO+TAhYKShJzmEX0JB2vCX/dwtQEGFXcMHkIOD2yMI0rHIaB4ZH5MZkT5b EnrGVg8MeFriDbrz3ayDE6fzkFAEmOCPYYX2HxIS4sPKhM7P09SGlE3KBz0cfWEyxvb8 3P8rMN1vpwWHYzu/0RJ2kHPWSvtEgS9RJd++B0yXQP4MCuCiS391XkjqipUHkjvbeB2c n3lEQ7oeZCxrwaEdRbA39RvpWr87A2EZ43MwqSIvdTPTYGz/5gVUcJh1m3nsp8M3cJXI m8oM2SzkqAR91mj/FacsedQ8Ih4eSGFaZz5BjA4v8LY0g77pDh5TrEV3Co/YubG7iYeg Z+Kw== X-Gm-Message-State: AOJu0YzIln8lvsRwSIfkzszvsSAmG6V0zgigPgsX0KDL9Fpi89vR68bI 0PW8fnie7Brf9r7uxzWxFTVVFewlW1s1Cpozsgx92ILWijLOnwQ0mexKtfTh4E26x+YZfRXfV0k 5WbQJ6lv9 X-Gm-Gg: ASbGncubWYNzJIjG2IJTo50uXjRieJ9o3B7ma81WqflPA1+7IUtj21COmr21c497jEe qfKJS+k/IvxcvY5aq3brFEFQSCmwvVtKsjmpUVRg/GWhVJfqZUyd7nSqJal8BvkZyJRSanVkEgw BED+pdhyI97bZKMGfS5nHnGDykLlvZ4/JbwV2aKKcAx3bEBHqe7M5a2a61o+ZtjaBksBxXm1U7M JZ/rdzgbP6/G33Z1XDHGXxHC69rFjc3ilMB7s8gWDp7nZn50PSTMNZ6aK68NHg9dX4DAcL6g9Km feQBTaMIpYzI5PbiFw196Y7/sv1MWfP5Pe9PtirSx3zr8Dj6lIHB82b+iEH/U9rP8+KAL4eAhC7 rYYZIWNoq41bEyytnjh0= X-Google-Smtp-Source: AGHT+IFrDeNMyuhSUkYD0MkhvJ/rKZMh2D2ItAfpUN+eAX3ACbr9gneY9kBGh3dxiabcPmZsl+U/wA== X-Received: by 2002:a05:6602:3f0d:b0:875:abe0:f8e9 with SMTP id ca18e2360f4ac-875bcbffe14mr363299339f.1.1749650326659; Wed, 11 Jun 2025 06:58:46 -0700 (PDT) Received: from [192.168.0.26] (75-166-228-225.hlrn.qwest.net. [75.166.228.225]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-875bc5b72b6sm40713139f.16.2025.06.11.06.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jun 2025 06:58:46 -0700 (PDT) From: Tom Tromey Date: Wed, 11 Jun 2025 07:58:43 -0600 Subject: [PATCH v2 1/2] Introduce ui_out::field_check_mark MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250611-emoji-check-mark-v2-1-d299ec101650@adacore.com> References: <20250611-emoji-check-mark-v2-0-d299ec101650@adacore.com> In-Reply-To: <20250611-emoji-check-mark-v2-0-d299ec101650@adacore.com> To: gdb-patches@sourceware.org Cc: Tom Tromey , Kevin Buettner X-Mailer: b4 0.14.2 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 This adds a new ui_out method, field_check_mark. This method is to be used to indicate the "current" or "selected" row in a table. This patch updates all the relevant tables to call this method. No change should be expected. Approved-by: Kevin Buettner --- gdb/ada-tasks.c | 5 +---- gdb/inferior.c | 6 +----- gdb/linux-fork.c | 5 +---- gdb/progspace.c | 6 +----- gdb/target-connection.c | 6 ++---- gdb/thread.c | 6 +----- gdb/ui-out.c | 9 +++++++++ gdb/ui-out.h | 13 +++++++++++++ 8 files changed, 29 insertions(+), 27 deletions(-) diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 259512377f085423d4feda1a8a67e409109179a2..2f152ec3581f1076110df2ca149a2add5a825e9e 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -1163,10 +1163,7 @@ print_ada_task_info (struct ui_out *uiout, /* Print a star if this task is the current task (or the task currently selected). */ - if (task_info->ptid == inferior_ptid) - uiout->field_string ("current", "*"); - else - uiout->field_skip ("current"); + uiout->field_check_mark ("current", task_info->ptid == inferior_ptid); /* Print the task number. */ uiout->field_signed ("id", taskno); diff --git a/gdb/inferior.c b/gdb/inferior.c index e8a28cd2a0e1a4f76946d4fc9c1abdfab08b5d3e..221dbce73d6721f5ed883745c0474e78d94c405d 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -598,11 +598,7 @@ print_inferior (struct ui_out *uiout, const char *requested_inferiors) ui_out_emit_tuple tuple_emitter (uiout, NULL); - if (inf == current_inf) - uiout->field_string ("current", "*"); - else - uiout->field_skip ("current"); - + uiout->field_check_mark ("current", inf == current_inf); uiout->field_signed ("number", inf->num); /* Because target_pid_to_str uses the current inferior, diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index 338ba032a0e75862d449b9c02c3c61cfc5492dbe..dc50391b22a0ba2d5728d7ae5a4505a73d864fd9 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -849,10 +849,7 @@ print_checkpoints (struct ui_out *uiout, inferior *req_inf, fork_info *req_fi) ui_out_emit_tuple tuple_emitter (uiout, nullptr); - if (is_current && cur_inf == inf) - uiout->field_string ("current", "*"); - else - uiout->field_skip ("current"); + uiout->field_check_mark ("current", is_current && cur_inf == inf); if (print_inf) uiout->field_fmt ("id", "%d.%d", inf->num, fi.num); diff --git a/gdb/progspace.c b/gdb/progspace.c index 1c27165743738f59d21f8f57e7f758206d85e210..0d543a1f197b3c1c039a2db0449295f8e7c46be7 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -304,11 +304,7 @@ print_program_space (struct ui_out *uiout, int requested) ui_out_emit_tuple tuple_emitter (uiout, NULL); - if (pspace == current_program_space) - uiout->field_string ("current", "*"); - else - uiout->field_skip ("current"); - + uiout->field_check_mark ("current", pspace == current_program_space); uiout->field_signed ("id", pspace->num); if (pspace->exec_filename () != nullptr) diff --git a/gdb/target-connection.c b/gdb/target-connection.c index 60d7732b56e465ac6fda1164846302e1b9167456..69e5765959ef6bf0bfbc2fb482f5a26fa1a03c79 100644 --- a/gdb/target-connection.c +++ b/gdb/target-connection.c @@ -126,10 +126,8 @@ print_connection (struct ui_out *uiout, const char *requested_connections) ui_out_emit_tuple tuple_emitter (uiout, NULL); - if (current_inferior ()->process_target () == t) - uiout->field_string ("current", "*"); - else - uiout->field_skip ("current"); + uiout->field_check_mark ("current", + current_inferior ()->process_target () == t); uiout->field_signed ("number", t->connection_number); diff --git a/gdb/thread.c b/gdb/thread.c index 0228027fb928160fde98e338a4eb8498722dd539..2c761cbae7f6f4ca0a3767fad10a9c2fb7df6c3a 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -1165,11 +1165,7 @@ do_print_thread (ui_out *uiout, const char *requested_threads, if (!uiout->is_mi_like_p ()) { - if (tp == current_thread) - uiout->field_string ("current", "*"); - else - uiout->field_skip ("current"); - + uiout->field_check_mark ("current", tp == current_thread); uiout->field_string ("id-in-tg", print_thread_id (tp)); } diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 106a896c07fdadeae6c902a5bd541f81900c6453..a45a7af20d69170fb3ecac62f3f0345395bd88c2 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -557,6 +557,15 @@ ui_out::field_fmt (const char *fldname, const ui_file_style &style, va_end (args); } +void +ui_out::field_check_mark (const char *fldname, bool value) +{ + if (value) + field_string (fldname, get_check_mark ()); + else + field_skip (fldname); +} + void ui_out::call_do_message (const ui_file_style &style, const char *format, ...) diff --git a/gdb/ui-out.h b/gdb/ui-out.h index 1796e9c9eb3439422a767603d2799f4a7c167cf2..11d12024c2c15dd203a1df9d62eec72039a94c5e 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -206,6 +206,11 @@ class ui_out const char *format, ...) ATTRIBUTE_PRINTF (4, 5); + /* This is used when a table has a "current" field or the like. If + VALUE is true, a check mark of some kind is emitted for the + field. If VALUE is false, the field is skipped instead. */ + void field_check_mark (const char *fldname, bool value); + void spaces (int numspaces) { do_spaces (numspaces); } void text (const char *string) { do_text (string); } void text (const std::string &string) { text (string.c_str ()); } @@ -374,6 +379,14 @@ class ui_out double, double) = 0; virtual void do_progress_end () = 0; + /* Return the appropriate check-mark string. */ + virtual const char *get_check_mark () + { + /* The default is "*" because that's what was done + historically. */ + return "*"; + } + /* Set as not MI-like by default. It is overridden in subclasses if necessary. */ -- 2.49.0