This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] 64-bit corefile support for Irix
- From: Michael Snyder <msnyder at cygnus dot com>
- To: binutils at sources dot redhat dot com
- Cc: gdb-patches at sources dot redhat dot com
- Date: Thu, 5 Sep 2002 16:18:01 -0700
- Subject: [RFA] 64-bit corefile support for Irix
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. */