summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2000-04-19 23:22:14 +0000
committerJim Blandy <jimb@codesourcery.com>2000-04-19 23:22:14 +0000
commit676c5f2e4dcfd0048ecbf5bda79ac407f834ac18 (patch)
treee90653b6467fd9582a514720d5ed0a692ad4b04f
parentc3d6b60b406f2e95b99132e46a5436485e37673d (diff)
downloadgdb-676c5f2e4dcfd0048ecbf5bda79ac407f834ac18.tar.gz
Bring RETURN_VALUE_ON_STACK under gdbarch's control.
* gdbarch.sh (RETURN_VALUE_ON_STACK): New entry. * gdbarch.c, gdbarch.h: Regenerated. * arch-utils.c (default_return_value_on_stack): New function. * arch-utils.h (default_return_value_on_stack): New declaration. * values.c (RETURN_VALUE_ON_STACK): Delete default definition.
-rw-r--r--gdb/arch-utils.c6
-rw-r--r--gdb/arch-utils.h5
-rw-r--r--gdb/gdbarch.c27
-rw-r--r--gdb/gdbarch.h7
-rwxr-xr-xgdb/gdbarch.sh1
-rw-r--r--gdb/values.c7
6 files changed, 46 insertions, 7 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 9048bd75419..49924cbaaf4 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -97,6 +97,12 @@ generic_frameless_function_invocation_not (struct frame_info *fi)
return 0;
}
+int
+generic_return_value_on_stack_not (struct type *type)
+{
+ return 0;
+}
+
char *
legacy_register_name (int i)
{
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 57da8ceb45f..6b0d2aa2cfd 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -39,6 +39,11 @@ extern gdbarch_breakpoint_from_pc_ftype legacy_breakpoint_from_pc;
/* Frameless functions not identifable. */
extern gdbarch_frameless_function_invocation_ftype generic_frameless_function_invocation_not;
+/* Only structures, unions, and arrays are returned using the struct
+ convention. Note that arrays are never passed by value in the C
+ language family, so that case is irrelevant for C. */
+extern gdbarch_return_value_on_stack_ftype generic_return_value_on_stack_not;
+
/* Map onto old REGISTER_NAMES. */
extern char *legacy_register_name (int i);
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 28378fe5718..69e0d8ce368 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -178,6 +178,7 @@ struct gdbarch
gdbarch_register_convert_to_raw_ftype *register_convert_to_raw;
gdbarch_pointer_to_address_ftype *pointer_to_address;
gdbarch_address_to_pointer_ftype *address_to_pointer;
+ gdbarch_return_value_on_stack_ftype *return_value_on_stack;
gdbarch_extract_return_value_ftype *extract_return_value;
gdbarch_push_arguments_ftype *push_arguments;
gdbarch_push_dummy_frame_ftype *push_dummy_frame;
@@ -315,6 +316,7 @@ struct gdbarch startup_gdbarch = {
0,
0,
0,
+ 0,
/* startup_gdbarch() */
};
struct gdbarch *current_gdbarch = &startup_gdbarch;
@@ -360,6 +362,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
gdbarch->register_convertible = generic_register_convertible_not;
gdbarch->pointer_to_address = generic_pointer_to_address;
gdbarch->address_to_pointer = generic_address_to_pointer;
+ gdbarch->return_value_on_stack = generic_return_value_on_stack_not;
gdbarch->breakpoint_from_pc = legacy_breakpoint_from_pc;
gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint;
gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint;
@@ -529,6 +532,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of register_convert_to_raw, invalid_p == 0 */
/* Skip verify of pointer_to_address, invalid_p == 0 */
/* Skip verify of address_to_pointer, invalid_p == 0 */
+ /* Skip verify of return_value_on_stack, invalid_p == 0 */
if ((GDB_MULTI_ARCH >= 2)
&& (gdbarch->extract_return_value == 0))
internal_error ("gdbarch: verify_gdbarch: extract_return_value invalid");
@@ -818,6 +822,10 @@ gdbarch_dump (void)
(long) current_gdbarch->address_to_pointer
/*ADDRESS_TO_POINTER ()*/);
fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_update: RETURN_VALUE_ON_STACK = 0x%08lx\n",
+ (long) current_gdbarch->return_value_on_stack
+ /*RETURN_VALUE_ON_STACK ()*/);
+ fprintf_unfiltered (gdb_stdlog,
"gdbarch_update: EXTRACT_RETURN_VALUE = 0x%08lx\n",
(long) current_gdbarch->extract_return_value
/*EXTRACT_RETURN_VALUE ()*/);
@@ -1866,6 +1874,25 @@ set_gdbarch_address_to_pointer (struct gdbarch *gdbarch,
gdbarch->address_to_pointer = address_to_pointer;
}
+int
+gdbarch_return_value_on_stack (struct gdbarch *gdbarch, struct type *type)
+{
+ if (GDB_MULTI_ARCH == 0)
+ return generic_return_value_on_stack_not (type);
+ if (gdbarch->return_value_on_stack == 0)
+ internal_error ("gdbarch: gdbarch_return_value_on_stack invalid");
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_return_value_on_stack called\n");
+ return gdbarch->return_value_on_stack (type);
+}
+
+void
+set_gdbarch_return_value_on_stack (struct gdbarch *gdbarch,
+ gdbarch_return_value_on_stack_ftype return_value_on_stack)
+{
+ gdbarch->return_value_on_stack = return_value_on_stack;
+}
+
void
gdbarch_extract_return_value (struct gdbarch *gdbarch, struct type *type, char *regbuf, char *valbuf)
{
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index cc01e75f57f..5c74e754b07 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -510,6 +510,13 @@ extern void set_gdbarch_address_to_pointer (struct gdbarch *gdbarch, gdbarch_add
#define ADDRESS_TO_POINTER(type, buf, addr) (gdbarch_address_to_pointer (current_gdbarch, type, buf, addr))
#endif
+typedef int (gdbarch_return_value_on_stack_ftype) (struct type *type);
+extern int gdbarch_return_value_on_stack (struct gdbarch *gdbarch, struct type *type);
+extern void set_gdbarch_return_value_on_stack (struct gdbarch *gdbarch, gdbarch_return_value_on_stack_ftype *return_value_on_stack);
+#if (GDB_MULTI_ARCH > 1) || !defined (RETURN_VALUE_ON_STACK)
+#define RETURN_VALUE_ON_STACK(type) (gdbarch_return_value_on_stack (current_gdbarch, type))
+#endif
+
typedef void (gdbarch_extract_return_value_ftype) (struct type *type, char *regbuf, char *valbuf);
extern void gdbarch_extract_return_value (struct gdbarch *gdbarch, struct type *type, char *regbuf, char *valbuf);
extern void set_gdbarch_extract_return_value (struct gdbarch *gdbarch, gdbarch_extract_return_value_ftype *extract_return_value);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 52385a817b2..5cd4f88b636 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -241,6 +241,7 @@ f:2:REGISTER_CONVERT_TO_RAW:void:register_convert_to_raw:struct type *type, int
f:2:POINTER_TO_ADDRESS:CORE_ADDR:pointer_to_address:struct type *type, char *buf:type, buf:::generic_pointer_to_address:0
f:2:ADDRESS_TO_POINTER:void:address_to_pointer:struct type *type, char *buf, CORE_ADDR addr:type, buf, addr:::generic_address_to_pointer:0
#
+f:2:RETURN_VALUE_ON_STACK:int:return_value_on_stack:struct type *type:type:::generic_return_value_on_stack_not:0
f:2:EXTRACT_RETURN_VALUE:void:extract_return_value:struct type *type, char *regbuf, char *valbuf:type, regbuf, valbuf::0:0
f:1:PUSH_ARGUMENTS:CORE_ADDR:push_arguments:int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr:nargs, args, sp, struct_return, struct_addr::0:0
f:2:PUSH_DUMMY_FRAME:void:push_dummy_frame:void:-:::0
diff --git a/gdb/values.c b/gdb/values.c
index 6186b34524b..67fe2ad52ae 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -1561,13 +1561,6 @@ generic_use_struct_convention (gcc_p, value_type)
#define USE_STRUCT_CONVENTION(gcc_p,type) generic_use_struct_convention (gcc_p, type)
#endif
-/* Some fundamental types (such as long double) are returned on the stack for
- certain architectures. This macro should return true for any type besides
- struct, union or array that gets returned on the stack. */
-
-#ifndef RETURN_VALUE_ON_STACK
-#define RETURN_VALUE_ON_STACK(TYPE) 0
-#endif
/* Return true if the function specified is using the structure returning
convention on this machine to return arguments, or 0 if it is using