public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/amd-dbgaapi-lib: Add set style commands for diagnostic messages
@ 2024-01-21 16:44 Lancelot SIX
  2024-01-22 15:41 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Lancelot SIX @ 2024-01-21 16:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: lsix, Lancelot SIX

The diagnostic messages produced by the amd-dbgapi library (controlled
with "set debug amd-dbgapi-lib log-level") are styled by default, but
the style cannot be edited by the user.

This patch adds the following commands to inspect and control the style
of diagnostic messages produced by amd-dbgapi:
- set style amd-dbgapi-lib fatal_error
- show style amd-dbgapi-lib fatal_error
- set style amd-dbgapi-lib trace_message
- show style amd-dbgapi-lib trace_message
- set style amd-dbgapi-lib warning_message
- show style amd-dbgapi-lib warning_message

Those commands work similarly to other "set/show style" commands already
available in GDB.

Change-Id: I89c30515ef69846ce53429d9f104cc86301a1256
---
 gdb/NEWS                |  9 +++++++++
 gdb/amd-dbgapi-target.c | 42 +++++++++++++++++++++++++++++++++++------
 gdb/doc/gdb.texinfo     | 20 ++++++++++++++++++++
 3 files changed, 65 insertions(+), 6 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index bab300e36b8..6e172e38d3a 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -47,6 +47,15 @@ set remote thread-options-packet
 show remote thread-options-packet
   Set/show the use of the thread options packet.
 
+set style amd-dbgapi-lib fatal_error
+show style amd-dbgapi-lib fatal_error
+set style amd-dbgapi-lib trace_message
+show style amd-dbgapi-lib trace_message
+set style amd-dbgapi-lib warning_message
+show style amd-dbgapi-lib warning_message
+  If AMDGPU support is enabled, those settings control the style of the
+  diagnostic messages emitted by the amd-dbgapi library.
+
 * New features in the GDB remote stub, GDBserver
 
   ** The --remote-debug and --event-loop-debug command line options
diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index ae8c1ea14e3..3a743a35e9d 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -25,6 +25,7 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-style.h"
+#include "gdbcmd.h"
 #include "inf-loop.h"
 #include "inferior.h"
 #include "objfiles.h"
@@ -2086,14 +2087,13 @@ location may not be accurate.  See \"show amdgpu precise-memory\".\n"));
 
 /* Style for some kinds of messages.  */
 
-static cli_style_option fatal_error_style
-  ("amd_dbgapi_fatal_error", ui_file_style::RED);
-static cli_style_option warning_style
-  ("amd_dbgapi_warning", ui_file_style::YELLOW);
+static cli_style_option fatal_error_style ("fatal_error", ui_file_style::RED);
+static cli_style_option warning_style ("warning_message",
+				       ui_file_style::YELLOW);
 
 /* BLACK + BOLD means dark gray.  */
-static cli_style_option trace_style
-  ("amd_dbgapi_trace", ui_file_style::BLACK, ui_file_style::BOLD);
+static cli_style_option trace_style ("trace_message", ui_file_style::BLACK,
+				     ui_file_style::BOLD);
 
 /* log_message callback.  */
 
@@ -2201,6 +2201,10 @@ struct cmd_list_element *show_amdgpu_list;
 struct cmd_list_element *set_debug_amd_dbgapi_lib_list;
 struct cmd_list_element *show_debug_amd_dbgapi_lib_list;
 
+/* List of set/show style amd-dbgapi-lib commands.  */
+struct cmd_list_element *set_style_amd_dbgapi_lib_list;
+struct cmd_list_element *show_style_amd_dbgapi_lib_list;
+
 /* Mapping from amd-dbgapi log level enum values to text.  */
 
 static constexpr const char *debug_amd_dbgapi_lib_log_level_enums[] =
@@ -2363,6 +2367,32 @@ If off (default), precise memory reporting is disabled."),
 			&set_debug_amd_dbgapi_lib_list,
 			&show_debug_amd_dbgapi_lib_list);
 
+  add_basic_prefix_cmd ("amd-dbgapi-lib", no_class,
+			_("Generic command for setting amd-dbgapi library "
+			  "logging styles."), &set_style_amd_dbgapi_lib_list,
+			0, &style_set_list);
+
+  add_basic_prefix_cmd ("amd-dbgapi-lib", no_class,
+			_("Generic command for showing amd-dbgapi library "
+			  "logging styles."), &show_style_amd_dbgapi_lib_list,
+			0, &style_show_list);
+
+  fatal_error_style.add_setshow_commands (no_class, _("\
+Configure amd-dbgapi-lib fatal errors styling."),
+					  &set_style_amd_dbgapi_lib_list,
+					  &show_style_amd_dbgapi_lib_list,
+					  false);
+
+  warning_style.add_setshow_commands (no_class, _("\
+Configure amd-dbgapi-lib warning messages styling."),
+				      &set_style_amd_dbgapi_lib_list,
+				      &show_style_amd_dbgapi_lib_list, false);
+
+  trace_style.add_setshow_commands (no_class, _("\
+Configure amd-dbgapi-lib trace messages styling."),
+				    &set_style_amd_dbgapi_lib_list,
+				    &show_style_amd_dbgapi_lib_list, false);
+
   add_setshow_boolean_cmd ("amd-dbgapi", class_maintenance,
 			   &debug_amd_dbgapi,
 			   _("Set debugging of amd-dbgapi target."),
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index e98c15242bc..8a9cf2de341 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27859,6 +27859,26 @@ family of commands.  This style is only used when @value{GDBN} is
 styling using its builtin disassembler library.  By default, this style's
 foreground color is red.
 
+@item amd-dbgapi-lib fatal_error
+Control the style of fatal-error diagnostic messages generated by
+amd-dbgapi-lib.  These are managed with the @code{set style
+amd-dbgapi-lib fatal_error} family of commands.  This style is only used
+if @value{GDBN} is compiled with amdgpu support (see @ref{AMD GPU}).
+
+@item amd-dbgapi-lib trace_message
+Control the style of trace diagnostic messages generated by
+amd-dbgapi-lib.  These are managed with the @code{set style
+amd-dbgapi-lib trace_message} family of commands.  This style is only
+used if @value{GDBN} is compiled with amdgpu support (see @ref{AMD
+GPU}).
+
+@item amd-dbgapi-lib warning_message
+Control the style of warning diagnostic messages generated by
+amd-dbgapi-lib.  These are managed with the @code{set style
+amd-dbgapi-lib warning_message} family of commands.  This style is only
+used if @value{GDBN} is compiled with amdgpu support (see @ref{AMD
+GPU}).
+
 @end table
 
 @node Numbers

base-commit: 5266f5c25b20ed6411b263952f52032afafd280d
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gdb/amd-dbgaapi-lib: Add set style commands for diagnostic messages
  2024-01-21 16:44 [PATCH] gdb/amd-dbgaapi-lib: Add set style commands for diagnostic messages Lancelot SIX
@ 2024-01-22 15:41 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2024-01-22 15:41 UTC (permalink / raw)
  To: Lancelot SIX; +Cc: gdb-patches, lsix

>>>>> "Lancelot" == Lancelot SIX <lancelot.six@amd.com> writes:

Lancelot> This patch adds the following commands to inspect and control the style
Lancelot> of diagnostic messages produced by amd-dbgapi:
Lancelot> - set style amd-dbgapi-lib fatal_error
Lancelot> - show style amd-dbgapi-lib fatal_error
Lancelot> - set style amd-dbgapi-lib trace_message
Lancelot> - show style amd-dbgapi-lib trace_message
Lancelot> - set style amd-dbgapi-lib warning_message
Lancelot> - show style amd-dbgapi-lib warning_message

I think it's more gdb-ish to use "-" rather than "_" to separate words.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-22 15:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-21 16:44 [PATCH] gdb/amd-dbgaapi-lib: Add set style commands for diagnostic messages Lancelot SIX
2024-01-22 15:41 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).