This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Support for opening large core files
- From: Daniel Jacobowitz <drow at false dot org>
- To: binutils at sourceware dot org
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 3 Nov 2005 11:09:04 -0500
- Subject: Support for opening large core files
Hi Alan,
This is the other change I mentioned to you on the gdb list a couple of
weeks ago. If we don't do this, then when we try to reopen a very
large file on a 32-bit system, fopen will fail. It works initially
because gdb passes a file descriptor to bfd_fopen.
Tested on i686-pc-linux-gnu, where it fixes bigcore.exp in the GDB
testsuite. No regressions for binutils, though all the weakref gas
tests fail.
Checked in. Joel, is the 6.4 branch open?
--
Daniel Jacobowitz
CodeSourcery, LLC
2005-11-03 Daniel Jacobowitz <dan@codesourcery.com>
* configure.in: Check for fopen64.
* libbfd-in.h (real_fopen): New prototype.
* configure, config.in, libbfd.h: Regenerated.
* bfdio.c (real_fopen): New function.
* opncls.c (bfd_fopen, bfd_fill_in_gnu_debuglink_section): Use it.
* cache.c (bfd_open_file): Likewise.
Index: bfdio.c
===================================================================
RCS file: /cvs/src/src/bfd/bfdio.c,v
retrieving revision 1.11
diff -u -p -r1.11 bfdio.c
--- bfdio.c 4 May 2005 15:53:01 -0000 1.11
+++ bfdio.c 3 Nov 2005 15:47:23 -0000
@@ -63,6 +63,16 @@ real_fseek (FILE *file, file_ptr offset,
#endif
}
+FILE *
+real_fopen (const char *filename, const char *modes)
+{
+#if defined (HAVE_FOPEN64)
+ return fopen64 (filename, modes);
+#else
+ return fopen (filename, modes);
+#endif
+}
+
/*
INTERNAL_DEFINITION
struct bfd_iovec
Index: cache.c
===================================================================
RCS file: /cvs/src/src/bfd/cache.c,v
retrieving revision 1.27
diff -u -p -r1.27 cache.c
--- cache.c 27 Oct 2005 05:31:16 -0000 1.27
+++ cache.c 3 Nov 2005 15:47:23 -0000
@@ -476,15 +476,15 @@ bfd_open_file (bfd *abfd)
{
case read_direction:
case no_direction:
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RB);
+ abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_RB);
break;
case both_direction:
case write_direction:
if (abfd->opened_once)
{
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RUB);
+ abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_RUB);
if (abfd->iostream == NULL)
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB);
+ abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB);
}
else
{
@@ -514,7 +514,7 @@ bfd_open_file (bfd *abfd)
if (stat (abfd->filename, &s) == 0 && s.st_size != 0)
unlink_if_ordinary (abfd->filename);
#endif
- abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB);
+ abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB);
abfd->opened_once = TRUE;
}
break;
Index: configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.196
diff -u -p -r1.196 configure.in
--- configure.in 25 Oct 2005 17:40:10 -0000 1.196
+++ configure.in 3 Nov 2005 15:47:25 -0000
@@ -921,7 +921,7 @@ AC_SUBST(bfd_default_target_size)
# fseeko, long. This assumes that sizeof off_t is .ge. sizeof long.
# Hopefully a reasonable assumption since fseeko et.al. should be
# upward compatible.
-AC_CHECK_FUNCS(ftello ftello64 fseeko fseeko64)
+AC_CHECK_FUNCS(ftello ftello64 fseeko fseeko64 fopen64)
if test x"$ac_cv_func_ftello" = xyes -a x"$ac_cv_func_fseeko" = xyes; then
AC_CHECK_SIZEOF(off_t)
fi
Index: libbfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd-in.h,v
retrieving revision 1.58
diff -u -p -r1.58 libbfd-in.h
--- libbfd-in.h 27 Oct 2005 03:36:57 -0000 1.58
+++ libbfd-in.h 3 Nov 2005 15:47:25 -0000
@@ -651,6 +651,7 @@ extern void _bfd_abort
the system "off_t" or "off64_t", as the offset. */
extern file_ptr real_ftell (FILE *file);
extern int real_fseek (FILE *file, file_ptr offset, int whence);
+extern FILE *real_fopen (const char *filename, const char *modes);
/* List of supported target vectors, and the default vector (if
bfd_default_vector[0] is NULL, there is no default). */
Index: opncls.c
===================================================================
RCS file: /cvs/src/src/bfd/opncls.c,v
retrieving revision 1.40
diff -u -p -r1.40 opncls.c
--- opncls.c 5 Oct 2005 21:24:23 -0000 1.40
+++ opncls.c 3 Nov 2005 15:47:26 -0000
@@ -175,7 +175,7 @@ bfd_fopen (const char *filename, const c
nbfd->iostream = fdopen (fd, mode);
else
#endif
- nbfd->iostream = fopen (filename, mode);
+ nbfd->iostream = real_fopen (filename, mode);
if (nbfd->iostream == NULL)
{
bfd_set_error (bfd_error_system_call);
@@ -1407,7 +1407,7 @@ bfd_fill_in_gnu_debuglink_section (bfd *
.gnu_debuglink section, we insist upon the user providing us with a
correct-for-section-creation-time path, but this need not conform to
the gdb location algorithm. */
- handle = fopen (filename, FOPEN_RB);
+ handle = real_fopen (filename, FOPEN_RB);
if (handle == NULL)
{
bfd_set_error (bfd_error_system_call);