Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@zwingli.cygnus.com>
To: gdb-patches@sources.redhat.com
Subject: PATCH: S/390: improve handling of structs returned by value
Date: Mon, 19 Nov 2001 23:17:00 -0000	[thread overview]
Message-ID: <20011129222647.CB0835E9D8@zwingli.cygnus.com> (raw)
Message-ID: <20011119231700.0EwdVKbII5NDokOH6njN9s6lmYlKRhj7zGmotccAsy0@z> (raw)


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.

	* s390-tdep.c (s390_frame_saved_pc_nofix): If the prologue didn't
	save the return address register, assume that the return address
	is still in there.

Index: gdb/s390-tdep.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/s390-tdep.c,v
retrieving revision 2.22
diff -c -r2.22 s390-tdep.c
*** gdb/s390-tdep.c	2001/11/29 05:04:17	2.22
--- gdb/s390-tdep.c	2001/11/29 22:16:23
***************
*** 1592,1597 ****
--- 1592,1608 ----
    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,1746 ****
    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_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);
  
    /* Parameters for inferior function calls.  */
    set_gdbarch_call_dummy_p (gdbarch, 1);
--- 1746,1759 ----
    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, 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,1762 ****
    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,
--- 1769,1774 ----
Index: gdb/arch-utils.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/arch-utils.c,v
retrieving revision 2.27
diff -c -r2.27 arch-utils.c
*** gdb/arch-utils.c	2001/11/06 11:09:09	2.27
--- gdb/arch-utils.c	2001/11/29 22:16:25
***************
*** 240,245 ****
--- 240,260 ----
  }
    
  
+ /* 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)
  {
Index: gdb/arch-utils.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/arch-utils.h,v
retrieving revision 2.20
diff -c -r2.20 arch-utils.h
*** gdb/arch-utils.h	2001/11/06 11:09:09	2.20
--- gdb/arch-utils.h	2001/11/29 22:16:25
***************
*** 27,32 ****
--- 27,34 ----
  /* 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;


             reply	other threads:[~2001-11-29 22:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-29 14:25 Jim Blandy [this message]
2001-11-19 23:17 ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011129222647.CB0835E9D8@zwingli.cygnus.com \
    --to=jimb@zwingli.cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox