[PATCH]: Fixes for pseudo regs support

Andrew Cagney ac131313@cygnus.com
Wed Mar 21 08:41:00 GMT 2001


Just FYI,

I've checked in the attached.  It has one addition to the original - I
removed the code that allowed SIZEOF_FRAME_SAVED_REGS to be overridden
at compile time.

If someone were to reduce SIZEOF_FRAME_SAVED_REGS to something smaller
than its current value, bad things would happen.  I can't see a reason
for making it biger - that can be accomplished by using NUM_PSEUDO_REGS.

	Andrew
2001-03-20  Andrew Cagney  <ac131313@redhat.com>

	* frame.h (SIZEOF_FRAME_SAVED_REGS): Report an error if macro
	already	defined.
	
	From 2000-08-25 Stephane Carrez <Stephane.Carrez@worldnet.fr>:
        * stabsread.c (define_symbol): A parameter ('R'), a local ('r'),
        or a reference ('a') can be in a pseudo register.
        * infcmd.c (do_registers_info): Must take into account the pseudo
        registers to print their value.
        (registers_info): Likewise.
        * stack.c (frame_info): Likewise.
        * frame.h (SIZEOF_FRAME_SAVED_REGS): Save the pseudo registers.

Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.5
diff -p -r1.5 frame.h
*** frame.h	2001/03/06 08:21:07	1.5
--- frame.h	2001/03/21 16:32:54
*************** struct frame_info
*** 81,87 ****
         address where the sp was saved.  */
      /* Allocated by frame_saved_regs_zalloc () which is called /
         initialized by FRAME_INIT_SAVED_REGS(). */
!     CORE_ADDR *saved_regs;	/*NUM_REGS */
  
  #ifdef EXTRA_FRAME_INFO
      /* XXXX - deprecated */
--- 81,87 ----
         address where the sp was saved.  */
      /* Allocated by frame_saved_regs_zalloc () which is called /
         initialized by FRAME_INIT_SAVED_REGS(). */
!     CORE_ADDR *saved_regs;	/*NUM_REGS + NUM_PSEUDO_REGS*/
  
  #ifdef EXTRA_FRAME_INFO
      /* XXXX - deprecated */
*************** enum print_what
*** 114,124 ****
      LOC_AND_ADDRESS 
    };
  
! /* Allocate additional space for appendices to a struct frame_info. */
  
! #ifndef SIZEOF_FRAME_SAVED_REGS
! #define SIZEOF_FRAME_SAVED_REGS (sizeof (CORE_ADDR) * (NUM_REGS))
  #endif
  extern void *frame_obstack_alloc (unsigned long size);
  extern void frame_saved_regs_zalloc (struct frame_info *);
  
--- 114,130 ----
      LOC_AND_ADDRESS 
    };
  
! /* Allocate additional space for appendices to a struct frame_info.
!    NOTE: Much of GDB's code works on the assumption that the allocated
!    saved_regs[] array is the size specified below.  If you try to make
!    that array smaller, GDB will happily walk off its end. */
  
! #ifdef SIZEOF_FRAME_SAVED_REGS
! #error "SIZEOF_FRAME_SAVED_REGS can not be re-defined"
  #endif
+ #define SIZEOF_FRAME_SAVED_REGS \
+         (sizeof (CORE_ADDR) * (NUM_REGS+NUM_PSEUDO_REGS))
+ 
  extern void *frame_obstack_alloc (unsigned long size);
  extern void frame_saved_regs_zalloc (struct frame_info *);
  
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.24
diff -p -r1.24 infcmd.c
*** infcmd.c	2001/03/13 23:31:13	1.24
--- infcmd.c	2001/03/21 16:32:55
*************** void
*** 1467,1473 ****
  do_registers_info (int regnum, int fpregs)
  {
    register int i;
!   int numregs = NUM_REGS;
  
    for (i = 0; i < numregs; i++)
      {
--- 1467,1473 ----
  do_registers_info (int regnum, int fpregs)
  {
    register int i;
!   int numregs = NUM_REGS + NUM_PSEUDO_REGS;
  
    for (i = 0; i < numregs; i++)
      {
*************** registers_info (char *addr_exp, int fpre
*** 1591,1597 ****
        end = addr_exp;
        while (*end != '\0' && *end != ' ' && *end != '\t')
  	++end;
!       numregs = NUM_REGS;
  
        regnum = target_map_name_to_register (addr_exp, end - addr_exp);
        if (regnum >= 0)
--- 1591,1597 ----
        end = addr_exp;
        while (*end != '\0' && *end != ' ' && *end != '\t')
  	++end;
!       numregs = NUM_REGS + NUM_PSEUDO_REGS;
  
        regnum = target_map_name_to_register (addr_exp, end - addr_exp);
        if (regnum >= 0)
Index: stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.11
diff -p -r1.11 stabsread.c
*** stabsread.c	2001/03/06 08:21:17	1.11
--- stabsread.c	2001/03/21 16:33:10
*************** define_symbol (CORE_ADDR valu, char *str
*** 1802,1810 ****
        SYMBOL_TYPE (sym) = read_type (&p, objfile);
        SYMBOL_CLASS (sym) = LOC_REGPARM;
        SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
!       if (SYMBOL_VALUE (sym) >= NUM_REGS)
  	{
! 	  complain (&reg_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
  		    SYMBOL_SOURCE_NAME (sym));
  	  SYMBOL_VALUE (sym) = SP_REGNUM;	/* Known safe, though useless */
  	}
--- 1802,1811 ----
        SYMBOL_TYPE (sym) = read_type (&p, objfile);
        SYMBOL_CLASS (sym) = LOC_REGPARM;
        SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
!       if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
  	{
! 	  complain (&reg_value_complaint, SYMBOL_VALUE (sym),
! 		    NUM_REGS + NUM_PSEUDO_REGS,
  		    SYMBOL_SOURCE_NAME (sym));
  	  SYMBOL_VALUE (sym) = SP_REGNUM;	/* Known safe, though useless */
  	}
*************** define_symbol (CORE_ADDR valu, char *str
*** 1817,1825 ****
        SYMBOL_TYPE (sym) = read_type (&p, objfile);
        SYMBOL_CLASS (sym) = LOC_REGISTER;
        SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
!       if (SYMBOL_VALUE (sym) >= NUM_REGS)
  	{
! 	  complain (&reg_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
  		    SYMBOL_SOURCE_NAME (sym));
  	  SYMBOL_VALUE (sym) = SP_REGNUM;	/* Known safe, though useless */
  	}
--- 1818,1827 ----
        SYMBOL_TYPE (sym) = read_type (&p, objfile);
        SYMBOL_CLASS (sym) = LOC_REGISTER;
        SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
!       if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
  	{
! 	  complain (&reg_value_complaint, SYMBOL_VALUE (sym),
! 		    NUM_REGS + NUM_PSEUDO_REGS,
  		    SYMBOL_SOURCE_NAME (sym));
  	  SYMBOL_VALUE (sym) = SP_REGNUM;	/* Known safe, though useless */
  	}
*************** define_symbol (CORE_ADDR valu, char *str
*** 2066,2074 ****
        SYMBOL_TYPE (sym) = read_type (&p, objfile);
        SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
        SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
!       if (SYMBOL_VALUE (sym) >= NUM_REGS)
  	{
! 	  complain (&reg_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
  		    SYMBOL_SOURCE_NAME (sym));
  	  SYMBOL_VALUE (sym) = SP_REGNUM;	/* Known safe, though useless */
  	}
--- 2068,2077 ----
        SYMBOL_TYPE (sym) = read_type (&p, objfile);
        SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
        SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
!       if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
  	{
! 	  complain (&reg_value_complaint, SYMBOL_VALUE (sym),
! 		    NUM_REGS + NUM_PSEUDO_REGS,
  		    SYMBOL_SOURCE_NAME (sym));
  	  SYMBOL_VALUE (sym) = SP_REGNUM;	/* Known safe, though useless */
  	}
Index: stack.c
===================================================================
RCS file: /cvs/src/src/gdb/stack.c,v
retrieving revision 1.16
diff -p -r1.16 stack.c
*** stack.c	2001/03/13 23:31:14	1.16
--- stack.c	2001/03/21 16:33:11
*************** frame_info (char *addr_exp, int from_tty
*** 1001,1007 ****
        print_address_numeric (fi->saved_regs[SP_REGNUM], 1, gdb_stdout);
        printf_filtered ("\n");
        count = 0;
!       numregs = NUM_REGS;
        for (i = 0; i < numregs; i++)
  	if (fi->saved_regs[i] && i != SP_REGNUM)
  	  {
--- 1001,1007 ----
        print_address_numeric (fi->saved_regs[SP_REGNUM], 1, gdb_stdout);
        printf_filtered ("\n");
        count = 0;
!       numregs = NUM_REGS + NUM_PSEUDO_REGS;
        for (i = 0; i < numregs; i++)
  	if (fi->saved_regs[i] && i != SP_REGNUM)
  	  {


More information about the Gdb-patches mailing list