This is the mail archive of the gdb-patches@sourceware.org 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]

[PATCH] Correct irix5-nat.c's fetch_core_registers


On my mips-sgi-irix6.5 box, attempting to read a "core" file on all
versions of gdb since v6.0, result in diagnostic message "wrong
size gregset struct in core file", though gdb v5.3 works fine.

The problem appears to be related to the transition to using regcache.
Where back in v5.3, core_reg_size was initially tested against
REGISTER_BYTES, which on MIPS IRIX was defined in tm.h as:

(MIPS_NUMREGS * 8 + (NUM_REGS - MIPS_NUMREGS) * MIPS_REGSIZE)

which used to evaluate to 568, the code in mainline now instead
tests against deprecated_register_bytes () which currently evaluates
to 1128!?  Investigating deprecated_register_bytes() currently
returns current_regcache->descr->sizeof_raw_registers whose
calculation has a FIXME next to it, regcache.c:140, stating that
in 2002 it switched to using sizeof_cooked_registers.  Hence
instead of 71*8 that it originally returned, it now returns 141*8,
which breaks the logic in irix5-nat.c.

The clean-up below tidies this up.  Alas other breakage (bit rot)
on MIPS IRIX still prevents reading "core" files from working,
however a back-port of this change to gdb-6.0 allows 6.0 to read
core files without problems.

The following patch has been tested against mainline CVS on
mips-sgi-irix6.5 (together with yesterday's patch to resolve the
build issues).  Attempting to read a core file now procedes past
the previous "wrong size gregset" error messages.  Instead I'm
now only getting "You can't do that without a process to debug."
failures due to push_target vs. irix weirdness.  [Any help on
how things are supposed to work would be appreciated].

Ok for mainline?  As with yesterday's post, I'd appreciate it if
someone could commit this change for me.  Many thanks in advance.



2006-07-21  Roger Sayle  <roger@eyesopen.com>

	* irix5-nat.c (fetch_core_registers): Fix logic error caused by
	the transition to or changes in deprecated_register_bytes.


Index: irix5-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/irix5-nat.c,v
retrieving revision 1.40
diff -c -3 -p -r1.40 irix5-nat.c
*** irix5-nat.c	17 Dec 2005 22:34:01 -0000	1.40
--- irix5-nat.c	21 Jul 2006 16:10:33 -0000
***************
*** 1,7 ****
  /* Native support for the SGI Iris running IRIX version 5, for GDB.

     Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
!    1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.

     Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
     and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
--- 1,7 ----
  /* Native support for the SGI Iris running IRIX version 5, for GDB.

     Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
!    1998, 1999, 2000, 2001, 2002, 2004, 2006 Free Software Foundation, Inc.

     Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
     and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
*************** fetch_core_registers (char *core_reg_sec
*** 244,259 ****
    char *srcp = core_reg_sect;
    int regno;

!   if (core_reg_size == deprecated_register_bytes ())
      {
        for (regno = 0; regno < NUM_REGS; regno++)
          {
            regcache_raw_write (current_regcache, regno, srcp);
!           srcp += register_size (current_gdbarch, regno);
          }
      }
!   else if (mips_isa_regsize (current_gdbarch) == 4 &&
! 	   core_reg_size == (2 * mips_isa_regsize (current_gdbarch)) * NUM_REGS)
      {
        /* This is a core file from a N32 executable, 64 bits are saved
           for all registers.  */
--- 244,264 ----
    char *srcp = core_reg_sect;
    int regno;

!   if (core_reg_size != NUM_REGS * 8)
!     {
!       warning (_("wrong size gregset struct in core file"));
!       return;
!     }
!
!   if (mips_isa_regsize (current_gdbarch) == 8)
      {
        for (regno = 0; regno < NUM_REGS; regno++)
          {
            regcache_raw_write (current_regcache, regno, srcp);
!           srcp += 8;
          }
      }
!   else /* mips_isa_regsize (current_gdbarch) == 4 */
      {
        /* This is a core file from a N32 executable, 64 bits are saved
           for all registers.  */
*************** fetch_core_registers (char *core_reg_sec
*** 270,280 ****
            srcp += 8;
  	}
      }
-   else
-     {
-       warning (_("wrong size gregset struct in core file"));
-       return;
-     }
  }

  /* Register that we are able to handle irix5 core file formats.
--- 275,280 ----


Roger
--


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