aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.c
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1993-10-21 20:41:50 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1993-10-21 20:41:50 +0000
commit100f92e2dea21ccb7de8fb0cb3a9b70d43d55bad (patch)
tree29f70f683bed980e1fec4d7cf5c1325bf63fed81 /gdb/objfiles.c
parentefa0c22e67c2858aec856d734b2a89da68cde606 (diff)
downloadgdb-100f92e2dea21ccb7de8fb0cb3a9b70d43d55bad.zip
gdb-100f92e2dea21ccb7de8fb0cb3a9b70d43d55bad.tar.gz
gdb-100f92e2dea21ccb7de8fb0cb3a9b70d43d55bad.tar.bz2
* Makefile.in (c-exp.tab.o): Remove notice about shift/reduce conflicts
which no longer occur. gcc -Wall lint: * findvar.c (symbol_read_needs_frame), corelow.c (ignore), inflow.c (gdb_has_a_terminal): Make sure to return a value. * regex.h: Declare re_set_syntax. * printcmd.c: Include valprint.h. * infcmd.c, exec.c, maint.c, core.c: Include language.h. * maint.c: Include expression.h. * infrun.c, fork-child.c, corelow.c, inflow.c: Include thread.h. * inftarg.c: Include command.h. * coredep.c: Include value.h. * c-exp.y, m2-exp.y, ch-exp.y: Include bfd.h, symfile.h and objfiles.h. * ch-typeprint.c: Include typeprint.h. * ch-valprint.c: Include c-lang.h. * nlmread.c: Include buildsym.h. * environ.c: Include gdbcore.h. Only include defs.h once. (set_in_environ): Cast const char * to char * when passing to set_gnutarget. Remove unused variables: * printcmd.c (printf_command): args_to_vprintf. * coffread.c (coff_symfile_init): strsection. Move variables to within the #ifdefs where they are used: * symtab.c (gdb_mangle_name): opname. * inftarg.c (child_attach): pid and exec_file. * inftarg.c (child_detach): siggnal. * objfiles.c (allocate_objfile): mapto, md, and fd. * objfiles.c (free_objfile): mmfd. * infrun.c (wait_for_inferior): Include BPSTAT_WHAT_LAST in switch. * infrun.c (wait_for_inferior): Remove unused same_pid label. * inferior.h: Declare set_sigint_trap and clear_sigint_trap. * parser-defs.h: Declare write_exp_elt_block. * stabsread.h: Declare elfstab_offset_sections and coffstab_build_psymtabs.
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r--gdb/objfiles.c145
1 files changed, 77 insertions, 68 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index b111f00..b890657 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -120,79 +120,88 @@ allocate_objfile (abfd, mapped)
int mapped;
{
struct objfile *objfile = NULL;
- int fd;
- PTR md;
- CORE_ADDR mapto;
mapped |= mapped_symbol_files;
#if !defined(NO_MMALLOC) && defined(HAVE_MMAP)
+ {
- /* If we can support mapped symbol files, try to open/reopen the mapped file
- that corresponds to the file from which we wish to read symbols. If the
- objfile is to be mapped, we must malloc the structure itself using the
- mmap version, and arrange that all memory allocation for the objfile uses
- the mmap routines. If we are reusing an existing mapped file, from which
- we get our objfile pointer, we have to make sure that we update the
- pointers to the alloc/free functions in the obstack, in case these
- functions have moved within the current gdb. */
-
- fd = open_mapped_file (bfd_get_filename (abfd), bfd_get_mtime (abfd),
- mapped);
- if (fd >= 0)
- {
- if (((mapto = map_to_address ()) == 0) ||
- ((md = mmalloc_attach (fd, (PTR) mapto)) == NULL))
- {
- close (fd);
- }
- else if ((objfile = (struct objfile *) mmalloc_getkey (md, 0)) != NULL)
- {
- /* Update memory corruption handler function addresses. */
- init_malloc (md);
- objfile -> md = md;
- objfile -> mmfd = fd;
- /* Update pointers to functions to *our* copies */
- obstack_chunkfun (&objfile -> psymbol_obstack, xmmalloc);
- obstack_freefun (&objfile -> psymbol_obstack, mfree);
- obstack_chunkfun (&objfile -> symbol_obstack, xmmalloc);
- obstack_freefun (&objfile -> symbol_obstack, mfree);
- obstack_chunkfun (&objfile -> type_obstack, xmmalloc);
- obstack_freefun (&objfile -> type_obstack, mfree);
- /* If already in objfile list, unlink it. */
- unlink_objfile (objfile);
- /* Forget things specific to a particular gdb, may have changed. */
- objfile -> sf = NULL;
- }
- else
- {
- /* Set up to detect internal memory corruption. MUST be done before
- the first malloc. See comments in init_malloc() and mmcheck(). */
- init_malloc (md);
- objfile = (struct objfile *) xmmalloc (md, sizeof (struct objfile));
- memset (objfile, 0, sizeof (struct objfile));
- objfile -> md = md;
- objfile -> mmfd = fd;
- objfile -> flags |= OBJF_MAPPED;
- mmalloc_setkey (objfile -> md, 0, objfile);
- obstack_specify_allocation_with_arg (&objfile -> psymbol_obstack,
- 0, 0, xmmalloc, mfree,
- objfile -> md);
- obstack_specify_allocation_with_arg (&objfile -> symbol_obstack,
- 0, 0, xmmalloc, mfree,
- objfile -> md);
- obstack_specify_allocation_with_arg (&objfile -> type_obstack,
- 0, 0, xmmalloc, mfree,
- objfile -> md);
- }
- }
+ /* If we can support mapped symbol files, try to open/reopen the
+ mapped file that corresponds to the file from which we wish to
+ read symbols. If the objfile is to be mapped, we must malloc
+ the structure itself using the mmap version, and arrange that
+ all memory allocation for the objfile uses the mmap routines.
+ If we are reusing an existing mapped file, from which we get
+ our objfile pointer, we have to make sure that we update the
+ pointers to the alloc/free functions in the obstack, in case
+ these functions have moved within the current gdb. */
+
+ int fd;
+
+ fd = open_mapped_file (bfd_get_filename (abfd), bfd_get_mtime (abfd),
+ mapped);
+ if (fd >= 0)
+ {
+ CORE_ADDR mapto;
+ PTR md;
- if (mapped && (objfile == NULL))
- {
- warning ("symbol table for '%s' will not be mapped",
- bfd_get_filename (abfd));
- }
+ if (((mapto = map_to_address ()) == 0) ||
+ ((md = mmalloc_attach (fd, (PTR) mapto)) == NULL))
+ {
+ close (fd);
+ }
+ else if ((objfile = (struct objfile *) mmalloc_getkey (md, 0)) != NULL)
+ {
+ /* Update memory corruption handler function addresses. */
+ init_malloc (md);
+ objfile -> md = md;
+ objfile -> mmfd = fd;
+ /* Update pointers to functions to *our* copies */
+ obstack_chunkfun (&objfile -> psymbol_obstack, xmmalloc);
+ obstack_freefun (&objfile -> psymbol_obstack, mfree);
+ obstack_chunkfun (&objfile -> symbol_obstack, xmmalloc);
+ obstack_freefun (&objfile -> symbol_obstack, mfree);
+ obstack_chunkfun (&objfile -> type_obstack, xmmalloc);
+ obstack_freefun (&objfile -> type_obstack, mfree);
+ /* If already in objfile list, unlink it. */
+ unlink_objfile (objfile);
+ /* Forget things specific to a particular gdb, may have changed. */
+ objfile -> sf = NULL;
+ }
+ else
+ {
+ /* Set up to detect internal memory corruption. MUST be
+ done before the first malloc. See comments in
+ init_malloc() and mmcheck(). */
+
+ init_malloc (md);
+
+ objfile = (struct objfile *)
+ xmmalloc (md, sizeof (struct objfile));
+ memset (objfile, 0, sizeof (struct objfile));
+ objfile -> md = md;
+ objfile -> mmfd = fd;
+ objfile -> flags |= OBJF_MAPPED;
+ mmalloc_setkey (objfile -> md, 0, objfile);
+ obstack_specify_allocation_with_arg (&objfile -> psymbol_obstack,
+ 0, 0, xmmalloc, mfree,
+ objfile -> md);
+ obstack_specify_allocation_with_arg (&objfile -> symbol_obstack,
+ 0, 0, xmmalloc, mfree,
+ objfile -> md);
+ obstack_specify_allocation_with_arg (&objfile -> type_obstack,
+ 0, 0, xmmalloc, mfree,
+ objfile -> md);
+ }
+ }
+
+ if (mapped && (objfile == NULL))
+ {
+ warning ("symbol table for '%s' will not be mapped",
+ bfd_get_filename (abfd));
+ }
+ }
#else /* defined(NO_MMALLOC) || !defined(HAVE_MMAP) */
if (mapped)
@@ -304,8 +313,6 @@ void
free_objfile (objfile)
struct objfile *objfile;
{
- int mmfd;
-
/* First do any symbol file specific actions required when we are
finished with a particular symbol file. Note that if the objfile
is using reusable symbol information (via mmalloc) then each of
@@ -362,6 +369,8 @@ free_objfile (objfile)
{
/* Remember the fd so we can close it. We can't close it before
doing the detach, and after the detach the objfile is gone. */
+ int mmfd;
+
mmfd = objfile -> mmfd;
mmalloc_detach (objfile -> md);
objfile = NULL;