* symtab.c (symbol_search_name): Minor reformatting.
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index 410b950fe33821e63fc127262e021ccd9f96143d..8b7d31d5101c39671b63842912f9bf4590395509 100644 (file)
@@ -1,7 +1,7 @@
 /* Print values for GNU debugger GDB.
 
    Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
-   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
    Foundation, Inc.
 
    This file is part of GDB.
 #include "block.h"
 #include "disasm.h"
 
+#ifdef TUI
+#include "tui/tui.h"           /* For tui_active et.al.   */
+#endif
+
 extern int asm_demangle;       /* Whether to demangle syms in asm printouts */
 extern int addressprint;       /* Whether to print hex addresses in HLL " */
 
@@ -190,7 +194,7 @@ static struct format_data
 decode_format (char **string_ptr, int oformat, int osize)
 {
   struct format_data val;
-  register char *p = *string_ptr;
+  char *p = *string_ptr;
 
   val.format = '?';
   val.size = '?';
@@ -275,7 +279,7 @@ decode_format (char **string_ptr, int oformat, int osize)
    This is used to pad hex numbers so they line up.  */
 
 static void
-print_formatted (struct value *val, register int format, int size,
+print_formatted (struct value *val, int format, int size,
                 struct ui_file *stream)
 {
   struct type *type = check_typedef (VALUE_TYPE (val));
@@ -315,7 +319,8 @@ print_formatted (struct value *val, register int format, int size,
          || TYPE_CODE (type) == TYPE_CODE_ARRAY
          || TYPE_CODE (type) == TYPE_CODE_STRING
          || TYPE_CODE (type) == TYPE_CODE_STRUCT
-         || TYPE_CODE (type) == TYPE_CODE_UNION)
+         || TYPE_CODE (type) == TYPE_CODE_UNION
+         || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
        /* If format is 0, use the 'natural' format for
         * that type of value.  If the type is non-scalar,
         * we have to use language rules to print it as
@@ -342,47 +347,37 @@ void
 print_scalar_formatted (void *valaddr, struct type *type, int format, int size,
                        struct ui_file *stream)
 {
-  LONGEST val_long;
+  LONGEST val_long = 0;
   unsigned int len = TYPE_LENGTH (type);
 
-  if (len > sizeof (LONGEST)
-      && (format == 't'
-         || format == 'c'
-         || format == 'o'
-         || format == 'u'
-         || format == 'd'
-         || format == 'x'))
+  if (len > sizeof(LONGEST) &&
+      (TYPE_CODE (type) == TYPE_CODE_INT
+       || TYPE_CODE (type) == TYPE_CODE_ENUM))
     {
-      if (!TYPE_UNSIGNED (type)
-         || !extract_long_unsigned_integer (valaddr, len, &val_long))
+      switch (format)
        {
-         /* We can't print it normally, but we can print it in hex.
-            Printing it in the wrong radix is more useful than saying
-            "use /x, you dummy".  */
-         /* FIXME:  we could also do octal or binary if that was the
-            desired format.  */
-         /* FIXME:  we should be using the size field to give us a
-            minimum field width to print.  */
-
-         if (format == 'o')
-           print_octal_chars (stream, valaddr, len);
-         else if (format == 'd')
-           print_decimal_chars (stream, valaddr, len);
-         else if (format == 't')
-           print_binary_chars (stream, valaddr, len);
-         else
-           /* replace with call to print_hex_chars? Looks
-              like val_print_type_code_int is redoing
-              work.  - edie */
-
-           val_print_type_code_int (type, valaddr, stream);
-
+       case 'o':
+         print_octal_chars (stream, valaddr, len);
          return;
-       }
-
-      /* If we get here, extract_long_unsigned_integer set val_long.  */
+       case 'u':
+       case 'd':
+         print_decimal_chars (stream, valaddr, len);
+         return;
+       case 't':
+         print_binary_chars (stream, valaddr, len);
+         return;
+       case 'x':
+         print_hex_chars (stream, valaddr, len);
+         return;
+       case 'c':
+         print_char_chars (stream, valaddr, len);
+         return;
+       default:
+         break;
+       };
     }
-  else if (format != 'f')
+
+  if (format != 'f')
     val_long = unpack_long (type, valaddr);
 
   /* If the value is a pointer, and pointers and addresses are not the
@@ -504,10 +499,8 @@ print_scalar_formatted (void *valaddr, struct type *type, int format, int size,
            if (*cp == '\0')
              cp--;
          }
-       strcpy (buf, local_binary_format_prefix ());
-       strcat (buf, cp);
-       strcat (buf, local_binary_format_suffix ());
-       fprintf_filtered (stream, buf);
+       strcpy (buf, cp);
+       fputs_filtered (buf, stream);
       }
       break;
 
@@ -772,12 +765,12 @@ static struct type *examine_g_type;
 static void
 do_examine (struct format_data fmt, CORE_ADDR addr, asection *sect)
 {
-  register char format = 0;
-  register char size;
-  register int count = 1;
+  char format = 0;
+  char size;
+  int count = 1;
   struct type *val_type = NULL;
-  register int i;
-  register int maxelts;
+  int i;
+  int maxelts;
 
   format = fmt.format;
   size = fmt.size;
@@ -872,8 +865,8 @@ static void
 print_command_1 (char *exp, int inspect, int voidprint)
 {
   struct expression *expr;
-  register struct cleanup *old_chain = 0;
-  register char format = 0;
+  struct cleanup *old_chain = 0;
+  char format = 0;
   struct value *val;
   struct format_data fmt;
   int cleanup = 0;
@@ -941,7 +934,6 @@ print_command_1 (char *exp, int inspect, int voidprint)
   inspect_it = 0;              /* Reset print routines to normal */
 }
 
-/* ARGSUSED */
 static void
 print_command (char *exp, int from_tty)
 {
@@ -949,7 +941,6 @@ print_command (char *exp, int from_tty)
 }
 
 /* Same as print, except in epoch, it gets its own window */
-/* ARGSUSED */
 static void
 inspect_command (char *exp, int from_tty)
 {
@@ -959,20 +950,18 @@ inspect_command (char *exp, int from_tty)
 }
 
 /* Same as print, except it doesn't print void results. */
-/* ARGSUSED */
 static void
 call_command (char *exp, int from_tty)
 {
   print_command_1 (exp, 0, 0);
 }
 
-/* ARGSUSED */
 void
 output_command (char *exp, int from_tty)
 {
   struct expression *expr;
-  register struct cleanup *old_chain;
-  register char format = 0;
+  struct cleanup *old_chain;
+  char format = 0;
   struct value *val;
   struct format_data fmt;
 
@@ -1001,18 +990,16 @@ output_command (char *exp, int from_tty)
   do_cleanups (old_chain);
 }
 
-/* ARGSUSED */
 static void
 set_command (char *exp, int from_tty)
 {
   struct expression *expr = parse_expression (exp);
-  register struct cleanup *old_chain =
+  struct cleanup *old_chain =
     make_cleanup (free_current_contents, &expr);
   evaluate_expression (expr);
   do_cleanups (old_chain);
 }
 
-/* ARGSUSED */
 static void
 sym_info (char *arg, int from_tty)
 {
@@ -1057,14 +1044,13 @@ sym_info (char *arg, int from_tty)
     printf_filtered ("No symbol matches %s.\n", arg);
 }
 
-/* ARGSUSED */
 static void
 address_info (char *exp, int from_tty)
 {
-  register struct symbol *sym;
-  register struct minimal_symbol *msymbol;
-  register long val;
-  register long basereg;
+  struct symbol *sym;
+  struct minimal_symbol *msymbol;
+  long val;
+  long basereg;
   asection *section;
   CORE_ADDR load_addr;
   int is_a_field_of_this;      /* C++: lookup_symbol sets this to nonzero
@@ -1147,7 +1133,12 @@ address_info (char *exp, int from_tty)
 
     case LOC_COMPUTED:
     case LOC_COMPUTED_ARG:
-      (SYMBOL_LOCATION_FUNCS (sym)->describe_location) (sym, gdb_stdout);
+      /* FIXME: cagney/2004-01-26: It should be possible to
+        unconditionally call the SYMBOL_OPS method when available.
+        Unfortunately DWARF 2 stores the frame-base (instead of the
+        function) location in a function's symbol.  Oops!  For the
+        moment enable this when/where applicable.  */
+      SYMBOL_OPS (sym)->describe_location (sym, gdb_stdout);
       break;
 
     case LOC_REGISTER:
@@ -1262,12 +1253,6 @@ address_info (char *exp, int from_tty)
                        val, REGISTER_NAME (basereg));
       break;
 
-    case LOC_THREAD_LOCAL_STATIC:
-      printf_filtered ("a thread-local variable at offset %ld in the "
-                       "thread-local storage for `%s'",
-                       val, SYMBOL_OBJFILE (sym)->name);
-      break;
-
     case LOC_OPTIMIZED_OUT:
       printf_filtered ("optimized out");
       break;
@@ -1360,15 +1345,15 @@ static void
 display_command (char *exp, int from_tty)
 {
   struct format_data fmt;
-  register struct expression *expr;
-  register struct display *new;
+  struct expression *expr;
+  struct display *new;
   int display_it = 1;
 
 #if defined(TUI)
   /* NOTE: cagney/2003-02-13 The `tui_active' was previously
      `tui_version'.  */
-  if (tui_active && *exp == '$')
-    display_it = (tui_set_layout (exp) == TUI_FAILURE);
+  if (tui_active && exp != NULL && *exp == '$')
+    display_it = (tui_set_layout_for_display_command (exp) == TUI_FAILURE);
 #endif
 
   if (display_it)
@@ -1429,7 +1414,7 @@ free_display (struct display *d)
 void
 clear_displays (void)
 {
-  register struct display *d;
+  struct display *d;
 
   while ((d = display_chain) != NULL)
     {
@@ -1444,7 +1429,7 @@ clear_displays (void)
 static void
 delete_display (int num)
 {
-  register struct display *d1, *d;
+  struct display *d1, *d;
 
   if (!display_chain)
     error ("No display number %d.", num);
@@ -1476,9 +1461,9 @@ delete_display (int num)
 static void
 undisplay_command (char *args, int from_tty)
 {
-  register char *p = args;
-  register char *p1;
-  register int num;
+  char *p = args;
+  char *p1;
+  int num;
 
   if (args == 0)
     {
@@ -1599,7 +1584,7 @@ do_one_display (struct display *d)
 void
 do_displays (void)
 {
-  register struct display *d;
+  struct display *d;
 
   for (d = display_chain; d; d = d->next)
     do_one_display (d);
@@ -1611,7 +1596,7 @@ do_displays (void)
 void
 disable_display (int num)
 {
-  register struct display *d;
+  struct display *d;
 
   for (d = display_chain; d; d = d->next)
     if (d->number == num)
@@ -1637,7 +1622,7 @@ disable_current_display (void)
 static void
 display_info (char *ignore, int from_tty)
 {
-  register struct display *d;
+  struct display *d;
 
   if (!display_chain)
     printf_unfiltered ("There are no auto-display expressions now.\n");
@@ -1664,10 +1649,10 @@ Num Enb Expression\n");
 static void
 enable_display (char *args, int from_tty)
 {
-  register char *p = args;
-  register char *p1;
-  register int num;
-  register struct display *d;
+  char *p = args;
+  char *p1;
+  int num;
+  struct display *d;
 
   if (p == 0)
     {
@@ -1699,13 +1684,12 @@ enable_display (char *args, int from_tty)
       }
 }
 
-/* ARGSUSED */
 static void
 disable_display_command (char *args, int from_tty)
 {
-  register char *p = args;
-  register char *p1;
-  register struct display *d;
+  char *p = args;
+  char *p1;
+  struct display *d;
 
   if (p == 0)
     {
@@ -1742,12 +1726,11 @@ print_variable_value (struct symbol *var, struct frame_info *frame,
   value_print (val, stream, 0, Val_pretty_default);
 }
 
-/* ARGSUSED */
 static void
 printf_command (char *arg, int from_tty)
 {
-  register char *f = NULL;
-  register char *s = arg;
+  char *f = NULL;
+  char *s = arg;
   char *string = NULL;
   struct value **val_args;
   char *substrings;
@@ -2009,7 +1992,7 @@ printf_command (char *arg, int from_tty)
        current_substring += strlen (current_substring) + 1;
       }
     /* Print the portion of the format string after the last argument.  */
-    printf_filtered (last_arg);
+    puts_filtered (last_arg);
   }
   do_cleanups (old_cleanups);
 }
@@ -2161,18 +2144,18 @@ but no count or size letter (see \"x\" command).", NULL));
 environment, the value is printed in its own window.");
   set_cmd_completer (c, location_completer);
 
-  add_show_from_set (
-                add_set_cmd ("max-symbolic-offset", no_class, var_uinteger,
-                             (char *) &max_symbolic_offset,
+  deprecated_add_show_from_set
+    (add_set_cmd ("max-symbolic-offset", no_class, var_uinteger,
+                 (char *) &max_symbolic_offset,
        "Set the largest offset that will be printed in <symbol+1234> form.",
-                             &setprintlist),
-                     &showprintlist);
-  add_show_from_set (
-                     add_set_cmd ("symbol-filename", no_class, var_boolean,
-                                  (char *) &print_symbol_filename,
-          "Set printing of source filename and line number with <symbol>.",
-                                  &setprintlist),
-                     &showprintlist);
+                 &setprintlist),
+     &showprintlist);
+  deprecated_add_show_from_set
+    (add_set_cmd ("symbol-filename", no_class, var_boolean,
+                 (char *) &print_symbol_filename, "\
+Set printing of source filename and line number with <symbol>.",
+                 &setprintlist),
+     &showprintlist);
 
   /* For examine/instruction a single byte quantity is specified as
      the data.  This avoids problems with value_at_lazy() requiring a
This page took 0.029133 seconds and 4 git commands to generate.