Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Roger Sayle <roger@eyesopen.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches@sourceware.org
Subject: [PATCH] Correct irix5-nat.c's fetch_core_registers (take 2)
Date: Tue, 25 Jul 2006 16:31:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.44.0607250942070.12446-100000@www.eyesopen.com> (raw)
In-Reply-To: <20060724214557.GA18918@nevyn.them.org>


On Mon, 24 Jul 2006, Daniel Jacobowitz wrote:
> If the core register set size matches the ISA register size, just read
> them in.  It should match.  You can check and warn if they don't.
> IOW I think the entire else branch is dead; it reads in four bytes of
> N32 64-bit registers.  Not very useful!

Try as I might, even resurecting a long dead SGI O2 and trying to use
the command "set mips saved-gpreg-size 32" to spoof the mips_isa_regsize
I couldn't get the else branch to trigger, so I think you're right that
this code is long dead.  Well, that greatly simplifies things!  The patch
below follows your suggestions and should additionally fix O32.

The following revised patch has been tested by building mainline gdb
on mips-sgi-irix6.5.  Unfortunately, as explained in my original post,
loading shared libraries on IRIX is broken, but an earlier version of
this patch cured to "wrong size gregset" errors when applied to older
versions of GDB.

Thanks again for your help.


2006-07-25  Roger Sayle  <roger@eyesopen.com>
	    Daniel Jacobowitz  <dan@codesourcery.com>

	* irix5-nat.c (fetch_core_registers): Simplify and correct logic.


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	25 Jul 2006 05:52:11 -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
*** 242,280 ****
  		      int which, CORE_ADDR reg_addr)
  {
    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.  */
!       for (regno = 0; regno < NUM_REGS; regno++)
! 	{
! 	  if (regno >= FP0_REGNUM && regno < (FP0_REGNUM + 32))
! 	    {
!               regcache_raw_write (current_regcache, regno, srcp);
! 	    }
! 	  else
! 	    {
!               regcache_raw_write (current_regcache, regno, srcp + 4);
! 	    }
!           srcp += 8;
! 	}
!     }
!   else
      {
        warning (_("wrong size gregset struct in core file"));
        return;
      }
  }

  /* Register that we are able to handle irix5 core file formats.
--- 242,263 ----
  		      int which, CORE_ADDR reg_addr)
  {
    char *srcp = core_reg_sect;
+   int regsize = mips_isa_regsize (current_gdbarch);
    int regno;

!   /* If regsize is 8, this is a N32 or N64 core file.
!      If regsize is 4, this is an O32 core file.  */
!   if (core_reg_size != regsize * NUM_REGS)
      {
        warning (_("wrong size gregset struct in core file"));
        return;
      }
+
+   for (regno = 0; regno < NUM_REGS; regno++)
+     {
+       regcache_raw_write (current_regcache, regno, srcp);
+       srcp += regsize;
+     }
  }

  /* Register that we are able to handle irix5 core file formats.

Roger
--


  reply	other threads:[~2006-07-25 16:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-21 16:41 [PATCH] Correct irix5-nat.c's fetch_core_registers Roger Sayle
2006-07-24 19:49 ` Daniel Jacobowitz
2006-07-24 21:34   ` Roger Sayle
2006-07-24 21:46     ` Daniel Jacobowitz
2006-07-25 16:31       ` Roger Sayle [this message]
2006-07-27 21:27         ` [PATCH] Correct irix5-nat.c's fetch_core_registers (take 2) Daniel Jacobowitz

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=Pine.LNX.4.44.0607250942070.12446-100000@www.eyesopen.com \
    --to=roger@eyesopen.com \
    --cc=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    /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