2003-07-30 Michael Snyder <msnyder@redhat.com>
authorMichael Snyder <msnyder@vmware.com>
Wed, 30 Jul 2003 20:59:10 +0000 (20:59 +0000)
committerMichael Snyder <msnyder@vmware.com>
Wed, 30 Jul 2003 20:59:10 +0000 (20:59 +0000)
* structs.h (value_being_returned): Add a struct_addr argument.
* infcall.c (call_function_by_hand): Pass struct_addr to
value_being_returned.
* infcmd.c (print_return_value): Pass zero as struct_addr.
* values.c (value_being_returned): If struct_addr is passed,
use it instead of trying to recover it from the inferior.

gdb/ChangeLog
gdb/infcall.c
gdb/infcmd.c
gdb/value.h
gdb/values.c

index 93baf91..69c2d6b 100644 (file)
@@ -1,3 +1,12 @@
+2003-07-30  Michael Snyder  <msnyder@redhat.com>
+
+       * structs.h (value_being_returned): Add a struct_addr argument.
+       * infcall.c (call_function_by_hand): Pass struct_addr to 
+       value_being_returned.
+       * infcmd.c (print_return_value): Pass zero as struct_addr.
+       * values.c (value_being_returned): If struct_addr is passed,
+       use it instead of trying to recover it from the inferior.
+
 2003-07-30  Kevin Buettner  <kevinb@redhat.com>
 
        * mn10300-tdep.c (analyze_dummy_frame): Pass ``pc'' so that
index 477fc0f..b00785c 100644 (file)
@@ -421,7 +421,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
       vector.  Hence this direct call.
 
       A follow-on change is to modify this interface so that it takes
-      thread OR frame OR tpid as a parameter, and returns a dummy
+      thread OR frame OR ptid as a parameter, and returns a dummy
       frame handle.  The handle can then be used further down as a
       parameter to generic_save_dummy_frame_tos().  Hmm, thinking
       about it, since everything is ment to be using generic dummy
@@ -445,7 +445,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
           On a RISC architecture, a void parameterless generic dummy
           frame (i.e., no parameters, no result) typically does not
           need to push anything the stack and hence can leave SP and
-          FP.  Similarly, a framelss (possibly leaf) function does
+          FP.  Similarly, a frameless (possibly leaf) function does
           not push anything on the stack and, hence, that too can
           leave FP and SP unchanged.  As a consequence, a sequence of
           void parameterless generic dummy frame calls to frameless
@@ -1056,8 +1056,10 @@ the function call).", name);
     }
   else
     {
-      struct value *retval = value_being_returned (value_type, retbuf,
-                                                  struct_return);
+      struct value *retval = value_being_returned (value_type,
+                                                  retbuf,
+                                                  struct_return,
+                                                  struct_addr);
       do_cleanups (retbuf_cleanup);
       return retval;
     }
index df7d950..c47c9ea 100644 (file)
@@ -1077,10 +1077,11 @@ print_return_value (int structure_return, struct type *value_type)
 
   if (!structure_return)
     {
-      value = value_being_returned (value_type, stop_registers, structure_return);
+      value = value_being_returned (value_type, stop_registers, 0, 0);
       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);
@@ -1088,20 +1089,23 @@ print_return_value (int structure_return, struct type *value_type)
     }
   else
     {
-      /* 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;
       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);
+      value = value_being_returned (value_type, stop_registers, 
+                                   structure_return, 0);
       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);
index d50626e..77d9d39 100644 (file)
@@ -420,7 +420,8 @@ extern struct value *value_subscript (struct value *array, struct value *idx);
 
 extern struct value *value_being_returned (struct type *valtype,
                                           struct regcache *retbuf,
-                                          int struct_return);
+                                          int struct_return,
+                                          CORE_ADDR struct_addr);
 
 extern struct value *value_in (struct value *element, struct value *set);
 
index 42395c8..7e7e9b1 100644 (file)
@@ -1212,31 +1212,36 @@ value_from_double (struct type *type, DOUBLEST num)
 /* ARGSUSED */
 struct value *
 value_being_returned (struct type *valtype, struct regcache *retbuf,
-                     int struct_return)
+                     int struct_return, CORE_ADDR struct_addr)
 {
   struct value *val;
   CORE_ADDR addr;
 
-  /* If this is not defined, just use EXTRACT_RETURN_VALUE instead.  */
-  if (EXTRACT_STRUCT_VALUE_ADDRESS_P ())
-    if (struct_return)
-      {
-       addr = EXTRACT_STRUCT_VALUE_ADDRESS (retbuf);
-       if (!addr)
-         error ("Function return value unknown.");
-       return value_at (valtype, addr, NULL);
-      }
-
-  /* If this is not defined, just use EXTRACT_RETURN_VALUE instead.  */
-  if (DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS_P ())
-    if (struct_return)
-      {
-       char *buf = deprecated_grub_regcache_for_registers (retbuf);
-       addr = DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS (buf);
-       if (!addr)
-         error ("Function return value unknown.");
-       return value_at (valtype, addr, NULL);
-      }
+  if (struct_return)
+    {
+      if (struct_addr != 0)
+       {
+         /* Struct return addr supplied by hand_function_call.  */
+         return value_at (valtype, struct_addr, NULL);
+       }
+      /* If one of these is not defined, just use EXTRACT_RETURN_VALUE
+        instead.  */
+      else if (EXTRACT_STRUCT_VALUE_ADDRESS_P ())
+       {
+         addr = EXTRACT_STRUCT_VALUE_ADDRESS (retbuf);
+         if (!addr)
+           error ("Function return value unknown.");
+         return value_at (valtype, addr, NULL);
+       }
+      else if (DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS_P ())
+       {
+         char *buf = deprecated_grub_regcache_for_registers (retbuf);
+         addr = DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS (buf);
+         if (!addr)
+           error ("Function return value unknown.");
+         return value_at (valtype, addr, NULL);
+       }
+    }
 
   val = allocate_value (valtype);
   CHECK_TYPEDEF (valtype);