Use new %p format suffixes in gdb
authorPedro Alves <palves@redhat.com>
Tue, 17 Sep 2019 23:03:28 +0000 (17:03 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 1 Oct 2019 21:12:38 +0000 (15:12 -0600)
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.

gdb/ChangeLog
gdb/breakpoint.c
gdb/infrun.c
gdb/macrocmd.c
gdb/printcmd.c
gdb/symfile.c
gdb/symtab.c

index ff336c86f0e6b23e9a5ba3cb71e27b4766778b3a..980aa60571fb3be95f9fb011613a2c4f12c4be5e 100644 (file)
@@ -1,3 +1,19 @@
+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>
 
index dd8fe4c86208543fe42acb92b88ab6cb1bf19f01..2030687728cfd17e637f50baf8e1f629512cb8ef 100644 (file)
@@ -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)));
     }
 }
 \f
@@ -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 ()));
     }
 }
 
index be29cbe4f51ff97a4d10ee6ff0cf23fbdbe230d6..07aebfa678f48ede1ba8a59dd75291762a46d44c 100644 (file)
@@ -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 ());
     }
 }
 
index 0f81c3d5da4475f47299bd97c71f030c212e093a..cb7267d07a3eeba5def1adfdd7b96e2804ac9c32 100644 (file)
@@ -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)
     {
index b3f7b59863b32f7cc93c113ee8b55473352c1f1e..c17afe29bb2072ffd81c1dd8242c5af8804ea17d 100644 (file)
@@ -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
     {
index b914b05a1754547b3376d1de2613e821f3b7cd41..ca1360f0a7ef396295c7309c2a195d72c9c0ced3 100644 (file)
@@ -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)
     {
index 6ea9fc6971e0f0228f0934321aae81aa75a44e0e..df6b87f94836fd51cb95a3507bb8c68a297c035c 100644 (file)
@@ -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
This page took 0.042965 seconds and 4 git commands to generate.