This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] revised mips reg_struct_has_addr


Here is the stripped down patch, which identically preserves current
behavior, and just creates a gdbarch version of reg_struct_has_addr.

Andrew, I left in the 6 lines of code in mips_push_arguments, but
they are now completely redundant and (if I'm right) will never be
executed, because reg_struct_has_addr will change the type of the
argument in such a way that the condition will never be true.
If you agree, we can take them out as a separate patch.

Michael
2002-08-06  Michael Snyder  <msnyder@redhat.com>

	*  mips-tdep.c: gdbarch-ify reg_struct_has_addr.
	(mips_EABI_reg_struct_has_addr, mips_NABI_reg_struct_has_addr, 
	mips_OABI_reg_struct_has_addr): New functions.
	(mips_gdbarch_init): Set gdbarch reg_struct_has_addr.

Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.89
diff -c -3 -p -r1.89 mips-tdep.c
*** mips-tdep.c	6 Aug 2002 19:03:40 -0000	1.89
--- mips-tdep.c	6 Aug 2002 23:02:44 -0000
*************** mips_use_struct_convention (int gcc_p, s
*** 573,578 ****
--- 573,606 ----
      return 1;			/* Structures are returned by ref in extra arg0 */
  }
  
+ /* Should call_function pass struct by reference? 
+    For each architecture, structs are passed either by
+    value or by reference, depending on their size.  */
+ 
+ static int
+ mips_EABI_reg_struct_has_addr (int gcc_p, struct type *type)
+ {
+   enum type_code typecode = TYPE_CODE (check_typedef (type));
+   int len = TYPE_LENGTH (check_typedef (type));
+ 
+   if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
+     return (len > MIPS_SAVED_REGSIZE);
+ 
+   return 0;
+ }
+ 
+ static int
+ mips_NABI_reg_struct_has_addr (int gcc_p, struct type *type)
+ {
+   return 0;	/* Assumption: N32/N64 never passes struct by ref.  */
+ }
+ 
+ int
+ mips_OABI_reg_struct_has_addr (int gcc_p, struct type *type)
+ {
+   return 0;	/* Assumption: O32/O64 never passes struct by ref.  */
+ }
+ 
  /* Tell if the program counter value in MEMADDR is in a MIPS16 function.  */
  
  static int
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4478,4483 ****
--- 4506,4513 ----
        set_gdbarch_long_bit (gdbarch, 32);
        set_gdbarch_ptr_bit (gdbarch, 32);
        set_gdbarch_long_long_bit (gdbarch, 64);
+       set_gdbarch_reg_struct_has_addr (gdbarch, 
+ 				       mips_OABI_reg_struct_has_addr);
        break;
      case MIPS_ABI_O64:
        tdep->mips_default_saved_regsize = 8;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4491,4496 ****
--- 4521,4528 ----
        set_gdbarch_long_bit (gdbarch, 32);
        set_gdbarch_ptr_bit (gdbarch, 32);
        set_gdbarch_long_long_bit (gdbarch, 64);
+       set_gdbarch_reg_struct_has_addr (gdbarch, 
+ 				       mips_OABI_reg_struct_has_addr);
        break;
      case MIPS_ABI_EABI32:
        tdep->mips_default_saved_regsize = 4;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4504,4509 ****
--- 4536,4543 ----
        set_gdbarch_long_bit (gdbarch, 32);
        set_gdbarch_ptr_bit (gdbarch, 32);
        set_gdbarch_long_long_bit (gdbarch, 64);
+       set_gdbarch_reg_struct_has_addr (gdbarch, 
+ 				       mips_EABI_reg_struct_has_addr);
        break;
      case MIPS_ABI_EABI64:
        tdep->mips_default_saved_regsize = 8;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4517,4522 ****
--- 4551,4558 ----
        set_gdbarch_long_bit (gdbarch, 64);
        set_gdbarch_ptr_bit (gdbarch, 64);
        set_gdbarch_long_long_bit (gdbarch, 64);
+       set_gdbarch_reg_struct_has_addr (gdbarch, 
+ 				       mips_EABI_reg_struct_has_addr);
        break;
      case MIPS_ABI_N32:
        tdep->mips_default_saved_regsize = 8;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4541,4546 ****
--- 4577,4584 ----
  	tm_print_insn_info.mach = info.bfd_arch_info->mach;
        else
  	tm_print_insn_info.mach = bfd_mach_mips8000;
+       set_gdbarch_reg_struct_has_addr (gdbarch, 
+ 				       mips_NABI_reg_struct_has_addr);
        break;
      case MIPS_ABI_N64:
        tdep->mips_default_saved_regsize = 8;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4565,4570 ****
--- 4603,4610 ----
  	tm_print_insn_info.mach = info.bfd_arch_info->mach;
        else
  	tm_print_insn_info.mach = bfd_mach_mips8000;
+       set_gdbarch_reg_struct_has_addr (gdbarch, 
+ 				       mips_NABI_reg_struct_has_addr);
        break;
      default:
        internal_error (__FILE__, __LINE__,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]