Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] 64-bit corefile support for Irix
@ 2002-09-05 16:18 Michael Snyder
  2002-09-09 12:49 ` Andrew Cagney
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2002-09-05 16:18 UTC (permalink / raw)
  To: binutils; +Cc: gdb-patches


Hi, 

This patch will allow gdb (and hopefully objdump/objcopy) to read
64-bit corefiles on Irix native.

Cheers, 
Michael

2002-09-05  Michael Snyder  <msnyder@redhat.com>

	* irix-core.c (do_sections, do_sections64): New functions.
	(irix_core_core_file_p): Call new functions do_sections, 
	do_sections64, depending on corefile (32-bit or 64-bit).

Index: irix-core.c
===================================================================
RCS file: /cvs/src/src/bfd/irix-core.c,v
retrieving revision 1.7
diff -p -r1.7 irix-core.c
*** irix-core.c	6 Jan 2002 07:30:35 -0000	1.7
--- irix-core.c	5 Sep 2002 23:14:39 -0000
*************** static boolean irix_core_core_file_match
*** 50,55 ****
--- 50,154 ----
    PARAMS ((bfd *, bfd *));
  static void swap_abort PARAMS ((void));
  
+ /* Helper function for irix_core_core_file_p:
+    32-bit and 64-bit versions.  */
+ 
+ #ifdef CORE_MAGIC64
+ static int
+ do_sections64 (bfd *abfd, struct coreout *coreout)
+ {
+   struct vmap64 vmap;
+   char *secname;
+   int i, val;
+ 
+   for (i = 0; i < coreout->c_nvmap; i++)
+     {
+ 
+       val = bfd_bread ((PTR) &vmap, (bfd_size_type) sizeof vmap, abfd);
+       if (val != sizeof vmap)
+ 	break;
+ 
+       switch (vmap.v_type)
+ 	{
+ 	case VDATA:
+ 	  secname = ".data";
+ 	  break;
+ 	case VSTACK:
+ 	  secname = ".stack";
+ 	  break;
+ #ifdef VMAPFILE
+ 	case VMAPFILE:
+ 	  secname = ".mapfile";
+ 	  break;
+ #endif
+ 	default:
+ 	  continue;
+ 	}
+ 
+       /* A file offset of zero means that the section is not contained
+ 	 in the corefile.  */
+       if (vmap.v_offset == 0)
+ 	continue;
+ 
+       if (!make_bfd_asection (abfd, secname,
+ 			      SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
+ 			      vmap.v_len,
+ 			      vmap.v_vaddr,
+ 			      vmap.v_offset))
+ 	return 0;	/* fail */
+     }
+   return 1;
+ }
+ #endif
+ 
+ /* 32-bit version */
+ 
+ static int
+ do_sections (bfd *abfd, struct coreout *coreout)
+ {
+   struct vmap vmap;
+   char *secname;
+   int i, val;
+ 
+   for (i = 0; i < coreout->c_nvmap; i++)
+     {
+ 
+       val = bfd_bread ((PTR) &vmap, (bfd_size_type) sizeof vmap, abfd);
+       if (val != sizeof vmap)
+ 	break;
+ 
+       switch (vmap.v_type)
+ 	{
+ 	case VDATA:
+ 	  secname = ".data";
+ 	  break;
+ 	case VSTACK:
+ 	  secname = ".stack";
+ 	  break;
+ #ifdef VMAPFILE
+ 	case VMAPFILE:
+ 	  secname = ".mapfile";
+ 	  break;
+ #endif
+ 	default:
+ 	  continue;
+ 	}
+ 
+       /* A file offset of zero means that the section is not contained
+ 	 in the corefile.  */
+       if (vmap.v_offset == 0)
+ 	continue;
+ 
+       if (!make_bfd_asection (abfd, secname,
+ 			      SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
+ 			      vmap.v_len,
+ 			      vmap.v_vaddr,
+ 			      vmap.v_offset))
+ 	return 0;	/* fail */
+     }
+   return 1;
+ }
+ 
  static asection *
  make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
       bfd *abfd;
*************** irix_core_core_file_p (abfd)
*** 79,86 ****
       bfd *abfd;
  {
    int val;
-   int i;
-   char *secname;
    struct coreout coreout;
    struct idesc *idg, *idf, *ids;
    bfd_size_type amt;
--- 178,183 ----
*************** irix_core_core_file_p (abfd)
*** 93,105 ****
        return 0;
      }
  
! #ifndef CORE_MAGICN32
! #define CORE_MAGICN32 CORE_MAGIC
! #endif
!   if ((coreout.c_magic != CORE_MAGIC && coreout.c_magic != CORE_MAGICN32)
!       || coreout.c_version != CORE_VERSION1)
      return 0;
  
    amt = sizeof (struct sgi_core_struct);
    core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, amt);
    if (!core_hdr (abfd))
--- 190,210 ----
        return 0;
      }
  
!   if (coreout.c_version != CORE_VERSION1)
      return 0;
  
+   /* Have we got a corefile?  */
+   switch (coreout.c_magic) {
+   case CORE_MAGIC:	break;
+ #ifdef CORE_MAGIC64
+   case CORE_MAGIC64:	break;
+ #endif
+ #ifdef CORE_MAGICN32
+   case CORE_MAGICN32:	break;
+ #endif
+   default:		return 0;	/* Un-identifiable or not corefile.  */
+   }
+ 
    amt = sizeof (struct sgi_core_struct);
    core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, amt);
    if (!core_hdr (abfd))
*************** irix_core_core_file_p (abfd)
*** 111,153 ****
    if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0)
      goto fail;
  
!   for (i = 0; i < coreout.c_nvmap; i++)
      {
!       struct vmap vmap;
! 
!       val = bfd_bread ((PTR) &vmap, (bfd_size_type) sizeof vmap, abfd);
!       if (val != sizeof vmap)
! 	break;
! 
!       switch (vmap.v_type)
! 	{
! 	case VDATA:
! 	  secname = ".data";
! 	  break;
! 	case VSTACK:
! 	  secname = ".stack";
! 	  break;
! #ifdef VMAPFILE
! 	case VMAPFILE:
! 	  secname = ".mapfile";
! 	  break;
! #endif
! 	default:
! 	  continue;
! 	}
! 
!       /* A file offset of zero means that the section is not contained
! 	 in the corefile.  */
!       if (vmap.v_offset == 0)
! 	continue;
! 
!       if (!make_bfd_asection (abfd, secname,
! 			      SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
! 			      vmap.v_len,
! 			      vmap.v_vaddr,
! 			      vmap.v_offset))
  	goto fail;
      }
  
    /* Make sure that the regs are contiguous within the core file. */
  
--- 216,232 ----
    if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0)
      goto fail;
  
!   /* Process corefile sections.  */
! #ifdef CORE_MAGIC64
!   if (coreout.c_magic == (int) CORE_MAGIC64)
      {
!       if (!do_sections64 (abfd, &coreout))
  	goto fail;
      }
+   else
+ #endif
+     if (!do_sections (abfd, &coreout))
+       goto fail;
  
    /* Make sure that the regs are contiguous within the core file. */
  


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] 64-bit corefile support for Irix
  2002-09-05 16:18 [RFA] 64-bit corefile support for Irix Michael Snyder
@ 2002-09-09 12:49 ` Andrew Cagney
  2002-09-09 17:52   ` Michael Snyder
  2002-09-12 12:31   ` Andrew Cagney
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Cagney @ 2002-09-09 12:49 UTC (permalink / raw)
  To: Michael Snyder; +Cc: binutils, gdb-patches

> Hi, 
> 
> This patch will allow gdb (and hopefully objdump/objcopy) to read
> 64-bit corefiles on Irix native.

The file isn't maintained so ...

> 2002-09-05  Michael Snyder  <msnyder@redhat.com>
> 
> 	* irix-core.c (do_sections, do_sections64): New functions.
> 	(irix_core_core_file_p): Call new functions do_sections, 
> 	do_sections64, depending on corefile (32-bit or 64-bit).
> 
> Index: irix-core.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/irix-core.c,v
> retrieving revision 1.7
> diff -p -r1.7 irix-core.c
> *** irix-core.c	6 Jan 2002 07:30:35 -0000	1.7
> --- irix-core.c	5 Sep 2002 23:14:39 -0000
> *************** static boolean irix_core_core_file_match
> *** 50,55 ****
> --- 50,154 ----
>     PARAMS ((bfd *, bfd *));
>   static void swap_abort PARAMS ((void));
>   
> + /* Helper function for irix_core_core_file_p:
> +    32-bit and 64-bit versions.  */
> + 
> + #ifdef CORE_MAGIC64

Where does the macro come from?  Should BFD provide it so that it can 
always be used.

enjoy,
Andrew



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] 64-bit corefile support for Irix
  2002-09-09 12:49 ` Andrew Cagney
@ 2002-09-09 17:52   ` Michael Snyder
  2002-09-12 12:31   ` Andrew Cagney
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Snyder @ 2002-09-09 17:52 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Michael Snyder, binutils, gdb-patches

Andrew Cagney wrote:
> 
> > Hi,
> >
> > This patch will allow gdb (and hopefully objdump/objcopy) to read
> > 64-bit corefiles on Irix native.
> 
> The file isn't maintained so ...
> 
> > 2002-09-05  Michael Snyder  <msnyder@redhat.com>
> >
> >       * irix-core.c (do_sections, do_sections64): New functions.
> >       (irix_core_core_file_p): Call new functions do_sections,
> >       do_sections64, depending on corefile (32-bit or 64-bit).
> >
> > Index: irix-core.c
> > ===================================================================
> > RCS file: /cvs/src/src/bfd/irix-core.c,v
> > retrieving revision 1.7
> > diff -p -r1.7 irix-core.c
> > *** irix-core.c       6 Jan 2002 07:30:35 -0000       1.7
> > --- irix-core.c       5 Sep 2002 23:14:39 -0000
> > *************** static boolean irix_core_core_file_match
> > *** 50,55 ****
> > --- 50,154 ----
> >     PARAMS ((bfd *, bfd *));
> >   static void swap_abort PARAMS ((void));
> >
> > + /* Helper function for irix_core_core_file_p:
> > +    32-bit and 64-bit versions.  */
> > +
> > + #ifdef CORE_MAGIC64
> 
> Where does the macro come from?  Should BFD provide it so that it can
> always be used.

It comes from a system header file on Irix.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] 64-bit corefile support for Irix
  2002-09-09 12:49 ` Andrew Cagney
  2002-09-09 17:52   ` Michael Snyder
@ 2002-09-12 12:31   ` Andrew Cagney
  2002-09-12 15:01     ` Eric Christopher
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Cagney @ 2002-09-12 12:31 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Michael Snyder, binutils, gdb-patches

> Hi,
> This patch will allow gdb (and hopefully objdump/objcopy) to read
> 64-bit corefiles on Irix native.
> 
> The file isn't maintained so ...

Oops, it's also a BFD file so outside of GDB's control.  Just ignore me :-)

> 2002-09-05  Michael Snyder  <msnyder@redhat.com>
> 
>     * irix-core.c (do_sections, do_sections64): New functions.
>     (irix_core_core_file_p): Call new functions do_sections,     do_sections64, depending on corefile (32-bit or 64-bit).
> 
> Index: irix-core.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/irix-core.c,v
> retrieving revision 1.7
> diff -p -r1.7 irix-core.c
> *** irix-core.c    6 Jan 2002 07:30:35 -0000    1.7
> --- irix-core.c    5 Sep 2002 23:14:39 -0000
> *************** static boolean irix_core_core_file_match
> *** 50,55 ****
> --- 50,154 ----
>     PARAMS ((bfd *, bfd *));
>   static void swap_abort PARAMS ((void));
>   + /* Helper function for irix_core_core_file_p:
> +    32-bit and 64-bit versions.  */
> + + #ifdef CORE_MAGIC64
> 
> Where does the macro come from?  Should BFD provide it so that it can always be used.

Turns out that the file can only be compiled on an IRIX system anyway.

Andrew



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] 64-bit corefile support for Irix
  2002-09-12 12:31   ` Andrew Cagney
@ 2002-09-12 15:01     ` Eric Christopher
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Christopher @ 2002-09-12 15:01 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Michael Snyder, binutils, gdb-patches

On Thu, 2002-09-12 at 12:31, Andrew Cagney wrote:
> > Hi,
> > This patch will allow gdb (and hopefully objdump/objcopy) to read
> > 64-bit corefiles on Irix native.
> > 
> > The file isn't maintained so ...
> 
> Oops, it's also a BFD file so outside of GDB's control.  Just ignore me :-)
> 

Hey, you want to maintain it - go ahead ;)

Anyhow, go ahead Michael.

-eric

-- 
Yuppies wear socks.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] 64-bit corefile support for Irix
@ 2002-09-10  9:56 David Anderson
  0 siblings, 0 replies; 6+ messages in thread
From: David Anderson @ 2002-09-10  9:56 UTC (permalink / raw)
  To: ac131313; +Cc: gdb-patches, binutils, msnyder


|> + #ifdef CORE_MAGIC64
|
|Where does the macro come from?  Should BFD provide it so that it can 
|always be used.
|
|enjoy,
|Andrew

It comes from IRIX /usr/include/core.out.h, the
header which defines the IRIX core file format.

The 3 defines are
#define CORE_MAGIC      0xdeadadb0
#define CORE_MAGIC64    0xdeadad40
#define CORE_MAGICN32   0xbabec0bb

The initial struct in the core has a field with one of
the above values (which one depends on which ABI
the executable that coredumped was, of course).

CORE_MAGIC is for o32
CORE_MAGICN32 is for n32
CORE_MAGIC64 is for -64 (some people call it n64).

CORE_MAGIC was first, followed by CORE_MAGIC64, and then by
CORE_MAGICN32 over time. All 3 existed starting in the 
mid 1990's.

Regards,
David B. Anderson davea@sgi.com http://reality.sgiweb.org/davea


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-09-12 22:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-05 16:18 [RFA] 64-bit corefile support for Irix Michael Snyder
2002-09-09 12:49 ` Andrew Cagney
2002-09-09 17:52   ` Michael Snyder
2002-09-12 12:31   ` Andrew Cagney
2002-09-12 15:01     ` Eric Christopher
2002-09-10  9:56 David Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox