From: Tom Tromey Date: Sat, 11 Jan 2025 21:36:54 +0000 (-0700) Subject: Use command style in cmd_show_list X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7627b430434117181323985ada05abde8a474fe7;p=thirdparty%2Fbinutils-gdb.git Use command style in cmd_show_list cmd_show_list is a bit funny because it shows partial command names -- for a command like "show abc xyz", it will only show "abc xyz". Nevertheless, I think it makes some sense to highlight these with the command style. That is what this patch does. --- diff --git a/gdb/auto-load.c b/gdb/auto-load.c index a8f3a8d5fdd..71bbae4fc1d 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -1472,7 +1472,7 @@ info_auto_load_cmd (const char *args, int from_tty) struct ui_out *uiout = current_uiout; ui_out_emit_tuple tuple_emitter (uiout, "infolist"); - + const ui_file_style cmd_style = command_style.style (); for (list = *auto_load_info_cmdlist_get (); list != NULL; list = list->next) { ui_out_emit_tuple option_emitter (uiout, "option"); @@ -1480,7 +1480,7 @@ info_auto_load_cmd (const char *args, int from_tty) gdb_assert (!list->is_prefix ()); gdb_assert (list->type == not_set_cmd); - uiout->field_string ("name", list->name); + uiout->field_string ("name", list->name, cmd_style); uiout->text (": "); cmd_func (list, auto_load_info_scripts_pattern_nl, from_tty); } diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 73b52253f5a..b438e980764 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -707,6 +707,7 @@ cmd_show_list (struct cmd_list_element *list, int from_tty) struct ui_out *uiout = current_uiout; ui_out_emit_tuple tuple_emitter (uiout, "showlist"); + const ui_file_style cmd_style = command_style.style (); for (; list != NULL; list = list->next) { /* We skip show command aliases to avoid showing duplicated values. */ @@ -727,15 +728,18 @@ cmd_show_list (struct cmd_list_element *list, int from_tty) { ui_out_emit_tuple option_emitter (uiout, "option"); - if (list->prefix != nullptr) + if (!uiout->is_mi_like_p () && list->prefix != nullptr) { /* If we find a prefix, output it (with "show " skipped). */ std::string prefixname = list->prefix->prefixname (); - prefixname = (!list->prefix->is_prefix () ? "" - : strstr (prefixname.c_str (), "show ") + 5); - uiout->text (prefixname); + if (startswith (prefixname, "show ")) + prefixname = prefixname.substr (5); + /* In non-MI mode, we include the full name here. */ + prefixname += list->name; + uiout->field_string ("name", prefixname, cmd_style); } - uiout->field_string ("name", list->name); + else + uiout->field_string ("name", list->name, cmd_style); uiout->text (": "); if (list->type == show_cmd) do_show_command (NULL, from_tty, list); diff --git a/gdb/remote.c b/gdb/remote.c index f3687fbaa70..1318352e02c 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -15583,6 +15583,7 @@ show_remote_cmd (const char *args, int from_tty) struct ui_out *uiout = current_uiout; ui_out_emit_tuple tuple_emitter (uiout, "showlist"); + const ui_file_style cmd_style = command_style.style (); for (; list != NULL; list = list->next) if (strcmp (list->name, "Z-packet") == 0) continue; @@ -15594,7 +15595,7 @@ show_remote_cmd (const char *args, int from_tty) { ui_out_emit_tuple option_emitter (uiout, "option"); - uiout->field_string ("name", list->name); + uiout->field_string ("name", list->name, cmd_style); uiout->text (": "); if (list->type == show_cmd) do_show_command (NULL, from_tty, list);