2001-09-24 Orjan Friberg <orjanf@axis.com>
[binutils-gdb.git] / gdb / printcmd.c
index 66dc512df67c2762f9cde41e7a092d644ce101cc..8ae6293700afdbfb3ca2730f4a1a3d6f25ae870f 100644 (file)
@@ -37,6 +37,7 @@
 #include "annotate.h"
 #include "symfile.h"           /* for overlay functions */
 #include "objfiles.h"          /* ditto */
+#include "completer.h"         /* for completion functions */
 #ifdef UI_OUT
 #include "ui-out.h"
 #endif
@@ -111,7 +112,7 @@ struct display
     /* Innermost block required by this expression when evaluated */
     struct block *block;
     /* Status of this display (enabled or disabled) */
-    enum enable status;
+    int enabled_p;
   };
 
 /* Chain of expressions whose values should be displayed
@@ -389,6 +390,12 @@ print_scalar_formatted (char *valaddr, struct type *type, int format, int size,
   else if (format != 'f')
     val_long = unpack_long (type, valaddr);
 
+  /* If the value is a pointer, and pointers and addresses are not the
+     same, then at this point, the value's length is TARGET_ADDR_BIT, not
+     TYPE_LENGTH (type).  */
+  if (TYPE_CODE (type) == TYPE_CODE_PTR)
+    len = TARGET_ADDR_BIT;
+
   /* If we are printing it as unsigned, truncate it in case it is actually
      a negative signed value (e.g. "print/u (short)-1" should print 65535
      (if shorts are 16 bits) instead of 4294967295).  */
@@ -449,9 +456,9 @@ print_scalar_formatted (char *valaddr, struct type *type, int format, int size,
 
     case 'f':
       if (len == sizeof (float))
-         type = builtin_type_float;
+        type = builtin_type_float;
       else if (len == sizeof (double))
-         type = builtin_type_double;
+        type = builtin_type_double;
       print_floating (valaddr, type, stream);
       break;
 
@@ -1389,8 +1396,7 @@ display_command (char *exp, int from_tty)
 
 #if defined(TUI)
   if (tui_version && *exp == '$')
-    display_it = ((TuiStatus) tuiDo (
-                 (TuiOpaqueFuncPtr) tui_vSetLayoutTo, exp) == TUI_FAILURE);
+    display_it = (tui_set_layout (exp) == TUI_FAILURE);
 #endif
 
   if (display_it)
@@ -1427,7 +1433,7 @@ display_command (char *exp, int from_tty)
       new->next = display_chain;
       new->number = ++display_number;
       new->format = fmt;
-      new->status = enabled;
+      new->enabled_p = 1;
       display_chain = new;
 
       if (from_tty && target_has_execution)
@@ -1538,7 +1544,7 @@ do_one_display (struct display *d)
 {
   int within_current_scope;
 
-  if (d->status == disabled)
+  if (d->enabled_p == 0)
     return;
 
   if (d->block)
@@ -1638,7 +1644,7 @@ disable_display (int num)
   for (d = display_chain; d; d = d->next)
     if (d->number == num)
       {
-       d->status = disabled;
+       d->enabled_p = 0;
        return;
       }
   printf_unfiltered ("No display number %d.\n", num);
@@ -1669,7 +1675,7 @@ Num Enb Expression\n");
 
   for (d = display_chain; d; d = d->next)
     {
-      printf_filtered ("%d:   %c  ", d->number, "ny"[(int) d->status]);
+      printf_filtered ("%d:   %c  ", d->number, "ny"[(int) d->enabled_p]);
       if (d->format.size)
        printf_filtered ("/%d%c%c ", d->format.count, d->format.size,
                         d->format.format);
@@ -1694,7 +1700,7 @@ enable_display (char *args, int from_tty)
   if (p == 0)
     {
       for (d = display_chain; d; d = d->next)
-       d->status = enabled;
+       d->enabled_p = 1;
     }
   else
     while (*p)
@@ -1710,7 +1716,7 @@ enable_display (char *args, int from_tty)
        for (d = display_chain; d; d = d->next)
          if (d->number == num)
            {
-             d->status = enabled;
+             d->enabled_p = 1;
              goto win;
            }
        printf_unfiltered ("No display number %d.\n", num);
@@ -1732,7 +1738,7 @@ disable_display_command (char *args, int from_tty)
   if (p == 0)
     {
       for (d = display_chain; d; d = d->next)
-       d->status = disabled;
+       d->enabled_p = 0;
     }
   else
     while (*p)
@@ -1939,9 +1945,6 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
 
       if (val)
        {
-         if (GDB_TARGET_IS_D10V
-             && SYMBOL_CLASS (sym) == LOC_REGPARM && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_PTR)
-           TYPE_LENGTH (VALUE_TYPE (val)) = 2;
 #ifdef UI_OUT
          val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), 0,
                     VALUE_ADDRESS (val),
@@ -2331,9 +2334,7 @@ disassemble_command (char *arg, int from_tty)
        error ("No function contains program counter for selected frame.\n");
 #if defined(TUI)
       else if (tui_version)
-       low = (CORE_ADDR) tuiDo ((TuiOpaqueFuncPtr) tui_vGetLowDisassemblyAddress,
-                                (Opaque) low,
-                                (Opaque) pc);
+       low = tuiGetLowDisassemblyAddress (low, pc);
 #endif
       low += FUNCTION_START_OFFSET;
     }
@@ -2345,9 +2346,7 @@ disassemble_command (char *arg, int from_tty)
        error ("No function contains specified address.\n");
 #if defined(TUI)
       else if (tui_version)
-       low = (CORE_ADDR) tuiDo ((TuiOpaqueFuncPtr) tui_vGetLowDisassemblyAddress,
-                                (Opaque) low,
-                                (Opaque) pc);
+       low = tuiGetLowDisassemblyAddress (low, pc);
 #endif
 #if 0
       if (overlay_debugging)
@@ -2374,8 +2373,7 @@ disassemble_command (char *arg, int from_tty)
     }
 
 #if defined(TUI)
-  if (!tui_version ||
-      m_winPtrIsNull (disassemWin) || !disassemWin->generic.isVisible)
+  if (!tui_is_window_visible (DISASSEM_WIN))
 #endif
     {
       printf_filtered ("Dump of assembler code ");
@@ -2423,8 +2421,7 @@ disassemble_command (char *arg, int from_tty)
 #if defined(TUI)
   else
     {
-      tuiDo ((TuiOpaqueFuncPtr) tui_vAddWinToLayout, DISASSEM_WIN);
-      tuiDo ((TuiOpaqueFuncPtr) tui_vUpdateSourceWindowsWithAddr, low);
+      tui_show_assembly (low);
     }
 #endif
 }
@@ -2444,6 +2441,8 @@ print_insn (CORE_ADDR memaddr, struct ui_file *stream)
     TARGET_PRINT_INSN_INFO->mach = TARGET_ARCHITECTURE->mach;
   /* else: should set .mach=0 but some disassemblers don't grok this */
 
+  TARGET_PRINT_INSN_INFO->stream = stream;
+
   return TARGET_PRINT_INSN (memaddr, TARGET_PRINT_INSN_INFO);
 }
 \f
@@ -2451,6 +2450,8 @@ print_insn (CORE_ADDR memaddr, struct ui_file *stream)
 void
 _initialize_printcmd (void)
 {
+  struct cmd_list_element *c;
+
   current_display_number = -1;
 
   add_info ("address", address_info,
@@ -2473,11 +2474,12 @@ Defaults for format and size letters are those previously used.\n\
 Default count is 1.  Default address is following last thing printed\n\
 with this command or \"print\".", NULL));
 
-  add_com ("disassemble", class_vars, disassemble_command,
-          "Disassemble a specified section of memory.\n\
+  c = add_com ("disassemble", class_vars, disassemble_command,
+              "Disassemble a specified section of memory.\n\
 Default is the function surrounding the pc of the selected frame.\n\
 With a single argument, the function surrounding that address is dumped.\n\
 Two arguments are taken as a range of memory to dump.");
+  c->completer = location_completer;
   if (xdb_commands)
     add_com_alias ("va", "disassemble", class_xdb, 0);
 
@@ -2555,11 +2557,12 @@ variable in the program being debugged.  EXP is any valid expression.\n",
 You can see these environment settings with the \"show\" command.", NULL));
 
   /* "call" is the same as "set", but handy for dbx users to call fns. */
-  add_com ("call", class_vars, call_command,
-          "Call a function in the program.\n\
+  c = add_com ("call", class_vars, call_command,
+              "Call a function in the program.\n\
 The argument is the function name and arguments, in the notation of the\n\
 current working language.  The result is printed and saved in the value\n\
 history, if it is not void.");
+  c->completer = location_completer;
 
   add_cmd ("variable", class_vars, set_command,
           "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
@@ -2570,7 +2573,7 @@ variable in the program being debugged.  EXP is any valid expression.\n\
 This may usually be abbreviated to simply \"set\".",
           &setlist);
 
-  add_com ("print", class_vars, print_command,
+  c = add_com ("print", class_vars, print_command,
           concat ("Print value of expression EXP.\n\
 Variables accessible are those of the lexical environment of the selected\n\
 stack frame, plus all those whose scope is global or an entire file.\n\
@@ -2592,11 +2595,13 @@ resides in memory.\n",
                   "\n\
 EXP may be preceded with /FMT, where FMT is a format letter\n\
 but no count or size letter (see \"x\" command).", NULL));
+  c->completer = location_completer;
   add_com_alias ("p", "print", class_vars, 1);
 
-  add_com ("inspect", class_vars, inspect_command,
+  c = add_com ("inspect", class_vars, inspect_command,
           "Same as \"print\" command, except that if you are running in the epoch\n\
 environment, the value is printed in its own window.");
+  c->completer = location_completer;
 
   add_show_from_set (
                 add_set_cmd ("max-symbolic-offset", no_class, var_uinteger,