* breakpoint.c (bptype_string): New, abstracted out from
authorPedro Alves <palves@redhat.com>
Wed, 21 Jul 2010 11:25:53 +0000 (11:25 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 21 Jul 2010 11:25:53 +0000 (11:25 +0000)
print_one_breakpoint_location.
(print_one_breakpoint_location): Adjust.
(breakpoint_1): Adjust the type column width dynamically.

gdb/ChangeLog
gdb/breakpoint.c

index 1e1257ef0053f3baf22a2f8e76e3a41fd4b8c27b..39eb1921b90b7cc7738e07d211b34d2257a14c35 100644 (file)
@@ -1,3 +1,10 @@
+2010-07-21  Pedro Alves  <pedro@codesourcery.com>
+
+       * breakpoint.c (bptype_string): New, abstracted out from
+       print_one_breakpoint_location.
+       (print_one_breakpoint_location): Adjust.
+       (breakpoint_1): Adjust the type column width dynamically.
+
 2010-07-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * symfile.c (find_separate_debug_file_by_debuglink): Remove
index a9be450dd18a8588399b7ba82e34a9b37bde3792..b53b5154e2aed74a86b4b99729e9ebcc49cedf56 100644 (file)
@@ -4433,16 +4433,9 @@ static void print_breakpoint_location (struct breakpoint *b,
   do_cleanups (old_chain);
 }
 
-/* Print B to gdb_stdout. */
-static void
-print_one_breakpoint_location (struct breakpoint *b,
-                              struct bp_location *loc,
-                              int loc_number,
-                              struct bp_location **last_loc,
-                              int print_address_bits,
-                              int allflag)
+static const char *
+bptype_string (enum bptype type)
 {
-  struct command_line *l;
   struct ep_type_description
     {
       enum bptype type;
@@ -4476,7 +4469,27 @@ print_one_breakpoint_location (struct breakpoint *b,
     {bp_static_tracepoint, "static tracepoint"},
     {bp_jit_event, "jit events"},
   };
-  
+
+  if (((int) type >= (sizeof (bptypes) / sizeof (bptypes[0])))
+      || ((int) type != bptypes[(int) type].type))
+    internal_error (__FILE__, __LINE__,
+                   _("bptypes table does not describe type #%d."),
+                   (int) type);
+
+  return bptypes[(int) type].description;
+}
+
+/* Print B to gdb_stdout.  */
+
+static void
+print_one_breakpoint_location (struct breakpoint *b,
+                              struct bp_location *loc,
+                              int loc_number,
+                              struct bp_location **last_loc,
+                              int print_address_bits,
+                              int allflag)
+{
+  struct command_line *l;
   static char bpenables[] = "nynny";
   char wrap_indent[80];
   struct ui_stream *stb = ui_out_stream_new (uiout);
@@ -4521,15 +4534,8 @@ print_one_breakpoint_location (struct breakpoint *b,
   annotate_field (1);
   if (part_of_multiple)
     ui_out_field_skip (uiout, "type");
-  else 
-    {
-      if (((int) b->type >= (sizeof (bptypes) / sizeof (bptypes[0])))
-         || ((int) b->type != bptypes[(int) b->type].type))
-       internal_error (__FILE__, __LINE__,
-                       _("bptypes table does not describe type #%d."),
-                       (int) b->type);
-      ui_out_field_string (uiout, "type", bptypes[(int) b->type].description);
-    }
+  else
+    ui_out_field_string (uiout, "type", bptype_string (b->type));
 
   /* 3 */
   annotate_field (2);
@@ -4907,7 +4913,8 @@ breakpoint_1 (int bnum, int allflag, int (*filter) (const struct breakpoint *))
   struct cleanup *bkpttbl_chain;
   struct value_print_options opts;
   int print_address_bits = 0;
-  
+  int print_type_col_width = 14;
+
   get_user_print_options (&opts);
 
   /* Compute the number of rows in the table, as well as the
@@ -4923,10 +4930,16 @@ breakpoint_1 (int bnum, int allflag, int (*filter) (const struct breakpoint *))
        
        if (allflag || user_settable_breakpoint (b))
          {
-           int addr_bit = breakpoint_address_bits (b);
+           int addr_bit, type_len;
+
+           addr_bit = breakpoint_address_bits (b);
            if (addr_bit > print_address_bits)
              print_address_bits = addr_bit;
 
+           type_len = strlen (bptype_string (b->type));
+           if (type_len > print_type_col_width)
+             print_type_col_width = type_len;
+
            nr_printable_breakpoints++;
          }
       }
@@ -4947,7 +4960,8 @@ breakpoint_1 (int bnum, int allflag, int (*filter) (const struct breakpoint *))
   ui_out_table_header (uiout, 7, ui_left, "number", "Num");            /* 1 */
   if (nr_printable_breakpoints > 0)
     annotate_field (1);
-  ui_out_table_header (uiout, 14, ui_left, "type", "Type");            /* 2 */
+  ui_out_table_header (uiout, print_type_col_width, ui_left,
+                      "type", "Type");         /* 2 */
   if (nr_printable_breakpoints > 0)
     annotate_field (2);
   ui_out_table_header (uiout, 4, ui_left, "disp", "Disp");             /* 3 */