daily update
[deliverable/binutils-gdb.git] / gdb / infcall.c
index e07cf00e3e0f1214ca7d651250503b99f78f2501..3f9c8713cf2a2ebf771c230be4ed9a5fb6e0509b 100644 (file)
@@ -228,6 +228,21 @@ value_arg_coerce (struct gdbarch *gdbarch, struct value *arg,
   return value_cast (type, arg);
 }
 
+/* Return the return type of a function with its first instruction exactly at
+   the PC address.  Return NULL otherwise.  */
+
+static struct type *
+find_function_return_type (CORE_ADDR pc)
+{
+  struct symbol *sym = find_pc_function (pc);
+
+  if (sym != NULL && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == pc
+      && SYMBOL_TYPE (sym) != NULL)
+    return TYPE_TARGET_TYPE (SYMBOL_TYPE (sym));
+
+  return NULL;
+}
+
 /* Determine a function's address and its return type from its value.
    Calls error() if the function is not valid for calling.  */
 
@@ -237,7 +252,8 @@ find_function_addr (struct value *function, struct type **retval_type)
   struct type *ftype = check_typedef (value_type (function));
   struct gdbarch *gdbarch = get_type_arch (ftype);
   struct type *value_type = NULL;
-  CORE_ADDR funaddr;
+  /* Initialize it just to avoid a GCC false warning.  */
+  CORE_ADDR funaddr = 0;
 
   /* If it's a member function, just look at the function
      part of it.  */
@@ -257,7 +273,19 @@ find_function_addr (struct value *function, struct type **retval_type)
     }
   if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
       || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
-    value_type = TYPE_TARGET_TYPE (ftype);
+    {
+      value_type = TYPE_TARGET_TYPE (ftype);
+
+      if (TYPE_GNU_IFUNC (ftype))
+       {
+         funaddr = gnu_ifunc_resolve_addr (gdbarch, funaddr);
+
+         /* Skip querying the function symbol if no RETVAL_TYPE has been
+            asked for.  */
+         if (retval_type)
+           value_type = find_function_return_type (funaddr);
+       }
+    }
   else if (TYPE_CODE (ftype) == TYPE_CODE_INT)
     {
       /* Handle the case of functions lacking debugging info.
This page took 0.023444 seconds and 4 git commands to generate.