RFA: USE_STRUCT_CONVENTION for NetBSD/i386

J.T. Conklin jtc@redback.com
Wed Mar 22 16:07:00 GMT 2000


I submit the enclosed patch for approval.  This change allows GDB to
extract the return value for most functions returning structs on 
NetBSD/i386 systems.  

Problems remain with functions returning structs of these two forms:

        struct one_float_t {
                float x;
        };

        struct one_double_t {
                double x;
        };

But all others work.

        --jtc

2000-03-22  J.T. Conklin  <jtc@redback.com>

	* i386/tm-nbsd.h (USE_STRUCT_CONVENTION): Define.
	* i386nbsd-nat.c (i386nbsd_use_struct_convention): New function.

Index: i386nbsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386nbsd-nat.c,v
retrieving revision 1.1
diff -c -r1.1 i386nbsd-nat.c
*** i386nbsd-nat.c	2000/03/22 01:36:31	1.1
--- i386nbsd-nat.c	2000/03/22 22:59:30
***************
*** 148,154 ****
    ptrace (PT_SETFPREGS, inferior_pid,
  	  (PTRACE_ARG3_TYPE) &inferior_fpregisters, 0);
  }
! 
  struct md_core
  {
    struct reg intreg;
--- 148,163 ----
    ptrace (PT_SETFPREGS, inferior_pid,
  	  (PTRACE_ARG3_TYPE) &inferior_fpregisters, 0);
  }
! 
! int
! i386nbsd_use_struct_convention (int gcc_p, struct type *type)
! {
!   return !(TYPE_LENGTH (type) == 1
! 	   || TYPE_LENGTH (type) == 2
! 	   || TYPE_LENGTH (type) == 4
! 	   || TYPE_LENGTH (type) == 8);
! }
! 
  struct md_core
  {
    struct reg intreg;
Index: config/i386/tm-nbsd.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/tm-nbsd.h,v
retrieving revision 1.2
diff -c -r1.2 tm-nbsd.h
*** tm-nbsd.h	2000/03/22 01:36:31	1.2
--- tm-nbsd.h	2000/03/22 22:59:30
***************
*** 26,31 ****
--- 26,36 ----
  #include "i386/tm-i386bsd.h"
  #include "tm-nbsd.h"
  
+ extern use_struct_convention_fn i386nbsd_use_struct_convention;
+ #define USE_STRUCT_CONVENTION(gcc_p, type) \
+ 	i386nbsd_use_struct_convention(gcc_p, type)
+ 
+ 
  #define JB_ELEMENT_SIZE sizeof(int)	/* jmp_buf[_JBLEN] is array of ints */
  #define JB_PC	0		/* Setjmp()'s return PC saved here */
  

-- 
J.T. Conklin
RedBack Networks


More information about the Gdb-patches mailing list