diff options
author | Pedro Alves <palves@redhat.com> | 2019-09-17 17:03:28 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-10-01 15:12:38 -0600 |
commit | 6a831f06e1bdf3aff6acf7ae31e2a3a9795137a5 (patch) | |
tree | 316d0ef4b369a0635a9132de2b5e63cdc2a94131 /gdb | |
parent | 2a3c1174c3c0db1140180fb3fc56ac324d1c0a7c (diff) | |
download | gdb-6a831f06e1bdf3aff6acf7ae31e2a3a9795137a5.zip gdb-6a831f06e1bdf3aff6acf7ae31e2a3a9795137a5.tar.gz gdb-6a831f06e1bdf3aff6acf7ae31e2a3a9795137a5.tar.bz2 |
Use new %p format suffixes in gdb
This changes various spots in gdb to use the new %p format suffixes.
gdb/ChangeLog
2019-10-01 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* symtab.c (print_symbol_info): Use %ps.
(print_msymbol_info): Use %ps.
* symfile.c (symbol_file_add_with_addrs): Use %ps.
* printcmd.c (print_variable_and_value): Use %ps.
* macrocmd.c (show_pp_source_pos): Use %ps.
* infrun.c (print_exited_reason): Use ui_out::message.
* breakpoint.c (watchpoint_check, print_one_breakpoint_location)
(describe_other_breakpoints): Use ui_out::message and new
formats.
(say_where): Use new formats.
(bkpt_print_it, tracepoint_print_one_detail): Use ui_out::message
and new formats.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 16 | ||||
-rw-r--r-- | gdb/breakpoint.c | 65 | ||||
-rw-r--r-- | gdb/infrun.c | 19 | ||||
-rw-r--r-- | gdb/macrocmd.c | 6 | ||||
-rw-r--r-- | gdb/printcmd.c | 5 | ||||
-rw-r--r-- | gdb/symfile.c | 13 | ||||
-rw-r--r-- | gdb/symtab.c | 24 |
7 files changed, 77 insertions, 71 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ff336c8..980aa60 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,6 +1,22 @@ 2019-10-01 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> + * symtab.c (print_symbol_info): Use %ps. + (print_msymbol_info): Use %ps. + * symfile.c (symbol_file_add_with_addrs): Use %ps. + * printcmd.c (print_variable_and_value): Use %ps. + * macrocmd.c (show_pp_source_pos): Use %ps. + * infrun.c (print_exited_reason): Use ui_out::message. + * breakpoint.c (watchpoint_check, print_one_breakpoint_location) + (describe_other_breakpoints): Use ui_out::message and new + formats. + (say_where): Use new formats. + (bkpt_print_it, tracepoint_print_one_detail): Use ui_out::message + and new formats. + +2019-10-01 Pedro Alves <palves@redhat.com> + Tom Tromey <tom@tromey.com> + * unittests/format_pieces-selftests.c: Add gdb_format parameter. (test_gdb_formats): New function. (run_tests): Call it. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index dd8fe4c..2030687 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4912,10 +4912,10 @@ watchpoint_check (bpstat bs) if (uiout->is_mi_like_p ()) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_SCOPE)); - uiout->text ("\nWatchpoint "); - uiout->field_signed ("wpnum", b->number); - uiout->text (" deleted because the program has left the block in\n" - "which its expression is valid.\n"); + uiout->message ("\nWatchpoint %pF deleted because the program has " + "left the block in\n" + "which its expression is valid.\n", + signed_field ("wpnum", b->number)); } /* Make sure the watchpoint's commands aren't executed. */ @@ -6141,10 +6141,9 @@ print_one_breakpoint_location (struct breakpoint *b, && breakpoint_condition_evaluation_mode () == condition_evaluation_target) { - uiout->text (" ("); - uiout->field_string ("evaluated-by", - bp_condition_evaluator (b)); - uiout->text (" evals)"); + uiout->message (" (%pF evals)", + string_field ("evaluated-by", + bp_condition_evaluator (b))); } uiout->text ("\n"); } @@ -6193,9 +6192,8 @@ print_one_breakpoint_location (struct breakpoint *b, if (!part_of_multiple && b->ignore_count) { annotate_field (8); - uiout->text ("\tignore next "); - uiout->field_signed ("ignore", b->ignore_count); - uiout->text (" hits\n"); + uiout->message ("\tignore next %pF hits\n", + signed_field ("ignore", b->ignore_count)); } /* Note that an enable count of 1 corresponds to "enable once" @@ -6658,9 +6656,9 @@ describe_other_breakpoints (struct gdbarch *gdbarch, (others > 1) ? "," : ((others == 1) ? " and" : "")); } - printf_filtered (_("also set at pc ")); - fputs_styled (paddress (gdbarch, pc), address_style.style (), gdb_stdout); - printf_filtered (".\n"); + current_uiout->message (_("also set at pc %ps.\n"), + styled_string (address_style.style (), + paddress (gdbarch, pc))); } } @@ -12075,23 +12073,21 @@ say_where (struct breakpoint *b) else { if (opts.addressprint || b->loc->symtab == NULL) - { - printf_filtered (" at "); - fputs_styled (paddress (b->loc->gdbarch, b->loc->address), - address_style.style (), - gdb_stdout); - } + printf_filtered (" at %ps", + styled_string (address_style.style (), + paddress (b->loc->gdbarch, + b->loc->address))); if (b->loc->symtab != NULL) { /* If there is a single location, we can print the location more nicely. */ if (b->loc->next == NULL) { - puts_filtered (": file "); - fputs_styled (symtab_to_filename_for_display (b->loc->symtab), - file_name_style.style (), - gdb_stdout); - printf_filtered (", line %d.", + const char *filename + = symtab_to_filename_for_display (b->loc->symtab); + printf_filtered (": file %ps, line %d.", + styled_string (file_name_style.style (), + filename), b->loc->line_number); } else @@ -12389,18 +12385,18 @@ bkpt_print_it (bpstat bs) annotate_breakpoint (b->number); maybe_print_thread_hit_breakpoint (uiout); - if (bp_temp) - uiout->text ("Temporary breakpoint "); - else - uiout->text ("Breakpoint "); if (uiout->is_mi_like_p ()) { uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT)); uiout->field_string ("disp", bpdisp_text (b->disposition)); } - uiout->field_signed ("bkptno", b->number); - uiout->text (", "); + if (bp_temp) + uiout->message ("Temporary breakpoint %pF, ", + signed_field ("bkptno", b->number)); + else + uiout->message ("Breakpoint %pF, ", + signed_field ("bkptno", b->number)); return PRINT_SRC_AND_LOC; } @@ -12716,10 +12712,9 @@ tracepoint_print_one_detail (const struct breakpoint *self, { gdb_assert (self->type == bp_static_tracepoint); - uiout->text ("\tmarker id is "); - uiout->field_string ("static-tracepoint-marker-string-id", - tp->static_trace_marker_id); - uiout->text ("\n"); + uiout->message ("\tmarker id is %pF\n", + string_field ("static-tracepoint-marker-string-id", + tp->static_trace_marker_id.c_str ())); } } diff --git a/gdb/infrun.c b/gdb/infrun.c index be29cbe..07aebfa 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -7656,24 +7656,19 @@ print_exited_reason (struct ui_out *uiout, int exitstatus) { if (uiout->is_mi_like_p ()) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_EXITED)); - uiout->text ("[Inferior "); - uiout->text (plongest (inf->num)); - uiout->text (" ("); - uiout->text (pidstr.c_str ()); - uiout->text (") exited with code "); - uiout->field_fmt ("exit-code", "0%o", (unsigned int) exitstatus); - uiout->text ("]\n"); + std::string exit_code_str + = string_printf ("0%o", (unsigned int) exitstatus); + uiout->message ("[Inferior %s (%s) exited with code %pF]\n", + plongest (inf->num), pidstr.c_str (), + string_field ("exit-code", exit_code_str.c_str ())); } else { if (uiout->is_mi_like_p ()) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_EXITED_NORMALLY)); - uiout->text ("[Inferior "); - uiout->text (plongest (inf->num)); - uiout->text (" ("); - uiout->text (pidstr.c_str ()); - uiout->text (") exited normally]\n"); + uiout->message ("[Inferior %s (%s) exited normally]\n", + plongest (inf->num), pidstr.c_str ()); } } diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c index 0f81c3d..cb7267d 100644 --- a/gdb/macrocmd.c +++ b/gdb/macrocmd.c @@ -120,8 +120,10 @@ show_pp_source_pos (struct ui_file *stream, int line) { std::string fullname = macro_source_fullname (file); - fputs_styled (fullname.c_str (), file_name_style.style (), stream); - fprintf_filtered (stream, ":%d\n", line); + fprintf_filtered (stream, "%ps:%d\n", + styled_string (file_name_style.style (), + fullname.c_str ()), + line); while (file->included_by) { diff --git a/gdb/printcmd.c b/gdb/printcmd.c index b3f7b59..c17afe2 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2214,9 +2214,8 @@ print_variable_and_value (const char *name, struct symbol *var, if (!name) name = SYMBOL_PRINT_NAME (var); - fputs_filtered (n_spaces (2 * indent), stream); - fputs_styled (name, variable_name_style.style (), stream); - fputs_filtered (" = ", stream); + fprintf_filtered (stream, "%s%ps = ", n_spaces (2 * indent), + styled_string (variable_name_style.style (), name)); try { diff --git a/gdb/symfile.c b/gdb/symfile.c index b914b05..ca1360f 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1106,11 +1106,8 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, if (deprecated_pre_add_symbol_hook) deprecated_pre_add_symbol_hook (name); else - { - puts_filtered (_("Reading symbols from ")); - fputs_styled (name, file_name_style.style (), gdb_stdout); - puts_filtered ("...\n"); - } + printf_filtered (_("Reading symbols from %ps...\n"), + styled_string (file_name_style.style (), name)); } syms_from_objfile (objfile, addrs, add_flags); @@ -1122,7 +1119,8 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, if ((flags & OBJF_READNOW)) { if (should_print) - printf_filtered (_("Expanding full symbols from %s...\n"), name); + printf_filtered (_("Expanding full symbols from %ps...\n"), + styled_string (file_name_style.style (), name)); if (objfile->sf) objfile->sf->qf->expand_all_symtabs (objfile); @@ -1134,7 +1132,8 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, file, and so printing it twice is just redundant. */ if (should_print && !objfile_has_symbols (objfile) && objfile->separate_debug_objfile == nullptr) - printf_filtered (_("(No debugging symbols found in %s)\n"), name); + printf_filtered (_("(No debugging symbols found in %ps)\n"), + styled_string (file_name_style.style (), name)); if (should_print) { diff --git a/gdb/symtab.c b/gdb/symtab.c index 6ea9fc6..df6b87f 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4748,9 +4748,9 @@ print_symbol_info (enum search_domain kind, if (filename_cmp (last, s_filename) != 0) { - fputs_filtered ("\nFile ", gdb_stdout); - fputs_styled (s_filename, file_name_style.style (), gdb_stdout); - fputs_filtered (":\n", gdb_stdout); + printf_filtered (_("\nFile %ps:\n"), + styled_string (file_name_style.style (), + s_filename)); } if (SYMBOL_LINE (sym) != 0) @@ -4812,15 +4812,15 @@ print_msymbol_info (struct bound_minimal_symbol msymbol) else tmp = hex_string_custom (BMSYMBOL_VALUE_ADDRESS (msymbol), 16); - fputs_styled (tmp, address_style.style (), gdb_stdout); - fputs_filtered (" ", gdb_stdout); - if (msymbol.minsym->text_p ()) - fputs_styled (MSYMBOL_PRINT_NAME (msymbol.minsym), - function_name_style.style (), - gdb_stdout); - else - fputs_filtered (MSYMBOL_PRINT_NAME (msymbol.minsym), gdb_stdout); - fputs_filtered ("\n", gdb_stdout); + + ui_file_style sym_style = (msymbol.minsym->text_p () + ? function_name_style.style () + : ui_file_style ()); + + printf_filtered (_("%ps %ps\n"), + styled_string (address_style.style (), tmp), + styled_string (sym_style, + MSYMBOL_PRINT_NAME (msymbol.minsym))); } /* This is the guts of the commands "info functions", "info types", and |