* completer.c (gdb_completer_loc_break_characters): New variable.
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index 8210b559675570ad57e5a3bfb7ff372bd4d0232d..746a0646cc0624aa61087288085b8f435a9470a5 100644 (file)
@@ -1,7 +1,7 @@
 /* Print values for GNU debugger GDB.
 
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1993, 1994, 1995,
-   1998, 2000 Free Software Foundation, Inc.
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -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
@@ -249,7 +250,7 @@ decode_format (char **string_ptr, int oformat, int osize)
          val.size = osize ? 'h' : osize;
        else
          /* Bad value for TARGET_PTR_BIT */
-         abort ();
+         internal_error (__FILE__, __LINE__, "failed internal consistency check");
        break;
       case 'f':
        /* Floating point has to be word or giantword.  */
@@ -456,7 +457,7 @@ print_scalar_formatted (char *valaddr, struct type *type, int format, int size,
       break;
 
     case 0:
-      abort ();
+      internal_error (__FILE__, __LINE__, "failed internal consistency check");
 
     case 't':
       /* Binary; 't' stands for "two".  */
@@ -718,17 +719,19 @@ build_address_symbolic (CORE_ADDR addr,  /* IN */
 void
 print_address_numeric (CORE_ADDR addr, int use_local, struct ui_file *stream)
 {
-  /* Truncate address to the size of a target pointer, avoiding shifts
+  /* Truncate address to the size of a target address, avoiding shifts
      larger or equal than the width of a CORE_ADDR.  The local
-     variable PTR_BIT stops the compiler reporting a shift overflow
-     when it won't occure. */
+     variable ADDR_BIT stops the compiler reporting a shift overflow
+     when it won't occur. */
   /* NOTE: This assumes that the significant address information is
      kept in the least significant bits of ADDR - the upper bits were
      either zero or sign extended.  Should ADDRESS_TO_POINTER() or
      some ADDRESS_TO_PRINTABLE() be used to do the conversion?  */
-  int ptr_bit = TARGET_PTR_BIT;
-  if (ptr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
-    addr &= ((CORE_ADDR) 1 << ptr_bit) - 1;
+
+  int addr_bit = TARGET_ADDR_BIT;
+
+  if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
+    addr &= ((CORE_ADDR) 1 << addr_bit) - 1;
   print_longest (stream, 'x', use_local, (ULONGEST) addr);
 }
 
@@ -1334,8 +1337,8 @@ x_command (char *exp, int from_tty)
        val = value_ind (val);
       /* In rvalue contexts, such as this, functions are coerced into
          pointers to functions.  This makes "x/i main" work.  */
-      if (                     /* last_format == 'i'
-                                  && */ TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC
+      if (/* last_format == 'i'  && */ 
+         TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC
           && VALUE_LVAL (val) == lval_memory)
        next_address = VALUE_ADDRESS (val);
       else
@@ -1438,8 +1441,8 @@ display_command (char *exp, int from_tty)
 static void
 free_display (struct display *d)
 {
-  free ((PTR) d->exp);
-  free ((PTR) d);
+  xfree (d->exp);
+  xfree (d);
 }
 
 /* Clear out the display_chain.
@@ -1453,9 +1456,9 @@ clear_displays (void)
 
   while ((d = display_chain) != NULL)
     {
-      free ((PTR) d->exp);
+      xfree (d->exp);
       display_chain = d->next;
-      free ((PTR) d);
+      xfree (d);
     }
 }
 
@@ -1788,7 +1791,7 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
   /* Number of ints of arguments that we have printed so far.  */
   int args_printed = 0;
 #ifdef UI_OUT
-  struct cleanup *old_chain;
+  struct cleanup *old_chain, *list_chain;
   struct ui_stream *stb;
 
   stb = ui_out_stream_new (uiout);
@@ -1906,7 +1909,7 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
 
       annotate_arg_begin ();
 
-      ui_out_list_begin (uiout, NULL);
+      list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
       fprintf_symbol_filtered (stb->stream, SYMBOL_SOURCE_NAME (sym),
                            SYMBOL_LANGUAGE (sym), DMGL_PARAMS | DMGL_ANSI);
       ui_out_field_stream (uiout, "name", stb);
@@ -1949,7 +1952,8 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
       else
        ui_out_text (uiout, "???");
 
-      ui_out_list_end (uiout);
+      /* Invoke ui_out_tuple_end.  */
+      do_cleanups (list_chain);
 #else
          val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), 0,
                     VALUE_ADDRESS (val),
@@ -2075,11 +2079,7 @@ printf_command (char *arg, int from_tty)
              *f++ = '\\';
              break;
            case 'a':
-#ifdef __STDC__
              *f++ = '\a';
-#else
-             *f++ = '\007';    /* Bell */
-#endif
              break;
            case 'b':
              *f++ = '\b';
@@ -2452,6 +2452,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,
@@ -2474,11 +2476,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);
 
@@ -2556,11 +2559,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\
@@ -2571,7 +2575,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\
@@ -2593,11 +2597,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,
This page took 0.027635 seconds and 4 git commands to generate.