* corelow.c, exec.c, inftarg.c, m3-nat.c, op50-rom.c, procfs.c,
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index 981cf59ded7a9931d6e7ab2f241cb019568ebda6..467b0ae4f62df56af3abf1216b5e416d448f4f0a 100644 (file)
@@ -33,6 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "breakpoint.h"
 #include "demangle.h"
 #include "valprint.h"
+#include "annotate.h"
 
 extern int asm_demangle;       /* Whether to demangle syms in asm printouts */
 extern int addressprint;       /* Whether to print hex addresses in HLL " */
@@ -87,19 +88,6 @@ int current_display_number;
 
 int inspect_it = 0;
 
-void
-print_value_flags (t)
-     struct type *t;
-{
-  /* FIXME: Should we be printing * for references as well as pointers?  */
-  if (t != NULL
-      && TYPE_CODE (t) == TYPE_CODE_PTR
-      && TYPE_CODE (TYPE_TARGET_TYPE (t)) != TYPE_CODE_VOID)
-    printf_filtered ("*");
-  else
-    printf_filtered ("-");
-}
-
 struct display
 {
   /* Chain link to next auto-display item.  */
@@ -537,7 +525,7 @@ print_address_symbolic (addr, stream, do_demangle, leadin)
   struct symbol *symbol;
   struct symtab *symtab = 0;
   CORE_ADDR name_location = 0;
-  char *name;
+  char *name = "";
 
   /* First try to find the address in the symbol table, then
      in the minsyms.  Take the closest one.  */
@@ -613,10 +601,12 @@ print_address_symbolic (addr, stream, do_demangle, leadin)
   fputs_filtered (">", stream);
 }
 
-/* Print address ADDR on STREAM.  */
+/* Print address ADDR on STREAM.  USE_LOCAL means the same thing as for
+   print_longest.  */
 void
-print_address_numeric (addr, stream)
+print_address_numeric (addr, use_local, stream)
      CORE_ADDR addr;
+     int use_local;
      GDB_FILE *stream;
 {
   /* This assumes a CORE_ADDR can fit in a LONGEST.  Probably a safe
@@ -634,7 +624,7 @@ print_address (addr, stream)
      CORE_ADDR addr;
      GDB_FILE *stream;
 {
-  print_address_numeric (addr, stream);
+  print_address_numeric (addr, 1, stream);
   print_address_symbolic (addr, stream, asm_demangle, " ");
 }
 
@@ -655,7 +645,7 @@ print_address_demangle (addr, stream, do_demangle)
     }
   else if (addressprint)
     {
-      print_address_numeric (addr, stream);
+      print_address_numeric (addr, 1, stream);
       print_address_symbolic (addr, stream, do_demangle, " ");
     }
   else
@@ -824,34 +814,26 @@ print_command_1 (exp, inspect, voidprint)
     {
       int histindex = record_latest_value (val);
 
-      if (annotation_level > 1)
-       {
-         if (histindex >= 0)
-           printf_filtered ("\n\032\032value-history-begin %d ", histindex);
-         else
-           printf_filtered ("\n\032\032value-begin ");
-         print_value_flags (VALUE_TYPE (val));
-         printf_filtered ("\n");
-       }
+      if (histindex >= 0)
+       annotate_value_history_begin (histindex, VALUE_TYPE (val));
+      else
+       annotate_value_begin (VALUE_TYPE (val));
 
       if (inspect)
        printf_unfiltered ("\031(gdb-makebuffer \"%s\"  %d '(\"", exp, histindex);
       else
        if (histindex >= 0) printf_filtered ("$%d = ", histindex);
 
-      if (annotation_level > 1 && histindex >= 0)
-       printf_filtered ("\n\032\032value-history-value\n");
+      if (histindex >= 0)
+       annotate_value_history_value ();
 
       print_formatted (val, format, fmt.size);
       printf_filtered ("\n");
 
-      if (annotation_level > 1)
-       {
-         if (histindex >= 0)
-           printf_filtered ("\n\032\032value-history-end\n");
-         else
-           printf_filtered ("\n\032\032value-end\n");
-       }
+      if (histindex >= 0)
+       annotate_value_history_end ();
+      else
+       annotate_value_end ();
 
       if (inspect)
        printf_unfiltered("\") )\030");
@@ -918,17 +900,11 @@ output_command (exp, from_tty)
 
   val = evaluate_expression (expr);
 
-  if (annotation_level > 1)
-    {
-      printf_filtered ("\n\032\032value-begin ");
-      print_value_flags (VALUE_TYPE (val));
-      printf_filtered ("\n");
-    }
+  annotate_value_begin (VALUE_TYPE (val));
 
   print_formatted (val, format, fmt.size);
 
-  if (annotation_level > 1)
-    printf_filtered ("\n\032\032value-end\n");
+  annotate_value_end ();
 
   do_cleanups (old_chain);
 }
@@ -983,7 +959,8 @@ address_info (exp, from_tty)
          fprintf_symbol_filtered (gdb_stdout, exp,
                                   current_language->la_language, DMGL_ANSI);
          printf_filtered ("\" is at ");
-         print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol), gdb_stdout);
+         print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol), 1,
+                                gdb_stdout);
          printf_filtered (" in a file compiled without debugging.\n");
        }
       else
@@ -1007,7 +984,7 @@ address_info (exp, from_tty)
 
     case LOC_LABEL:
       printf_filtered ("a label at address ");
-      print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), gdb_stdout);
+      print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, gdb_stdout);
       break;
 
     case LOC_REGISTER:
@@ -1016,7 +993,7 @@ address_info (exp, from_tty)
 
     case LOC_STATIC:
       printf_filtered ("static storage at address ");
-      print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), gdb_stdout);
+      print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, gdb_stdout);
       break;
 
     case LOC_REGPARM:
@@ -1059,7 +1036,7 @@ address_info (exp, from_tty)
 
     case LOC_BLOCK:
       printf_filtered ("a function at address ");
-      print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)),
+      print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), 1,
                             gdb_stdout);
       break;
 
@@ -1310,11 +1287,16 @@ do_one_display (d)
 
   current_display_number = d->number;
 
-  printf_filtered ("%d: ", d->number);
+  annotate_display_begin ();
+  printf_filtered ("%d", d->number);
+  annotate_display_number_end ();
+  printf_filtered (": ");
   if (d->format.size)
     {
       CORE_ADDR addr;
-      
+
+      annotate_display_format ();
+
       printf_filtered ("x/");
       if (d->format.count != 1)
        printf_filtered ("%d", d->format.count);
@@ -1322,7 +1304,12 @@ do_one_display (d)
       if (d->format.format != 'i' && d->format.format != 's')
        printf_filtered ("%c", d->format.size);
       printf_filtered (" ");
+
+      annotate_display_expression ();
+
       print_expression (d->exp, gdb_stdout);
+      annotate_display_expression_end ();
+
       if (d->format.count != 1)
        printf_filtered ("\n");
       else
@@ -1331,20 +1318,34 @@ do_one_display (d)
       addr = value_as_pointer (evaluate_expression (d->exp));
       if (d->format.format == 'i')
        addr = ADDR_BITS_REMOVE (addr);
-      
+
+      annotate_display_value ();
+
       do_examine (d->format, addr);
     }
   else
     {
+      annotate_display_format ();
+
       if (d->format.format)
        printf_filtered ("/%c ", d->format.format);
+
+      annotate_display_expression ();
+
       print_expression (d->exp, gdb_stdout);
+      annotate_display_expression_end ();
+
       printf_filtered (" = ");
+
+      annotate_display_expression ();
+
       print_formatted (evaluate_expression (d->exp),
                       d->format.format, d->format.size);
       printf_filtered ("\n");
     }
 
+  annotate_display_end ();
+
   gdb_flush (gdb_stdout);
   current_display_number = -1;
 }
@@ -1627,7 +1628,7 @@ print_frame_args (func, fi, num, stream)
 
                 Additional note:  It might be nice if "info args" displayed
                 both values.
-                One more note:  There is a case with sparc sturcture passing
+                One more note:  There is a case with sparc structure passing
                 where we need to use the LOC_REGISTER, but this is dealt with
                 by creating a single LOC_REGPARM in symbol reading.  */
 
@@ -1643,12 +1644,11 @@ print_frame_args (func, fi, num, stream)
        fprintf_filtered (stream, ", ");
       wrap_here ("    ");
 
-      if (annotation_level > 1)
-       printf_filtered ("\n\032\032arg-name-begin\n");
+      annotate_arg_begin ();
+
       fprintf_symbol_filtered (stream, SYMBOL_SOURCE_NAME (sym),
                               SYMBOL_LANGUAGE (sym), DMGL_PARAMS | DMGL_ANSI);
-      if (annotation_level > 1)
-       printf_filtered ("\n\032\032arg-name-end\n");
+      annotate_arg_name_end ();
       fputs_filtered ("=", stream);
 
       /* Avoid value_print because it will deref ref parameters.  We just
@@ -1658,12 +1658,7 @@ print_frame_args (func, fi, num, stream)
         2 for each recurse.  */
       val = read_var_value (sym, FRAME_INFO_ID (fi));
 
-      if (annotation_level > 1)
-       {
-         printf_filtered ("\n\032\032arg-begin ");
-         print_value_flags (val == NULL ? NULL : VALUE_TYPE (val));
-         printf_filtered ("\n");
-       }
+      annotate_arg_value (val == NULL ? NULL : VALUE_TYPE (val));
 
       if (val)
         val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), VALUE_ADDRESS (val),
@@ -1671,8 +1666,7 @@ print_frame_args (func, fi, num, stream)
       else
        fputs_filtered ("???", stream);
 
-      if (annotation_level > 1)
-       printf_filtered ("\n\032\032arg-end\n");
+      annotate_arg_end ();
 
       first = 0;
     }
@@ -1845,8 +1839,8 @@ printf_command (arg, from_tty)
 
   {
     /* Now scan the string for %-specs and see what kinds of args they want.
-       argclass[I] classifies the %-specs so we can give vprintf_unfiltered something
-       of the right size.  */
+       argclass[I] classifies the %-specs so we can give printf_filtered
+       something of the right size.  */
 
     enum argclass {no_arg, int_arg, string_arg, double_arg, long_long_arg};
     enum argclass *argclass;
@@ -1942,16 +1936,6 @@ printf_command (arg, from_tty)
     if (nargs != nargs_wanted)
       error ("Wrong number of arguments for specified format-string");
 
-    /* FIXME: We should be using vprintf_filtered, but as long as it
-       has an arbitrary limit that is unacceptable.  Correct fix is
-       for vprintf_filtered to scan down the format string so it knows
-       how big a buffer it needs (perhaps by putting a vasprintf (see
-       GNU C library) in libiberty).
-
-       But for now, just force out any pending output, so at least the output
-       appears in the correct order.  */
-    wrap_here ((char *)NULL);
-
     /* Now actually print them.  */
     current_substring = substrings;
     for (i = 0; i < nargs; i++)
@@ -1980,23 +1964,20 @@ printf_command (arg, from_tty)
              read_memory (tem, str, j);
              str[j] = 0;
 
-             /* Don't use printf_filtered because of arbitrary limit.  */
-             printf_unfiltered (current_substring, str);
+             printf_filtered (current_substring, str);
            }
            break;
          case double_arg:
            {
              double val = value_as_double (val_args[i]);
-             /* Don't use printf_filtered because of arbitrary limit.  */
-             printf_unfiltered (current_substring, val);
+             printf_filtered (current_substring, val);
              break;
            }
          case long_long_arg:
 #if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
            {
              long long val = value_as_long (val_args[i]);
-             /* Don't use printf_filtered because of arbitrary limit.  */
-             printf_unfiltered (current_substring, val);
+             printf_filtered (current_substring, val);
              break;
            }
 #else
@@ -2006,8 +1987,7 @@ printf_command (arg, from_tty)
            {
              /* FIXME: there should be separate int_arg and long_arg.  */
              long val = value_as_long (val_args[i]);
-             /* Don't use printf_filtered because of arbitrary limit.  */
-             printf_unfiltered (current_substring, val);
+             printf_filtered (current_substring, val);
              break;
            }
          default:
@@ -2017,8 +1997,7 @@ printf_command (arg, from_tty)
        current_substring += strlen (current_substring) + 1;
       }
     /* Print the portion of the format string after the last argument.  */
-    /* It would be OK to use printf_filtered here.  */
-    printf (last_arg);
+    printf_filtered (last_arg);
   }
   do_cleanups (old_cleanups);
 }
@@ -2074,9 +2053,9 @@ disassemble_command (arg, from_tty)
   else
     {
       printf_filtered ("from ");
-      print_address_numeric (low, gdb_stdout);
+      print_address_numeric (low, 1, gdb_stdout);
       printf_filtered (" to ");
-      print_address_numeric (high, gdb_stdout);
+      print_address_numeric (high, 1, gdb_stdout);
       printf_filtered (":\n");
     }
 
This page took 0.027141 seconds and 4 git commands to generate.