From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>, Kevin Buettner <kevinb@redhat.com>
Subject: [PATCH v2 1/2] Introduce ui_out::field_check_mark
Date: Wed, 11 Jun 2025 07:58:43 -0600 [thread overview]
Message-ID: <20250611-emoji-check-mark-v2-1-d299ec101650@adacore.com> (raw)
In-Reply-To: <20250611-emoji-check-mark-v2-0-d299ec101650@adacore.com>
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 <kevinb@redhat.com>
---
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
next prev parent reply other threads:[~2025-06-11 14:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 13:58 [PATCH v2 0/2] Use check-mark for current row of CLI table Tom Tromey
2025-06-11 13:58 ` Tom Tromey [this message]
2025-06-11 17:39 ` [PATCH v2 1/2] Introduce ui_out::field_check_mark Kevin Buettner
2025-06-11 13:58 ` [PATCH v2 2/2] Allow check-mark to be changed for CLI Tom Tromey
2025-06-11 14:33 ` Simon Marchi
2025-06-11 14:57 ` Simon Marchi
2025-06-11 15:01 ` Eli Zaretskii
2025-06-11 15:18 ` Simon Marchi
2025-06-11 15:40 ` Eli Zaretskii
2025-06-11 17:37 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250611-emoji-check-mark-v2-1-d299ec101650@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=kevinb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox