diff options
-rw-r--r-- | gdb/ChangeLog | 13 | ||||
-rw-r--r-- | gdb/dbxread.c | 98 | ||||
-rw-r--r-- | gdb/gdb-stabs.h | 5 | ||||
-rw-r--r-- | gdb/stabsread.c | 4 | ||||
-rw-r--r-- | gdb/stabsread.h | 12 |
5 files changed, 77 insertions, 55 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5f12759..0a8cf3f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +Mon Oct 7 10:42:32 1996 Per Bothner <bothner@deneb.cygnus.com> + + Replace header_files global by per-objfile field. + * gdb-stabs.h (struct dbx_symfile_info): Add fields header_files, + n_header_files, n_allocated_header_files. + * stabsread.h (header_files, n_header_files, n_allocated_header_files): + Replace externs by macros HEADER_FILES, N_HEADER_FILES, and + N_ALLOCATED_HEADER_FILES. + * dbxread.c (dbx_symfile_finish): Free HEADER_FILES. + (free_header_files, init_header-files): Don't free/init headerfiles. + (various functions): Use macros instead of header_files globals. + * stabsread.c (various functions): Likewise. + Sun Oct 6 22:43:06 1996 Jason Merrill <jason@yorick.cygnus.com> * dwarf2read.c (read_tag_reference_type): New fn. diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 5b0e5cc..35884bb 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -41,10 +41,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #endif #include "obstack.h" -#include <sys/param.h> -#ifndef NO_SYS_FILE -#include <sys/file.h> -#endif #include "gdb_stat.h" #include <ctype.h> #include "symtab.h" @@ -279,24 +275,11 @@ add_this_object_header_file PARAMS ((int)); static void free_header_files () { - register int i; - - if (header_files != NULL) - { - for (i = 0; i < n_header_files; i++) - { - free (header_files[i].name); - } - free ((PTR)header_files); - header_files = NULL; - n_header_files = 0; - } if (this_object_header_files) { free ((PTR)this_object_header_files); this_object_header_files = NULL; } - n_allocated_header_files = 0; n_allocated_this_object_header_files = 0; } @@ -305,11 +288,6 @@ free_header_files () static void init_header_files () { - n_header_files = 0; - n_allocated_header_files = 10; - header_files = (struct header_file *) - xmalloc (10 * sizeof (struct header_file)); - n_allocated_this_object_header_files = 10; this_object_header_files = (int *) xmalloc (10 * sizeof (int)); } @@ -342,10 +320,10 @@ add_old_header_file (name, instance) char *name; int instance; { - register struct header_file *p = header_files; + register struct header_file *p = HEADER_FILES (current_objfile); register int i; - for (i = 0; i < n_header_files; i++) + for (i = 0; i < N_HEADER_FILES (current_objfile); i++) if (STREQ (p[i].name, name) && instance == p[i].instance) { add_this_object_header_file (i); @@ -371,26 +349,40 @@ add_new_header_file (name, instance) int instance; { register int i; + register struct header_file *hfile; /* Make sure there is room for one more header file. */ - if (n_header_files == n_allocated_header_files) + i = N_ALLOCATED_HEADER_FILES (current_objfile); + + if (N_HEADER_FILES (current_objfile) == i) { - n_allocated_header_files *= 2; - header_files = (struct header_file *) - xrealloc ((char *) header_files, - (n_allocated_header_files * sizeof (struct header_file))); + if (i == 0) + { + N_ALLOCATED_HEADER_FILES (current_objfile) = 10; + HEADER_FILES (current_objfile) = (struct header_file *) + xmalloc (10 * sizeof (struct header_file)); + } + else + { + i *= 2; + N_ALLOCATED_HEADER_FILES (current_objfile) = i; + HEADER_FILES (current_objfile) = (struct header_file *) + xrealloc ((char *) HEADER_FILES (current_objfile), + (i * sizeof (struct header_file))); + } } /* Create an entry for this header file. */ - i = n_header_files++; - header_files[i].name = savestring (name, strlen(name)); - header_files[i].instance = instance; - header_files[i].length = 10; - header_files[i].vector + i = N_HEADER_FILES (current_objfile)++; + hfile = HEADER_FILES (current_objfile) + i; + hfile->name = savestring (name, strlen(name)); + hfile->instance = instance; + hfile->length = 10; + hfile->vector = (struct type **) xmalloc (10 * sizeof (struct type *)); - memset (header_files[i].vector, 0, 10 * sizeof (struct type *)); + memset (hfile->vector, 0, 10 * sizeof (struct type *)); add_this_object_header_file (i); } @@ -400,7 +392,7 @@ static struct type ** explicit_lookup_type (real_filenum, index) int real_filenum, index; { - register struct header_file *f = &header_files[real_filenum]; + register struct header_file *f = &HEADER_FILES (current_objfile)[real_filenum]; if (index >= f->length) { @@ -522,29 +514,26 @@ dbx_symfile_read (objfile, section_offsets, mainline) val = strlen (objfile->name); + sym_bfd = objfile->obfd; + /* .o and .nlm files are relocatables with text, data and bss segs based at 0. This flag disables special (Solaris stabs-in-elf only) fixups for - symbols with a value of 0. XXX - This is a Krock. Solaris stabs-in-elf - should be fixed to determine pst->textlow without using this text seg of - 0 fixup crap. */ + symbols with a value of 0. */ - if (strcmp (&objfile->name[val-2], ".o") == 0 - || strcmp (&objfile->name[val-4], ".nlm") == 0) - symfile_relocatable = 1; + symfile_relocatable = bfd_get_file_flags (sym_bfd) & HAS_RELOC; /* This is true for Solaris (and all other systems which put stabs in sections, hopefully, since it would be silly to do things differently from Solaris), and false for SunOS4 and other a.out file formats. */ block_address_function_relative = - ((0 == strncmp (bfd_get_target (objfile->obfd), "elf", 3)) - || (0 == strncmp (bfd_get_target (objfile->obfd), "som", 3)) - || (0 == strncmp (bfd_get_target (objfile->obfd), "coff", 4)) - || (0 == strncmp (bfd_get_target (objfile->obfd), "pe", 2)) - || (0 == strncmp (bfd_get_target (objfile->obfd), "nlm", 3))); + ((0 == strncmp (bfd_get_target (sym_bfd), "elf", 3)) + || (0 == strncmp (bfd_get_target (sym_bfd), "som", 3)) + || (0 == strncmp (bfd_get_target (sym_bfd), "coff", 4)) + || (0 == strncmp (bfd_get_target (sym_bfd), "pe", 2)) + || (0 == strncmp (bfd_get_target (sym_bfd), "nlm", 3))); - sym_bfd = objfile->obfd; - val = bfd_seek (objfile->obfd, DBX_SYMTAB_OFFSET (objfile), SEEK_SET); + val = bfd_seek (sym_bfd, DBX_SYMTAB_OFFSET (objfile), SEEK_SET); if (val < 0) perror_with_name (objfile->name); @@ -730,6 +719,17 @@ dbx_symfile_finish (objfile) { if (objfile->sym_stab_info != NULL) { + if (HEADER_FILES (objfile) != NULL) + { + register int i = N_HEADER_FILES (objfile); + register struct header_file *hfiles = HEADER_FILES (objfile); + + while (--i >= 0) + { + free (hfiles [i].name); + } + free ((PTR) hfiles); + } mfree (objfile -> md, objfile->sym_stab_info); } free_header_files (); diff --git a/gdb/gdb-stabs.h b/gdb/gdb-stabs.h index cb7b621..fabe17c 100644 --- a/gdb/gdb-stabs.h +++ b/gdb/gdb-stabs.h @@ -64,6 +64,11 @@ struct dbx_symfile_info { int symbol_size; /* Bytes in a single symbol */ struct stab_section_info *stab_section_info; /* section starting points of the original .o files before linking. */ + + /* See stabsread.h for the use of the following. */ + struct header_file *header_files; + int n_header_files; + int n_allocated_header_files; }; #define DBX_SYMFILE_INFO(o) ((struct dbx_symfile_info *)((o)->sym_stab_info)) diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 8c03a6f..adc0a36 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -344,7 +344,7 @@ Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.", { real_filenum = this_object_header_files[filenum]; - if (real_filenum >= n_header_files) + if (real_filenum >= N_HEADER_FILES (current_objfile)) { struct type *temp_type; struct type **temp_type_p; @@ -358,7 +358,7 @@ Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.", return temp_type_p; } - f = &header_files[real_filenum]; + f = HEADER_FILES (current_objfile) + real_filenum; f_orig_length = f->length; if (index >= f_orig_length) diff --git a/gdb/stabsread.h b/gdb/stabsread.h index 0a1d165..c08635f 100644 --- a/gdb/stabsread.h +++ b/gdb/stabsread.h @@ -106,11 +106,15 @@ struct header_file }; -EXTERN struct header_file *header_files; +/* The table of header_files of this OBJFILE. */ +#define HEADER_FILES(OBJFILE) (DBX_SYMFILE_INFO (OBJFILE)->header_files) -EXTERN int n_header_files; +/* The actual length of HEADER_FILES. */ +#define N_HEADER_FILES(OBJFILE) (DBX_SYMFILE_INFO (OBJFILE)->n_header_files) -EXTERN int n_allocated_header_files; +/* The allocated lengh of HEADER_FILES. */ +#define N_ALLOCATED_HEADER_FILES(OBJFILE) \ + (DBX_SYMFILE_INFO (OBJFILE)->n_allocated_header_files) /* Within each object file, various header files are assigned numbers. A type is defined or referred to with a pair of numbers @@ -118,7 +122,7 @@ EXTERN int n_allocated_header_files; and TYPENUM is the number within that header file. TYPENUM is the index within the vector of types for that header file. - FILENUM == 1 is special; it refers to the main source of the object file, + FILENUM == 0 is special; it refers to the main source of the object file, and not to any header file. FILENUM != 1 is interpreted by looking it up in the following table, which contains indices in header_files. */ |