aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/arch-utils.c15
-rw-r--r--gdb/arch-utils.h2
-rw-r--r--gdb/s390-tdep.c16
4 files changed, 41 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index df9242f..823cee6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
2001-11-29 Jim Blandy <jimb@redhat.com>
+ Tighten up GDB's support for returning structs by value.
+ * s390-tdep.c (s390_use_struct_convention): New function.
+ (s390_gdbarch_init): Register it as the S/390's
+ USE_STRUCT_CONVENTION method. Register
+ generic_cannot_extract_struct_value_address as our
+ EXTRACT_STRUCT_VALUE_ADDRESS method.
+ * arch-utils.c (generic_cannot_extract_struct_value_address): New
+ function.
+ * arch-utils.h: Add corresponding prototype.
+
* values.c (value_being_returned): Make error message a proper
sentence.
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 0dab00c..2b23951 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -240,6 +240,21 @@ generic_register_convertible_not (int num)
}
+/* Under some ABI's that specify the `struct convention' for returning
+ structures by value, by the time we've returned from the function,
+ the return value is sitting there in the caller's buffer, but GDB
+ has no way to find the address of that buffer.
+
+ On such architectures, use this function as your
+ extract_struct_value_address method. When asked to a struct
+ returned by value in this fashion, GDB will print a nice error
+ message, instead of garbage. */
+CORE_ADDR
+generic_cannot_extract_struct_value_address (char *dummy)
+{
+ return 0;
+}
+
int
default_register_sim_regno (int num)
{
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 5dec3c2..b065dec 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -27,6 +27,8 @@ extern int gdbarch_debug;
/* Fallback for register convertible. */
extern gdbarch_register_convertible_ftype generic_register_convertible_not;
+extern CORE_ADDR generic_cannot_extract_struct_value_address (char *dummy);
+
/* Helper function for targets that don't know how my arguments are
being passed */
extern gdbarch_frame_num_args_ftype frame_num_args_unknown;
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 465780f..4ec129c 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -1592,6 +1592,17 @@ s390_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
return sp;
}
+
+static int
+s390_use_struct_convention (int gcc_p, struct type *value_type)
+{
+ enum type_code code = TYPE_CODE (value_type);
+
+ return (code == TYPE_CODE_STRUCT
+ || code == TYPE_CODE_UNION);
+}
+
+
/* Return the GDB type object for the "standard" data type
of data in register N. */
struct type *
@@ -1735,12 +1746,14 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_cannot_fetch_register (gdbarch, s390_cannot_fetch_register);
set_gdbarch_cannot_store_register (gdbarch, s390_cannot_fetch_register);
set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register);
- set_gdbarch_use_struct_convention (gdbarch, generic_use_struct_convention);
+ set_gdbarch_use_struct_convention (gdbarch, s390_use_struct_convention);
set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid);
set_gdbarch_register_name (gdbarch, s390_register_name);
set_gdbarch_stab_reg_to_regnum (gdbarch, s390_stab_reg_to_regnum);
set_gdbarch_dwarf_reg_to_regnum (gdbarch, s390_stab_reg_to_regnum);
set_gdbarch_dwarf2_reg_to_regnum (gdbarch, s390_stab_reg_to_regnum);
+ set_gdbarch_extract_struct_value_address
+ (gdbarch, generic_cannot_extract_struct_value_address);
/* Parameters for inferior function calls. */
set_gdbarch_call_dummy_p (gdbarch, 1);
@@ -1756,7 +1769,6 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
- set_gdbarch_extract_struct_value_address (gdbarch, 0);
set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
set_gdbarch_push_return_address (gdbarch, s390_push_return_address);
set_gdbarch_sizeof_call_dummy_words (gdbarch,