2004-01-02 Michael Chastain <mec.gnu@mindspring.com>
[deliverable/binutils-gdb.git] / gdb / infcmd.c
index c47c9eac876d55116ecd8f9fd748b7623ed1c5b0..2c8631eb3ba634ef9a4200caef44a3cf49d1d6bd 100644 (file)
@@ -44,6 +44,7 @@
 #include "reggroups.h"
 #include "block.h"
 #include <ctype.h>
+#include "gdb_assert.h"
 
 /* Functions exported for general use, in inferior.h: */
 
@@ -261,7 +262,6 @@ notice_args_read (char *args, int from_tty, struct cmd_list_element *c)
 \f
 /* Compute command-line string given argument vector.  This does the
    same shell processing as fork_inferior.  */
-/* ARGSUSED */
 char *
 construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv)
 {
@@ -370,7 +370,6 @@ strip_bg_char (char **args)
   return 0;
 }
 
-/* ARGSUSED */
 void
 tty_command (char *file, int from_tty)
 {
@@ -543,7 +542,6 @@ continue_command (char *proc_count_exp, int from_tty)
 \f
 /* Step until outside of current statement.  */
 
-/* ARGSUSED */
 static void
 step_command (char *count_string, int from_tty)
 {
@@ -552,7 +550,6 @@ step_command (char *count_string, int from_tty)
 
 /* Likewise, but skip over subroutine calls as if single instructions.  */
 
-/* ARGSUSED */
 static void
 next_command (char *count_string, int from_tty)
 {
@@ -561,14 +558,12 @@ next_command (char *count_string, int from_tty)
 
 /* Likewise, but step only one instruction.  */
 
-/* ARGSUSED */
 void
 stepi_command (char *count_string, int from_tty)
 {
   step_1 (0, 1, count_string);
 }
 
-/* ARGSUSED */
 void
 nexti_command (char *count_string, int from_tty)
 {
@@ -584,7 +579,7 @@ disable_longjmp_breakpoint_cleanup (void *ignore)
 static void
 step_1 (int skip_subroutines, int single_inst, char *count_string)
 {
-  register int count = 1;
+  int count = 1;
   struct frame_info *frame;
   struct cleanup *cleanups = 0;
   int async_exec = 0;
@@ -806,7 +801,7 @@ which has no line number information.\n", name);
 static void
 jump_command (char *arg, int from_tty)
 {
-  register CORE_ADDR addr;
+  CORE_ADDR addr;
   struct symtabs_and_lines sals;
   struct symtab_and_line sal;
   struct symbol *fn;
@@ -958,7 +953,6 @@ signal_command (char *signum_exp, int from_tty)
    we set.  This may involve changes to wait_for_inferior and the
    proceed status code.  */
 
-/* ARGSUSED */
 static void
 until_next_command (int from_tty)
 {
@@ -1077,40 +1071,72 @@ print_return_value (int structure_return, struct type *value_type)
 
   if (!structure_return)
     {
-      value = value_being_returned (value_type, stop_registers, 0, 0);
+      value = register_value_being_returned (value_type, stop_registers);
       stb = ui_out_stream_new (uiout);
       ui_out_text (uiout, "Value returned is ");
-      ui_out_field_fmt (uiout, "gdb-result-var", "$%d", 
-                       record_latest_value (value));
+      ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
       ui_out_text (uiout, " = ");
       value_print (value, stb->stream, 0, Val_no_prettyprint);
       ui_out_field_stream (uiout, "return-value", stb);
       ui_out_text (uiout, "\n");
     }
-  else
+  /* FIXME: 2003-09-27: When returning from a nested inferior function
+     call, it's possible (with no help from the architecture vector)
+     to locate and return/print a "struct return" value.  This is just
+     a more complicated case of what is already being done in in the
+     inferior function call code.  In fact, when inferior function
+     calls are made async, this will likely be made the norm.  */
+  else if (gdbarch_return_value_p (current_gdbarch))
+    /* We cannot determine the contents of the structure because it is
+       on the stack, and we don't know where, since we did not
+       initiate the call, as opposed to the call_function_by_hand
+       case.  */
     {
-#ifdef VALUE_RETURNED_FROM_STACK
-      /* We cannot determine the contents of the structure because it
-        is on the stack, and we don't know where, since we did not
-        initiate the call, as opposed to the call_function_by_hand
-        case.  */
-      value = 0;
+      gdb_assert (gdbarch_return_value (current_gdbarch, value_type, NULL, NULL, NULL)
+                 == RETURN_VALUE_STRUCT_CONVENTION);
       ui_out_text (uiout, "Value returned has type: ");
       ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
       ui_out_text (uiout, ".");
       ui_out_text (uiout, " Cannot determine contents\n");
-#else
-      value = value_being_returned (value_type, stop_registers, 
-                                   structure_return, 0);
+      return;
+    }
+  else
+    {
+      if (EXTRACT_STRUCT_VALUE_ADDRESS_P ())
+       {
+         CORE_ADDR addr = EXTRACT_STRUCT_VALUE_ADDRESS (stop_registers);
+         if (!addr)
+           error ("Function return value unknown.");
+         value = value_at (value_type, addr, NULL);
+       }
+      else if (DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS_P ())
+       {
+         char *buf = deprecated_grub_regcache_for_registers (stop_registers);
+         CORE_ADDR addr = DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS (buf);
+         if (!addr)
+           error ("Function return value unknown.");
+         value = value_at (value_type, addr, NULL);
+       }
+      else
+       {
+         /* It is "struct return" yet the value is being extracted,
+             presumably from registers, using EXTRACT_RETURN_VALUE.
+             This doesn't make sense.  Unfortunately, the legacy
+             interfaces allowed this behavior.  Sigh!  */
+         value = allocate_value (value_type);
+         CHECK_TYPEDEF (value_type);
+         /* If the function returns void, don't bother fetching the
+            return value.  */
+         EXTRACT_RETURN_VALUE (value_type, stop_registers,
+                               VALUE_CONTENTS_RAW (value));
+       }
       stb = ui_out_stream_new (uiout);
       ui_out_text (uiout, "Value returned is ");
-      ui_out_field_fmt (uiout, "gdb-result-var", "$%d", 
-                       record_latest_value (value));
+      ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
       ui_out_text (uiout, " = ");
       value_print (value, stb->stream, 0, Val_no_prettyprint);
       ui_out_field_stream (uiout, "return-value", stb);
       ui_out_text (uiout, "\n");
-#endif
     }
 }
 
@@ -1125,7 +1151,7 @@ print_return_value (int structure_return, struct type *value_type)
 void
 finish_command_continuation (struct continuation_arg *arg)
 {
-  register struct symbol *function;
+  struct symbol *function;
   struct breakpoint *breakpoint;
   struct cleanup *cleanups;
 
@@ -1153,9 +1179,7 @@ finish_command_continuation (struct continuation_arg *arg)
 
       funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
 
-      struct_return = using_struct_return (value_of_variable (function, NULL),
-                                          funcaddr,
-                                          check_typedef (value_type),
+      struct_return = using_struct_return (check_typedef (value_type),
                                           BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
 
       print_return_value (struct_return, value_type); 
@@ -1170,8 +1194,8 @@ static void
 finish_command (char *arg, int from_tty)
 {
   struct symtab_and_line sal;
-  register struct frame_info *frame;
-  register struct symbol *function;
+  struct frame_info *frame;
+  struct symbol *function;
   struct breakpoint *breakpoint;
   struct cleanup *old_chain;
   struct continuation_arg *arg1, *arg2, *arg3;
@@ -1281,9 +1305,7 @@ finish_command (char *arg, int from_tty)
          funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
 
          struct_return =
-           using_struct_return (value_of_variable (function, NULL),
-                                funcaddr,
-                                check_typedef (value_type),
+           using_struct_return (check_typedef (value_type),
                        BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
 
          print_return_value (struct_return, value_type); 
@@ -1292,7 +1314,6 @@ finish_command (char *arg, int from_tty)
     }
 }
 \f
-/* ARGSUSED */
 static void
 program_info (char *args, int from_tty)
 {
@@ -1345,7 +1366,7 @@ environment_info (char *var, int from_tty)
 {
   if (var)
     {
-      register char *val = get_in_environ (inferior_environ, var);
+      char *val = get_in_environ (inferior_environ, var);
       if (val)
        {
          puts_filtered (var);
@@ -1362,7 +1383,7 @@ environment_info (char *var, int from_tty)
     }
   else
     {
-      register char **vector = environ_vector (inferior_environ);
+      char **vector = environ_vector (inferior_environ);
       while (*vector)
        {
          puts_filtered (*vector++);
@@ -1374,7 +1395,7 @@ environment_info (char *var, int from_tty)
 static void
 set_environment_command (char *arg, int from_tty)
 {
-  register char *p, *val, *var;
+  char *p, *val, *var;
   int nullset = 0;
 
   if (arg == 0)
@@ -1454,7 +1475,6 @@ unset_environment_command (char *var, int from_tty)
 
 static const char path_var_name[] = "PATH";
 
-/* ARGSUSED */
 static void
 path_info (char *args, int from_tty)
 {
@@ -1484,9 +1504,6 @@ path_command (char *dirname, int from_tty)
 }
 \f
 
-#ifdef REGISTER_NAMES
-char *gdb_register_names[] = REGISTER_NAMES;
-#endif
 /* Print out the machine register regnum. If regnum is -1, print all
    registers (print_all == 1) or all non-float and non-vector
    registers (print_all == 0).
@@ -1565,7 +1582,7 @@ default_print_registers_info (struct gdbarch *gdbarch,
       else
        {
          memcpy (virtual_buffer, raw_buffer,
-                 REGISTER_VIRTUAL_SIZE (i));
+                 DEPRECATED_REGISTER_VIRTUAL_SIZE (i));
        }
 
       /* If virtual format is floating, print it that way, and in raw
@@ -1578,13 +1595,13 @@ default_print_registers_info (struct gdbarch *gdbarch,
                     file, 0, 1, 0, Val_pretty_default);
 
          fprintf_filtered (file, "\t(raw 0x");
-         for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
+         for (j = 0; j < DEPRECATED_REGISTER_RAW_SIZE (i); j++)
            {
              int idx;
              if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
                idx = j;
              else
-               idx = REGISTER_RAW_SIZE (i) - 1 - j;
+               idx = DEPRECATED_REGISTER_RAW_SIZE (i) - 1 - j;
              fprintf_filtered (file, "%02x", (unsigned char) raw_buffer[idx]);
            }
          fprintf_filtered (file, ")");
@@ -1612,7 +1629,7 @@ void
 registers_info (char *addr_exp, int fpregs)
 {
   int regnum, numregs;
-  register char *end;
+  char *end;
 
   if (!target_has_registers)
     error ("The program has no registers now.");
@@ -1681,24 +1698,24 @@ registers_info (char *addr_exp, int fpregs)
 
       /* A register group?  */
       {
-       struct reggroup *const *group;
-       for (group = reggroups (current_gdbarch);
-            (*group) != NULL;
-            group++)
+       struct reggroup *group;
+       for (group = reggroup_next (current_gdbarch, NULL);
+            group != NULL;
+            group = reggroup_next (current_gdbarch, group))
          {
            /* Don't bother with a length check.  Should the user
               enter a short register group name, go with the first
               group that matches.  */
-           if (strncmp (start, reggroup_name ((*group)), end - start) == 0)
+           if (strncmp (start, reggroup_name (group), end - start) == 0)
              break;
          }
-       if ((*group) != NULL)
+       if (group != NULL)
          {
            int regnum;
            for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
              {
                if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
-                                                (*group)))
+                                                group))
                  gdbarch_print_registers_info (current_gdbarch,
                                                gdb_stdout, deprecated_selected_frame,
                                                regnum, fpregs);
@@ -1915,7 +1932,6 @@ interrupt_target_command (char *args, int from_tty)
     }
 }
 
-/* ARGSUSED */
 static void
 print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
                  struct frame_info *frame, const char *args)
@@ -1952,7 +1968,6 @@ float_info (char *args, int from_tty)
   print_float_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
 }
 \f
-/* ARGSUSED */
 static void
 unset_command (char *args, int from_tty)
 {
This page took 0.029568 seconds and 4 git commands to generate.