Use styled_string in more places

This adds more uses of styled_string, changing gdb to style some
output that was previously left unstyled.

gdb/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

	* stack.c (print_frame, info_frame_command_core): Use
	styled_string.
	* linux-thread-db.c (try_thread_db_load_1)
	(try_thread_db_load_from_pdir_1): Use styled_string.
	* auto-load.c (file_is_auto_load_safe, execute_script_contents)
	(auto_load_section_scripts, info_auto_load_local_gdbinit)
	(maybe_print_unsupported_script_warning)
	(maybe_print_script_not_found_warning): Use styled_string.
	* ada-lang.c (user_select_syms): Use styled_string.
This commit is contained in:
Tom Tromey 2019-09-17 19:11:55 -06:00
parent 7f6aba03b9
commit 9d636d67e0
5 changed files with 55 additions and 23 deletions

View file

@ -1,3 +1,15 @@
2019-10-01 Tom Tromey <tom@tromey.com>
* stack.c (print_frame, info_frame_command_core): Use
styled_string.
* linux-thread-db.c (try_thread_db_load_1)
(try_thread_db_load_from_pdir_1): Use styled_string.
* auto-load.c (file_is_auto_load_safe, execute_script_contents)
(auto_load_section_scripts, info_auto_load_local_gdbinit)
(maybe_print_unsupported_script_warning)
(maybe_print_script_not_found_warning): Use styled_string.
* ada-lang.c (user_select_syms): Use styled_string.
2019-10-01 Tom Tromey <tom@tromey.com> 2019-10-01 Tom Tromey <tom@tromey.com>
* p-lang.c (pascal_printstr): Use metadata style. * p-lang.c (pascal_printstr): Use metadata style.

View file

@ -3881,9 +3881,11 @@ See set/show multiple-symbol."));
printf_filtered (_(" at %p[<no source file available>%p]:%d\n"), printf_filtered (_(" at %p[<no source file available>%p]:%d\n"),
metadata_style.style ().ptr (), nullptr, sal.line); metadata_style.style ().ptr (), nullptr, sal.line);
else else
printf_filtered (_(" at %s:%d\n"), printf_filtered
symtab_to_filename_for_display (sal.symtab), (_(" at %ps:%d\n"),
sal.line); styled_string (file_name_style.style (),
symtab_to_filename_for_display (sal.symtab)),
sal.line);
continue; continue;
} }
else else

View file

@ -41,6 +41,7 @@
#include "gdb/section-scripts.h" #include "gdb/section-scripts.h"
#include <algorithm> #include <algorithm>
#include "gdbsupport/pathstuff.h" #include "gdbsupport/pathstuff.h"
#include "cli/cli-style.h"
/* The section to look in for auto-loaded scripts (in file formats that /* The section to look in for auto-loaded scripts (in file formats that
support sections). support sections).
@ -490,9 +491,10 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
if (filename_is_in_auto_load_safe_path_vec (filename, &filename_real)) if (filename_is_in_auto_load_safe_path_vec (filename, &filename_real))
return 1; return 1;
warning (_("File \"%s\" auto-loading has been declined by your " warning (_("File \"%ps\" auto-loading has been declined by your "
"`auto-load safe-path' set to \"%s\"."), "`auto-load safe-path' set to \"%s\"."),
filename_real.get (), auto_load_safe_path); styled_string (file_name_style.style (), filename_real.get ()),
auto_load_safe_path);
if (!advice_printed) if (!advice_printed)
{ {
@ -989,8 +991,10 @@ execute_script_contents (struct auto_load_pspace_info *pspace_info,
/* We don't throw an error, the program is still debuggable. */ /* We don't throw an error, the program is still debuggable. */
warning (_("\ warning (_("\
Missing/bad script name in entry at offset %u in section %s\n\ Missing/bad script name in entry at offset %u in section %s\n\
of file %s."), of file %ps."),
offset, section_name, objfile_name (objfile)); offset, section_name,
styled_string (file_name_style.style (),
objfile_name (objfile)));
return; return;
} }
script_text = newline + 1; script_text = newline + 1;
@ -1120,8 +1124,10 @@ auto_load_section_scripts (struct objfile *objfile, const char *section_name)
return; return;
if (!bfd_get_full_section_contents (abfd, scripts_sect, &data)) if (!bfd_get_full_section_contents (abfd, scripts_sect, &data))
warning (_("Couldn't read %s section of %s"), warning (_("Couldn't read %s section of %ps"),
section_name, bfd_get_filename (abfd)); section_name,
styled_string (file_name_style.style (),
bfd_get_filename (abfd)));
else else
{ {
gdb::unique_xmalloc_ptr<bfd_byte> data_holder (data); gdb::unique_xmalloc_ptr<bfd_byte> data_holder (data);
@ -1349,11 +1355,13 @@ info_auto_load_local_gdbinit (const char *args, int from_tty)
if (auto_load_local_gdbinit_pathname == NULL) if (auto_load_local_gdbinit_pathname == NULL)
printf_filtered (_("Local .gdbinit file was not found.\n")); printf_filtered (_("Local .gdbinit file was not found.\n"));
else if (auto_load_local_gdbinit_loaded) else if (auto_load_local_gdbinit_loaded)
printf_filtered (_("Local .gdbinit file \"%s\" has been loaded.\n"), printf_filtered (_("Local .gdbinit file \"%ps\" has been loaded.\n"),
auto_load_local_gdbinit_pathname); styled_string (file_name_style.style (),
auto_load_local_gdbinit_pathname));
else else
printf_filtered (_("Local .gdbinit file \"%s\" has not been loaded.\n"), printf_filtered (_("Local .gdbinit file \"%ps\" has not been loaded.\n"),
auto_load_local_gdbinit_pathname); styled_string (file_name_style.style (),
auto_load_local_gdbinit_pathname));
} }
/* Print an "unsupported script" warning if it has not already been printed. /* Print an "unsupported script" warning if it has not already been printed.
@ -1370,9 +1378,11 @@ maybe_print_unsupported_script_warning
{ {
warning (_("\ warning (_("\
Unsupported auto-load script at offset %u in section %s\n\ Unsupported auto-load script at offset %u in section %s\n\
of file %s.\n\ of file %ps.\n\
Use `info auto-load %s-scripts [REGEXP]' to list them."), Use `info auto-load %s-scripts [REGEXP]' to list them."),
offset, section_name, objfile_name (objfile), offset, section_name,
styled_string (file_name_style.style (),
objfile_name (objfile)),
ext_lang_name (language)); ext_lang_name (language));
pspace_info->unsupported_script_warning_printed = true; pspace_info->unsupported_script_warning_printed = true;
} }
@ -1392,9 +1402,11 @@ maybe_print_script_not_found_warning
{ {
warning (_("\ warning (_("\
Missing auto-load script at offset %u in section %s\n\ Missing auto-load script at offset %u in section %s\n\
of file %s.\n\ of file %ps.\n\
Use `info auto-load %s-scripts [REGEXP]' to list them."), Use `info auto-load %s-scripts [REGEXP]' to list them."),
offset, section_name, objfile_name (objfile), offset, section_name,
styled_string (file_name_style.style (),
objfile_name (objfile)),
ext_lang_name (language)); ext_lang_name (language));
pspace_info->script_not_found_warning_printed = true; pspace_info->script_not_found_warning_printed = true;
} }

View file

@ -48,6 +48,7 @@
#include <algorithm> #include <algorithm>
#include "gdbsupport/pathstuff.h" #include "gdbsupport/pathstuff.h"
#include "valprint.h" #include "valprint.h"
#include "cli/cli-style.h"
/* GNU/Linux libthread_db support. /* GNU/Linux libthread_db support.
@ -933,8 +934,9 @@ try_thread_db_load_1 (struct thread_db_info *info)
enabled. User visible output should not depend on debug enabled. User visible output should not depend on debug
settings. */ settings. */
file = *libthread_db_search_path != '\0' ? gdb_stdout : gdb_stdlog; file = *libthread_db_search_path != '\0' ? gdb_stdout : gdb_stdlog;
fprintf_unfiltered (file, _("Using host libthread_db library \"%s\".\n"), fprintf_unfiltered (file,
library); _("Using host libthread_db library \"%ps\".\n"),
styled_string (file_name_style.style (), library));
} }
/* The thread library was detected. Activate the thread_db target /* The thread library was detected. Activate the thread_db target
@ -1028,7 +1030,8 @@ try_thread_db_load_from_pdir_1 (struct objfile *obj, const char *subdir)
if (obj_name[0] != '/') if (obj_name[0] != '/')
{ {
warning (_("Expected absolute pathname for libpthread in the" warning (_("Expected absolute pathname for libpthread in the"
" inferior, but got %s."), obj_name); " inferior, but got %ps."),
styled_string (file_name_style.style (), obj_name));
return false; return false;
} }

View file

@ -1393,7 +1393,7 @@ print_frame (const frame_print_options &fp_opts,
annotate_frame_where (); annotate_frame_where ();
uiout->wrap_hint (" "); uiout->wrap_hint (" ");
uiout->text (" from "); uiout->text (" from ");
uiout->field_string ("from", lib); uiout->field_string ("from", lib, file_name_style.style ());
} }
} }
if (uiout->is_mi_like_p ()) if (uiout->is_mi_like_p ())
@ -1524,8 +1524,11 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
} }
wrap_here (" "); wrap_here (" ");
if (sal.symtab) if (sal.symtab)
printf_filtered (" (%s:%d)", symtab_to_filename_for_display (sal.symtab), printf_filtered
sal.line); (" (%ps:%d)",
styled_string (file_name_style.style (),
symtab_to_filename_for_display (sal.symtab)),
sal.line);
puts_filtered ("; "); puts_filtered ("; ");
wrap_here (" "); wrap_here (" ");
printf_filtered ("saved %s = ", pc_regname); printf_filtered ("saved %s = ", pc_regname);