This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: patch for large corefile support on linux
- From: Andrew Cagney <cagney at gnu dot org>
- To: Bart Robinson <lomew at pobox dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Tue, 06 Jul 2004 10:26:59 -0400
- Subject: Re: patch for large corefile support on linux
- References: <16530.60194.94064.59942@bas.flux.utah.edu>
Dear Patches,
This is a simple patch that seems to allow debugging of >2gb
corefiles.
We've had problems dealing with large corefiles on Linux and I
tried gdb 6.1 recently since it had some code in BFD to do
lseek64 and stuff. I noticed all I had to do to get GDB dealing
with them was to add O_LARGEFILE to the core file open. (We
have previously patched our kernel to open the core file write
with O_LARGEFILE as well, but this may be default in later
kernels.) This is on a 32bit x86 platform.
I doubt it will let >4gb corefiles work in gdb, as the elf32
header is still being used AFIAK, but it helps. Also, large
*program* files aren't covered, but that is less of an issue.
Diff against 6.1 sources.
Draining the patch backlog for 6.2, I've checked this in. Thanks!
committed the attached,
Andrew
2004-07-05 Andrew Cagney <cagney@gnu.org>
Patch from Bart Robinson.
* corelow.c (core_open): Add variable "flags", or in O_LARGEFILE.
(O_LARGEFILE): Define to 0, if not defined.
Index: corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.40
diff -p -u -r1.40 corelow.c
--- corelow.c 25 May 2004 16:04:07 -0000 1.40
+++ corelow.c 6 Jul 2004 14:10:46 -0000
@@ -50,6 +50,10 @@
#define O_BINARY 0
#endif
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0
+#endif
+
/* List of all available core_fns. On gdb startup, each core file
register reader calls deprecated_add_core_fns() to register
information on each core format it is prepared to read. */
@@ -280,6 +284,7 @@ core_open (char *filename, int from_tty)
bfd *temp_bfd;
int ontop;
int scratch_chan;
+ int flags;
target_preopen (from_tty);
if (!filename)
@@ -299,7 +304,12 @@ core_open (char *filename, int from_tty)
old_chain = make_cleanup (xfree, filename);
- scratch_chan = open (filename, O_BINARY | ( write_files ? O_RDWR : O_RDONLY ), 0);
+ flags = O_BINARY | O_LARGEFILE;
+ if (write_files)
+ flags |= O_RDWR;
+ else
+ flags |= O_RDONLY;
+ scratch_chan = open (filename, flags, 0);
if (scratch_chan < 0)
perror_with_name (filename);