aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1992-04-17 02:59:43 +0000
committerFred Fish <fnf@specifix.com>1992-04-17 02:59:43 +0000
commit2d6d969c616d286076df1778db0d06a64f11251a (patch)
tree1cd211eb346eef7d90fcfbbb6e2ba561138f06bd
parentd453b386ac60cb219f5949da95cb99d1e22ad6b9 (diff)
downloadgdb-2d6d969c616d286076df1778db0d06a64f11251a.zip
gdb-2d6d969c616d286076df1778db0d06a64f11251a.tar.gz
gdb-2d6d969c616d286076df1778db0d06a64f11251a.tar.bz2
Fix to dwarfread.c to target pointer and target long sizes, fixes for
mapped symbol file handling, and a couple of other misc small fixes.
-rw-r--r--gdb/ChangeLog21
-rw-r--r--gdb/dwarfread.c18
-rw-r--r--gdb/objfiles.c68
-rw-r--r--gdb/objfiles.h19
-rw-r--r--gdb/xcoffexec.c1
-rw-r--r--gdb/xcoffsolib.c3
6 files changed, 104 insertions, 26 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3fb8628..c190ce7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,24 @@
+Thu Apr 16 19:56:50 1992 Fred Fish (fnf@cygnus.com)
+
+ * dwarfread.c (TARGET_FT_POINTER_SIZE, TARGET_FT_LONG_SIZE):
+ Define using TARGET_PTR_BIT and TARGET_LONG_BIT for now.
+ * objfiles.c: Cast calls to close() with unused returns to void.
+ * objfiles.c (allocate_objfile): Initialize objfile's mmfd, free
+ old objfile's name before updating it.
+ * objfiles.c (free_objfile): Major rewrite for mapped objfiles.
+ * objfiles.h (objfile struct): Add mmfd member.
+ * symfile.c (syms_from_objfile): Move some code to
+ new_symfile_objfile.
+ * symfile.c (new_symfile_objfile): Add new function, common code
+ from syms_from_objfile.
+ * symfile.c (symbol_file_add): Call new_symfile_objfile for both
+ mapped and unmapped symbol files.
+ * symfile.c (symbol_file_command): Print "No symbol file now"
+ message, ala exec_file_command for the exec file.
+ * symfile.h (new_symfile_objfile): Add prototype.
+ * xcoffexec.c (map_vmap): Add call to new_symfile_objfile.
+ * xcoffsolib.c (solib_add): Add call to new_symfile_objfile.
+
Thu Apr 16 18:26:34 1992 Per Bothner (bothner@cygnus.com)
* rs6000-pinsn.c: New version from IBM (Metin).
diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c
index 161fc78..2e52295 100644
--- a/gdb/dwarfread.c
+++ b/gdb/dwarfread.c
@@ -103,15 +103,15 @@ typedef unsigned int DIE_REF; /* Reference to a DIE */
/* Macros that return the sizes of various types of data in the target
environment.
- FIXME: They currently just return the sizes in the host environment.
- They need to be able to get the right size either from the bfd or possibly
- from the DWARF info. It would be nice if the DWARF producer inserted DIES
- that describe the fundamental types in the target environment into the
- DWARF info, similar to the way dbx stabs producers produce information
- about their fundamental types. */
-
-#define TARGET_FT_POINTER_SIZE(objfile) sizeof (PTR) /* FIXME */
-#define TARGET_FT_LONG_SIZE(objfile) sizeof (long) /* FIXME */
+ FIXME: Currently these are just compile time constants (as they are in
+ other parts of gdb as well). They need to be able to get the right size
+ either from the bfd or possibly from the DWARF info. It would be nice if
+ the DWARF producer inserted DIES that describe the fundamental types in
+ the target environment into the DWARF info, similar to the way dbx stabs
+ producers produce information about their fundamental types. */
+
+#define TARGET_FT_POINTER_SIZE(objfile) (TARGET_PTR_BIT / TARGET_CHAR_BIT)
+#define TARGET_FT_LONG_SIZE(objfile) (TARGET_LONG_BIT / TARGET_CHAR_BIT)
/* The Amiga SVR4 header file <dwarf.h> defines AT_element_list as a
FORM_BLOCK2, and this is the value emitted by the AT&T compiler.
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index faf9e96..9842615 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -84,13 +84,14 @@ allocate_objfile (abfd, mapped)
if (((mapto = map_to_address ()) == 0) ||
((md = mmalloc_attach (fd, (void *) mapto)) == NULL))
{
- close (fd);
+ (void) 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);
@@ -107,6 +108,7 @@ allocate_objfile (abfd, mapped)
objfile = (struct objfile *) xmmalloc (md, sizeof (struct objfile));
(void) memset (objfile, 0, sizeof (struct objfile));
objfile -> md = md;
+ objfile -> mmfd = fd;
objfile -> flags |= OBJF_MAPPED;
mmalloc_setkey (objfile -> md, 0, objfile);
obstack_full_begin (&objfile -> psymbol_obstack, 0, 0,
@@ -165,6 +167,10 @@ allocate_objfile (abfd, mapped)
region. */
objfile -> obfd = abfd;
+ if (objfile -> name != NULL)
+ {
+ mfree (objfile -> md, objfile -> name);
+ }
objfile -> name = mstrsave (objfile -> md, bfd_get_filename (abfd));
objfile -> mtime = bfd_get_mtime (abfd);
@@ -186,28 +192,40 @@ allocate_objfile (abfd, mapped)
objfile -> sf
- */
+ FIXME: If the objfile is using reusable symbol information (via mmalloc),
+ then we need to take into account the fact that more than one process
+ may be using the symbol information at the same time (when mmalloc is
+ extended to support cooperative locking). When more than one process
+ is using the mapped symbol info, we need to be more careful about when
+ we free objects in the reusable area. */
void
free_objfile (objfile)
struct objfile *objfile;
{
struct objfile *ofp;
+ 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
+ these routines is responsible for doing the correct thing, either
+ freeing things which are valid only during this particular gdb
+ execution, or leaving them to be reused during the next one. */
if (objfile -> sf != NULL)
{
(*objfile -> sf -> sym_finish) (objfile);
}
- if (objfile -> name != NULL)
- {
- mfree (objfile -> md, objfile -> name);
- }
+
+ /* We always close the bfd. */
+
if (objfile -> obfd != NULL)
{
bfd_close (objfile -> obfd);
}
- /* Remove it from the chain of all objfiles. */
+ /* Remove it from the chain of all objfiles. */
if (object_files == objfile)
{
@@ -220,13 +238,11 @@ free_objfile (objfile)
if (ofp -> next == objfile)
{
ofp -> next = objfile -> next;
+ break;
}
}
}
-
- obstack_free (&objfile -> psymbol_obstack, 0);
- obstack_free (&objfile -> symbol_obstack, 0);
- obstack_free (&objfile -> type_obstack, 0);
+ objfile -> next = NULL;
#if 0 /* FIXME!! */
@@ -245,9 +261,31 @@ free_objfile (objfile)
#endif
- /* The last thing we do is free the objfile struct itself */
+ /* The last thing we do is free the objfile struct itself for the
+ non-reusable case, or detach from the mapped file for the reusable
+ case. Note that the mmalloc_detach or the mfree is the last thing
+ we can do with this objfile. */
- mfree (objfile -> md, objfile);
+ if (objfile -> flags & OBJF_MAPPED)
+ {
+ /* 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. */
+ mmfd = objfile -> mmfd;
+ mmalloc_detach (objfile -> md);
+ (void) close (mmfd);
+ }
+ else
+ {
+ if (objfile -> name != NULL)
+ {
+ mfree (objfile -> md, objfile -> name);
+ }
+ /* Free the obstacks for non-reusable objfiles */
+ obstack_free (&objfile -> psymbol_obstack, 0);
+ obstack_free (&objfile -> symbol_obstack, 0);
+ obstack_free (&objfile -> type_obstack, 0);
+ mfree (objfile -> md, objfile);
+ }
}
@@ -356,7 +394,7 @@ open_mapped_file (filename, mtime, mapped)
{
if (fstat (fd, &sbuf) != 0)
{
- close (fd);
+ (void) close (fd);
perror_with_name (symfilename);
}
else if (sbuf.st_mtime > mtime)
@@ -365,7 +403,7 @@ open_mapped_file (filename, mtime, mapped)
}
else
{
- close (fd);
+ (void) close (fd);
fd = -1;
}
}
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 554c9b8..d158fbb 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -124,7 +124,18 @@ struct objfile
/* All struct objfile's are chained together by their next pointers.
The global variable "object_files" points to the first link in this
- chain. */
+ chain.
+
+ FIXME: There is a problem here if the objfile is reusable, and if
+ multiple users are to be supported. The problem is that the objfile
+ list is linked through a member of the objfile struct itself, which
+ is only valid for one gdb process. The list implementation needs to
+ be changed to something like:
+
+ struct list {struct list *next; struct objfile *objfile};
+
+ where the list structure is completely maintained separately within
+ each gdb process. */
struct objfile *next;
@@ -205,6 +216,12 @@ struct objfile
PTR md;
+ /* The file descriptor that was used to obtain the mmalloc descriptor
+ for this objfile. If we call mmalloc_detach with the malloc descriptor
+ we should then close this file descriptor. */
+
+ int mmfd;
+
/* Structure which keeps track of functions that manipulate objfile's
of the same type as this objfile. I.E. the function to read partial
symbols for example. Note that this structure is in statically
diff --git a/gdb/xcoffexec.c b/gdb/xcoffexec.c
index b17d874..8e4322f 100644
--- a/gdb/xcoffexec.c
+++ b/gdb/xcoffexec.c
@@ -345,6 +345,7 @@ map_vmap (bfd *bf, bfd *arch)
we don't have to load them as default anymore.
syms_from_objfile (obj, 0, 0, 0);
+ new_symfile_objfile (obj, 0, 0);
#endif
}
diff --git a/gdb/xcoffsolib.c b/gdb/xcoffsolib.c
index 0ad8432..4d2893f 100644
--- a/gdb/xcoffsolib.c
+++ b/gdb/xcoffsolib.c
@@ -77,7 +77,8 @@ solib_add (arg_string, from_tty, target)
continue;
}
- syms_from_objfile (obj, 0, 0);
+ syms_from_objfile (obj, 0, 0, 0);
+ new_symfile_objfile (obj, 0, 0);
vmap_symtab (vp, 0, 0);
printf ("Done.\n");
loaded = vp->loaded = 1;