aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1996-07-11 07:41:51 +0000
committerFred Fish <fnf@specifix.com>1996-07-11 07:41:51 +0000
commit5410991408fb224962a53189e5f94aeec854e649 (patch)
tree7c16ab2e87ea7e2274a0193ccfbad8723a994e9a /gdb/objfiles.c
parent7f12eb53ca94589c030b562c362b6283f1b002e4 (diff)
downloadgdb-5410991408fb224962a53189e5f94aeec854e649.zip
gdb-5410991408fb224962a53189e5f94aeec854e649.tar.gz
gdb-5410991408fb224962a53189e5f94aeec854e649.tar.bz2
* Makefile.in (MMALLOC_CFLAGS): Eliminate intermediate MMALLOC_DISABLE
and MMALLOC_CHECK macros, and add comment indicating how host dependent makefile fragment should modify MMALLOC_CFLAGS to not use mmalloc, or to use it but to not do heap corruption checking. * gdbserver/Makefile.in: Ditto. * utils.c (init_malloc): Replace warning() use with direct call of fprintf_unfiltered, since current_target has not yet been set and thus we cannot use warning(). If we try to use mmcheck and it fails, suggest that this configuration needs NO_MMCHECK or MMCHECK_FORCE defined. Other small mmalloc related cleanups. * config/sparc/sun4os4.mh (MMALLOC_CFLAGS): Define MMCHECK_FORCE to 1. * config/alpha/alpha-osf2.mh (MMALLOC_CFLAGS): Set to -DNO_MMCHECK. * config/sparc/xm-sun4os4.h (MMAP_BASE_ADDRESS, MMAP_INCREMENT): * config/i386/xm-i386v4.h (MMAP_BASE_ADDRESS, MMAP_INCREMENT): * config/i386/xm-linux.h (MMAP_BASE_ADDRESS, MMAP_INCREMENT): * config/m68k/xm-hp300hpux.h (MMAP_BASE_ADDRESS, MMAP_INCREMENT): * config/m68k/xm-m68kv4.h (MMAP_BASE_ADDRESS, MMAP_INCREMENT); * config/m68k/xm-sun3os4.h (MMAP_BASE_ADDRESS, MMAP_INCREMENT): * config/pa/xm-hppah.h (MMAP_BASE_ADDRESS, MMAP_INCREMENT): * config/sparc/xm-sun4sol2.h (MMAP_BASE_ADDRESS, MMAP_INCREMENT): Remove obsolete defines. * config/alpha/alpha-linux.mh (MMALLOC_DISABLE): * config/alpha/alpha-osf1.mh (MMALLOC_DISABLE): * config/rs6000/rs6000.mh (MMALLOC_DISABLE): * config/rs6000/aix4.mh (MMALLOC_DISABLE): * config/powerpc/aix4.mh (MMALLOC_DISABLE): * config/powerpc/aix.mh (MMALLOC_DISABLE): * config/ns32k/ns32km3.mh (MMALLOC_DISABLE): * config/mips/mipsm3.mh (MMALLOC_DISABLE): * config/mips/decstation.mh (MMALLOC_DISABLE): * config/m88k/cxux.mh (MMALLOC_DISABLE): * config/i386/i386mk.mh (MMALLOC_DISABLE): * config/i386/i386m3.mh (MMALLOC_DISABLE): * config/i386/i386gnu.mh (MMALLOC_DISABLE): Use MMALLOC_CFLAGS instead.
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r--gdb/objfiles.c51
1 files changed, 48 insertions, 3 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 97b05dc..85f35cb 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -48,6 +48,9 @@ open_mapped_file PARAMS ((char *filename, long mtime, int mapped));
static CORE_ADDR
map_to_address PARAMS ((void));
+static PTR
+map_to_file PARAMS ((int));
+
#endif /* !defined(NO_MMALLOC) && defined(HAVE_MMAP) */
/* Externally visible variables that are owned by this module.
@@ -144,11 +147,9 @@ allocate_objfile (abfd, mapped)
mapped);
if (fd >= 0)
{
- CORE_ADDR mapto;
PTR md;
- if (((mapto = map_to_address ()) == 0) ||
- ((md = mmalloc_attach (fd, (PTR) mapto)) == NULL))
+ if ((md = map_to_file (fd)) == NULL)
{
close (fd);
}
@@ -870,6 +871,50 @@ map_to_address ()
}
+static PTR
+map_to_file (fd)
+ int fd;
+{
+ PTR md;
+ CORE_ADDR mapto;
+ int tempfd;
+
+ md = mmalloc_attach (fd, (PTR) 0);
+ if (md != NULL)
+ {
+ mapto = (CORE_ADDR) mmalloc_getkey (md, 1);
+ md = mmalloc_detach (md);
+ if (md != NULL)
+ {
+ /* FIXME: should figure out why detach failed */
+ md = NULL;
+ }
+ else if (mapto != (CORE_ADDR) NULL)
+ {
+ /* This mapping file needs to be remapped at "mapto" */
+ md = mmalloc_attach (fd, (PTR) mapto);
+ }
+ else
+ {
+ /* This is a freshly created mapping file. */
+ mapto = (CORE_ADDR) mmalloc_findbase (20 * 1024 * 1024);
+ if (mapto != -1)
+ {
+ /* To avoid reusing the freshly created mapping file, at the
+ address selected by mmap, we must truncate it before trying
+ to do an attach at the address we want. */
+ ftruncate (fd, 0);
+ md = mmalloc_attach (fd, (PTR) mapto);
+ if (md != NULL)
+ {
+ mmalloc_setkey (md, 1, (PTR) mapto);
+ }
+ }
+ }
+ }
+ return (md);
+}
+
#endif /* !defined(NO_MMALLOC) && defined(HAVE_MMAP) */
/* Returns a section whose range includes PC or NULL if none found. */