2004-01-02 Michael Chastain <mec.gnu@mindspring.com>
[deliverable/binutils-gdb.git] / gdb / infcmd.c
index f232fd5a7ed50edb540d218000f22a712246fec2..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: */
 
@@ -1070,7 +1071,7 @@ print_return_value (int structure_return, struct type *value_type)
 
   if (!structure_return)
     {
-      value = value_being_returned (value_type, stop_registers, structure_return);
+      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));
@@ -1079,19 +1080,56 @@ print_return_value (int structure_return, struct type *value_type)
       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.  */
     {
-      /* 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 DEPRECATED_VALUE_RETURNED_FROM_STACK
-      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);
+      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));
@@ -1099,7 +1137,6 @@ print_return_value (int structure_return, struct type *value_type)
       value_print (value, stb->stream, 0, Val_no_prettyprint);
       ui_out_field_stream (uiout, "return-value", stb);
       ui_out_text (uiout, "\n");
-#endif
     }
 }
 
@@ -1558,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, ")");
This page took 0.037767 seconds and 4 git commands to generate.