diff options
author | Fred Fish <fnf@specifix.com> | 1992-03-15 01:09:14 +0000 |
---|---|---|
committer | Fred Fish <fnf@specifix.com> | 1992-03-15 01:09:14 +0000 |
commit | 318bf84ffe5bc5472cefe0c1a838f132f9ac4ff9 (patch) | |
tree | 928f9df1d55c71c1bf0d2238a942e8fe5cd9dfc9 /gdb | |
parent | 0750528ab6401a40f6673eeb29b58dea7a6e92b9 (diff) | |
download | gdb-318bf84ffe5bc5472cefe0c1a838f132f9ac4ff9.zip gdb-318bf84ffe5bc5472cefe0c1a838f132f9ac4ff9.tar.gz gdb-318bf84ffe5bc5472cefe0c1a838f132f9ac4ff9.tar.bz2 |
Globs of changes. See the ChangeLog for details. Most related to
using the new mmalloc package.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 94 | ||||
-rw-r--r-- | gdb/Makefile.in | 54 | ||||
-rw-r--r-- | gdb/c-exp.y | 6 | ||||
-rw-r--r-- | gdb/coffread.c | 633 | ||||
-rw-r--r-- | gdb/cplus-dem.c | 12 | ||||
-rw-r--r-- | gdb/dbxread.c | 47 | ||||
-rw-r--r-- | gdb/defs.h | 71 | ||||
-rwxr-xr-x | gdb/depend | 7 | ||||
-rw-r--r-- | gdb/dwarfread.c | 20 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 46 | ||||
-rw-r--r-- | gdb/i386-xdep.c | 8 | ||||
-rw-r--r-- | gdb/i387-tdep.c | 2 | ||||
-rw-r--r-- | gdb/infrun.c | 6 | ||||
-rw-r--r-- | gdb/language.c | 19 | ||||
-rw-r--r-- | gdb/m2-exp.y | 6 | ||||
-rw-r--r-- | gdb/main.c | 55 | ||||
-rw-r--r-- | gdb/minsyms.c | 2 | ||||
-rw-r--r-- | gdb/objfiles.c | 262 | ||||
-rw-r--r-- | gdb/source.c | 201 | ||||
-rw-r--r-- | gdb/symfile.c | 151 | ||||
-rw-r--r-- | gdb/symfile.h | 317 | ||||
-rw-r--r-- | gdb/symm-xdep.c | 8 | ||||
-rw-r--r-- | gdb/symmisc.c | 755 | ||||
-rw-r--r-- | gdb/symtab.c | 73 | ||||
-rw-r--r-- | gdb/xm-amix.h | 10 | ||||
-rw-r--r-- | gdb/xm-i386v4.h | 10 | ||||
-rw-r--r-- | gdb/xm-sun3os4.h | 10 | ||||
-rw-r--r-- | gdb/xm-sun4os4.h | 10 |
28 files changed, 1980 insertions, 915 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 401efb6..fc5cd33 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,97 @@ +Sat Mar 14 16:38:47 1992 Fred Fish (fnf@cygnus.com) + + * gmalloc.c, gmalloc.h mcheck.c mmap-alloc.c mmap-sbrk.c mtrace.c, + state.c, state.h: Removed. + * .gdbinit: Add ../malloc, ../libiberty, and ../bfd to list of + directories searched for source files. + * Makefile.in (GNU_MALLOC, MALLOC_CFLAGS, MALLOCSRC): Removed + * Makefile.in (MMALLOC_DIR, MMALLOC_DEP, MMALLOC_LIB, + MMALLOC_DISABLE, MMALLOC_CHECK, MMALLOC_CFLAGS): Add + * Makefile.in (CFLAGS): Replace MALLOC_CFLAGS with MMALLOC_CFLAGS. + * Makefile.in (CLIBS, CDEPS): Add MMALLOC_LIB + * Makefile.in (ADD_FILES, ADD_DEPS): Remove GNU_MALLOC. + * Makefile.in (SFILES_MAINDIR): Remove stat.c mmap-alloc.c, mmap- + sbrk.c + * Makefile.in (HFILES): Remove state.h + * Makefile.in (POSSLIBS_MAINDIR): Remove MALLOCSRC. + * Makefile.in (OBS): Remove state.o mmap-alloc.o mmap-sbrk.o + * Makefile.in (saber_gdb): Remove mcheck, mtrace. Add MMALLOC_DIR. + * Makefile.in (clean): Remove all object files. + * c-exp.y: Define malloc to xmalloc and realloc to xrealloc. + * cplus-dem.c: Remove prototypes definitions that are now done in + def.h. + * dbxread.c (throughout): Change from using per-objfile + xmalloc/xrealloc/free functions to xmmalloc/xmrealloc/mfree. + * defs.h: Remove prototypes for mmap_* functions. Add prototypes + for xmmalloc, xmrealloc, mfree, mmcheck, mmtrace, mmalloc_attach, + mmalloc_detach, mmalloc_setkey, msavestring, and mstrsave, nomem. + * depend: Remove dependencies for state.o, state.h. + * dwarfread.c: Add declaration for warning_pre_print. + * dwarfread.c (dwarfwarn): Use warning_pre_print. + * dwarfread.c (throughout): Change from using per-objfile + xmalloc/xrealloc/free functions to xmmalloc/xmrealloc/mfree. + * gdbtypes.c (lookup_fundamental_type): Fix init_type calls to + use supplied objfile. + * i386-xdep.c (print_387_status): Change to use warning() rather + than printfs. + * i387-tdep.c (print_387_control_word): Change to use warning() + rather than printfs. + * infrun.c (wait_for_inferior): Remove unreachable abort() call + that some compilers grumble about. + * language.c (throughout): Add declaration for warning_pre_print + and using warning() instead of printfs. + * m2-exp.y: Define malloc to xmalloc and realloc to xrealloc. + * main.c (main): Add declaration for warning_pre_print and set it + similarly to error_pre_print. Add declarations for + mapped_symbol_files and readnow_symbol_files. Add appropriate + definitions to long_options[]. + * minsyms.c: Trivial fix to comment. + * objfiles.c (allocate_objfile): Substantially rewritten for + using mapped symbol files. + * objfiles.c (throughout): Change from using per-objfile + xmalloc/xrealloc/free functions to xmmalloc/xmrealloc/mfree. + * objfiles.c (open_mapped_file, mapped_to_address): Add functions. + * source.c (throughout): Change from using per-objfile + xmalloc/xrealloc/free functions to xmmalloc/xmrealloc/mfree. + * source.c (open_source_file): Use mstrsave to save file name in + mapped symbol region for objfile. + * symfile.c: Remove include for state.h. + include to local form. + * symfile.c (symbol_file_add_digested): Remove. + * symfile.c (symbol_file_add): Substantially rewritten for mapped + symbol files. + * symfile.h: Remove malloc/xrealloc/xmalloc/xrealloc/free members + from objfile structure. Add malloc descriptor pointer (md). + * symfile.h (OBJF_DUMPABLE): Changed name to OBJF_MAPPED. + * symm-xdep.c (print_fpu_status): Use warning() rather than + printfs. + * symmisc.c (free_symtab_block): Now takes and uses current + objfile pointer. + * symmisc.c (throughout): Change from using per-objfile + xmalloc/xrealloc/free functions to xmmalloc/xmrealloc/mfree. + * symtab.c (cplus_mangled_symbol): Cast return value to avoid + Sun compiler grumblings when PTR is char *. + * symtab.c (lookup_symbol): Cast return value of iterate_over_ + msymbols() to correct pointer type. + * utils.c (warning_pre_print): Initialize to "\nwarning: ". + * utils.c (fatal, fatal_dump_core): Ensure that the fatal + error always starts on a line of it's own. + * utils.c (init_malloc, malloc_botch, xmalloc, xrealloc): + Rewrite for new mapped malloc package use. + * utils.c (mmalloc, mrealloc, mfree): Stubs for configurations + that don't want to use the mapped malloc package; pass arguments + on to traditional malloc package functions. + * utils.c (nomem): Add for fatal virtual memory exhausted aborts. + * utils.c (xmmalloc, xmrealloc, xmalloc, xrealloc): Like mmalloc, + mrealloc, malloc, and realloc but get fatal error if runs out + of memory. + * utils.c (msavestring, mstrsave): Save a string in a specific + mapped malloc region. + * utils.c (print_spaces): Use xmalloc to get the buffer. + * xm-amix.h, xm-i386v4.h, xm-sun3os4.h, xm-sun4os4.h: Add defines + for MMAP_BASE_ADDRESS and MMAP_INCREMENT. + * config/i386v4.mh: Insignificant reorganization. + Sat Mar 14 11:44:47 1992 Fred Fish (fnf@cygnus.com) * xcoffread.c: Only enable compilation of debugging functions diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 665d536..48a7647 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -96,18 +96,24 @@ MAKEINFO=makeinfo #CC-LD=gcc -static CC-LD=${CC} -# define this to be "gmalloc.o" if you want to use the gnu malloc routine -# (useful for debugging memory allocation problems in gdb). To use your -# system malloc, uncomment the following two lines. -#GNU_MALLOC = -#MALLOC_CFLAGS = -DNO_MALLOC_CHECK -GNU_MALLOC = gmalloc.o mcheck.o mtrace.o -MALLOC_CFLAGS = - # Where is the "include" directory? Traditionally ../include or ./include INCLUDE_DIR = ${srcdir}/../include INCLUDE_DEP = $$(INCLUDE_DIR) +# Where is the source dir for the MMALLOC library? Traditionally ../mmalloc +# or ./mmalloc (When we want the binary library built from it, we use +# ${MMALLOC_DIR}${subdir}.) +# Note that mmalloc can still be used on systems without mmap(). +# To use your system malloc, comment out the following defines. +MMALLOC_DIR = ${srcdir}/../mmalloc +MMALLOC_DEP = $$(MMALLOC_DIR) +MMALLOC_LIB = ./../mmalloc${subdir}/libmmalloc.a +# To use your system malloc, uncomment MMALLOC_DISABLE. +#MMALLOC_DISABLE = -DNO_MMALLOC +# To use mmalloc but disable corruption checking, uncomment MMALLOC_CHECK +#MMALLOC_CHECK = -DNO_MMALLOC_CHECK +MMALLOC_CFLAGS = ${MMALLOC_CHECK} ${MMALLOC_DISABLE} + # Where is the source dir for the BFD library? Traditionally ../bfd or ./bfd # (When we want the binary library built from it, we use ${BFD_DIR}${subdir}.) BFD_DIR = ${srcdir}/../bfd @@ -134,7 +140,7 @@ GLOBAL_CFLAGS = ${MINUS_G} ${TM_CFLAGS} ${XM_CFLAGS} # CFLAGS is the aggregate of several individual *_CFLAGS macros. # USER_CFLAGS is specifically reserved for setting from the command line # when running make. I.E. "make USER_CFLAGS=-Wmissing-prototypes". -CFLAGS = ${GLOBAL_CFLAGS} ${PROFILE_CFLAGS} ${MALLOC_CFLAGS} ${INCLUDE_CFLAGS} ${USER_CFLAGS} +CFLAGS = ${GLOBAL_CFLAGS} ${PROFILE_CFLAGS} ${MMALLOC_CFLAGS} ${INCLUDE_CFLAGS} ${USER_CFLAGS} # None of the things in CFLAGS will do any harm, and on some systems # (e.g. SunOS4) it is important to use the M_CFLAGS. LDFLAGS = $(CFLAGS) @@ -151,11 +157,13 @@ LIBIBERTY = ./../libiberty${subdir}/libiberty.a # Libraries and corresponding dependencies for compiling gdb. # {X,T}M_CLIBS, defined in *config files, have host- and target-dependent libs. # TERMCAP comes after readline, since readline depends on it. -CLIBS = ${BFD_LIB} ${RL_LIB} ${TERMCAP} ${LIBIBERTY} ${XM_CLIBS} ${TM_CLIBS} -CDEPS = ${XM_CDEPS} ${TM_CDEPS} ${BFD_LIB} ${LIBIBERTY} ${RL_LIB} +CLIBS = ${BFD_LIB} ${RL_LIB} ${TERMCAP} ${MMALLOC_LIB} ${LIBIBERTY} \ + ${XM_CLIBS} ${TM_CLIBS} +CDEPS = ${XM_CDEPS} ${TM_CDEPS} ${BFD_LIB} ${MMALLOC_LIB} ${LIBIBERTY} \ + ${RL_LIB} ${MMALLOC_LIB} -ADD_FILES = ${REGEX} ${ALLOCA} ${GNU_MALLOC} ${XM_ADD_FILES} ${TM_ADD_FILES} -ADD_DEPS = ${REGEX1} ${ALLOCA1} ${GNU_MALLOC} ${XM_ADD_FILES} ${TM_ADD_FILES} +ADD_FILES = ${REGEX} ${ALLOCA} ${XM_ADD_FILES} ${TM_ADD_FILES} +ADD_DEPS = ${REGEX1} ${ALLOCA1} ${XM_ADD_FILES} ${TM_ADD_FILES} VERSION = 4.4.5 DIST=gdb @@ -178,8 +186,8 @@ SFILES_MAINDIR = \ utils.c valarith.c valops.c valprint.c values.c c-exp.y m2-exp.y \ signame.c cplus-dem.c mem-break.c target.c inftarg.c \ dbxread.c coffread.c elfread.c dwarfread.c xcoffread.c \ - ieee-float.c language.c parse.c buildsym.c state.c objfiles.c \ - minsyms.c mmap-alloc.c mmap-sbrk.c + ieee-float.c language.c parse.c buildsym.c objfiles.c \ + minsyms.c # Source files in subdirectories (which will be handled separately by # 'make gdb.tar.Z'). @@ -224,16 +232,13 @@ SFILES_KGDB = $(SFILES) stuff.c kdb-start.c HFILES= breakpoint.h buildsym.h command.h defs.h environ.h \ expression.h frame.h gdbcmd.h gdbcore.h gdbtypes.h \ ieee-float.h inferior.h minimon.h partial-stab.h \ - signals.h signame.h symfile.h symtab.h state.h solib.h \ + signals.h signame.h symfile.h symtab.h solib.h \ target.h terminal.h tm-68k.h tm-i960.h tm-sunos.h tm-sysv4.h \ xm-m68k.h xm-sysv4.h language.h parser-defs.h value.h REMOTE_EXAMPLES = m68k-stub.c i386-stub.c rem-multi.shar -MALLOCSRC = gmalloc.c mcheck.c mtrace.c mtrace.awk \ - gmalloc.h - -POSSLIBS_MAINDIR = regex.c regex.h alloca.c $(MALLOCSRC) +POSSLIBS_MAINDIR = regex.c regex.h alloca.c POSSLIBS = $(POSSLIBS_MAINDIR) TESTS = testbpt.c testfun.c testrec.c testreg.c testregs.c @@ -267,7 +272,7 @@ OBS = main.o blockframe.o breakpoint.o findvar.o stack.o source.o \ command.o utils.o expprint.o environ.o version.o gdbtypes.o \ copying.o $(DEPFILES) signame.o cplus-dem.o mem-break.o target.o \ inftarg.o ieee-float.o putenv.o parse.o language.o $(YYOBJ) \ - buildsym.o state.o objfiles.o minsyms.o mmap-alloc.o mmap-sbrk.o \ + buildsym.o objfiles.o minsyms.o \ dbxread.o coffread.o elfread.o dwarfread.o xcoffread.o # mipsread.o RAPP_OBS = rgdb.o rudp.o rserial.o serial.o udp.o $(XDEPFILES) @@ -330,9 +335,8 @@ saber_gdb: $(SFILES) $(DEPFILES) copying.c version.c #load ${LIBIBERTY_DIR}/*.c #load ${BFD_DIR}/*.c #load ${READLINE_DIR}/*.c + #load ${MMALLOC_DIR}/*.c #load -ltermcap - ##void mcheck(a) void (*a)(); { } - ##void mtrace() { } @@ -532,8 +536,8 @@ make-proto-gdb-1: ${TARFILES} ${TARDIRS} gdb.info chmod og=u `find . -print` clean: - rm -f ${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} - rm -f init.c init.o version.c + rm -f *.o ${ADD_FILES} + rm -f init.c version.c rm -f gdb core gdb.tar gdb.tar.Z make.log rm -f gdb[0-9] $(MAKE) subdir_do DO=clean "DODIRS=$(SUBDIRS)" diff --git a/gdb/c-exp.y b/gdb/c-exp.y index dc10d2b..c131643 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -39,6 +39,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "value.h" #include "language.h" +/* Ensure that if the generated parser contains any calls to malloc/realloc, + that they get mapped to xmalloc/xrealloc. */ + +#define malloc xmalloc +#define realloc xrealloc + /* These MUST be included in any grammar file!!!! Please choose unique names! */ #define yymaxdepth c_maxdepth diff --git a/gdb/coffread.c b/gdb/coffread.c index 13c3f2d..49a8000 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -18,40 +18,20 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdio.h> #include "defs.h" #include "symtab.h" +#include "gdbtypes.h" #include "breakpoint.h" #include "bfd.h" #include "symfile.h" - +#include "buildsym.h" #include <obstack.h> + #include <string.h> #include "coff/internal.h" /* Internal format of COFF symbols in BFD */ #include "libcoff.h" /* FIXME secret internal data from BFD */ -static void add_symbol_to_list (); -static void read_coff_symtab (); -static void patch_opaque_types (); -static struct type *decode_function_type (); -static struct type *decode_type (); -static struct type *decode_base_type (); -static struct type *read_enum_type (); -static struct type *read_struct_type (); -static void finish_block (); -static struct blockvector *make_blockvector (); -static struct symbol *process_coff_symbol (); -static int init_stringtab (); -static void free_stringtab (); -static char *getfilename (); -static char *getsymname (); -static int init_lineno (); -static void enter_linenos (); -static void read_one_sym (); - -extern int fclose (); - /* To be an sdb debug type, type must have at least a basic or primary derived type. Using this rather than checking against T_NULL is said to prevent core dumps if we try to operate on Michael Bloom @@ -68,11 +48,6 @@ extern int fclose (); # define SDB_REG_TO_REGNUM(value) (value) #endif -/* Name of source file whose symbol data we are now processing. - This comes from a symbol named ".file". */ - -static char *last_source_file; - /* Core address of start and end of text of current source file. This comes from a ".text" symbol where x_nlinno > 0. */ @@ -88,18 +63,6 @@ static CORE_ADDR first_object_file_end; static FILE *nlist_stream_global; static int nlist_nsyms_global; -/* The index in the symbol table of the last coff symbol that was processed. */ - -static int symnum; - -/* Vector of types defined so far, indexed by their coff symnum. */ - -static struct type **type_vector; - -/* Number of elements allocated for type_vector currently. */ - -static int type_vector_length; - /* Vector of line number information. */ static struct linetable *line_vector; @@ -150,41 +113,40 @@ static unsigned local_auxesz; /* Chain of typedefs of pointers to empty struct/union types. They are chained thru the SYMBOL_VALUE_CHAIN. */ -#define HASHSIZE 127 static struct symbol *opaque_type_chain[HASHSIZE]; /* Record the symbols defined for each context in a list. We don't create a struct block for the context until we know how long to make it. */ -struct pending +struct coff_pending { - struct pending *next; + struct coff_pending *next; struct symbol *symbol; }; /* Here are the three lists that symbols are put on. */ -struct pending *file_symbols; /* static at top level, and types */ +struct coff_pending *coff_file_symbols; /* static at top level, and types */ -struct pending *global_symbols; /* global functions and variables */ +struct coff_pending *coff_global_symbols; /* global functions and variables */ -struct pending *local_symbols; /* everything local to lexical context */ +struct coff_pending *coff_local_symbols; /* everything local to lexical context */ /* List of unclosed lexical contexts (that will become blocks, eventually). */ -struct context_stack +struct coff_context_stack { - struct context_stack *next; - struct pending *locals; + struct coff_context_stack *next; + struct coff_pending *locals; struct pending_block *old_blocks; struct symbol *name; CORE_ADDR start_addr; int depth; }; -struct context_stack *context_stack; +struct coff_context_stack *coff_context_stack; /* Nonzero if within a function (so symbols should be local, if nothing says specifically). */ @@ -198,15 +160,6 @@ int within_function; struct type *in_function_type; #endif -/* List of blocks already made (lexical contexts already closed). - This is used at the end to make the blockvector. */ - -struct pending_block -{ - struct pending_block *next; - struct block *block; -}; - struct pending_block *pending_blocks; extern CORE_ADDR startup_file_start; /* From blockframe.c */ @@ -231,6 +184,116 @@ struct complaint unexpected_type_complaint = struct complaint bad_sclass_complaint = {"Bad n_sclass for symbol %s", 0, 0}; + +/* Simplified internal version of coff symbol table information */ + +struct coff_symbol { + char *c_name; + int c_symnum; /* symbol number of this entry */ + int c_naux; /* 0 if syment only, 1 if syment + auxent, etc */ + long c_value; + int c_sclass; + int c_secnum; + unsigned int c_type; +}; + +static struct type * +coff_read_struct_type PARAMS ((int, int, int)); + +static struct type * +decode_base_type PARAMS ((struct coff_symbol *, unsigned int, + union internal_auxent *)); + +static struct type * +decode_type PARAMS ((struct coff_symbol *, unsigned int, + union internal_auxent *)); + +static struct type * +decode_function_type PARAMS ((struct coff_symbol *, unsigned int, + union internal_auxent *)); + +static struct type * +coff_read_enum_type PARAMS ((int, int, int)); + +static struct blockvector * +make_blockvector PARAMS ((struct objfile *)); + +static struct symbol * +process_coff_symbol PARAMS ((struct coff_symbol *, union internal_auxent *, + struct objfile *)); + +static PTR +patch_opaque_types PARAMS ((struct objfile *, struct symtab *, PTR, PTR, PTR)); + +static void +patch_type PARAMS ((struct type *, struct type *)); + +static void +enter_linenos PARAMS ((long, int, int)); + +static int +init_lineno PARAMS ((int, long, int)); + +static char * +getfilename PARAMS ((union internal_auxent *)); + +static char * +getsymname PARAMS ((struct internal_syment *)); + +static void +free_stringtab PARAMS ((void)); + +static int +init_stringtab PARAMS ((int, long)); + +static void +read_one_sym PARAMS ((struct coff_symbol *, struct internal_syment *, + union internal_auxent *)); + +static void +read_coff_symtab PARAMS ((int, int, struct objfile *)); + +static void +coff_new_init PARAMS ((void)); + +static void +coff_symfile_read PARAMS ((struct sym_fns *, CORE_ADDR, int)); + +static void +find_linenos PARAMS ((bfd *, sec_ptr, PTR)); + +static void +coff_symfile_init PARAMS ((struct sym_fns *)); + +static void +record_minimal_symbol PARAMS ((char *, CORE_ADDR)); + +static void +coff_end_symtab PARAMS ((struct objfile *)); + +static void +complete_symtab PARAMS ((char *, CORE_ADDR, unsigned int)); + +static void +coff_start_symtab PARAMS ((void)); + +static void +coff_record_line PARAMS ((int, CORE_ADDR)); + +static void +coff_finish_block PARAMS ((struct symbol *, struct coff_pending **, + struct pending_block *, CORE_ADDR, CORE_ADDR, + struct objfile *)); + +static void +coff_add_symbol_to_list PARAMS ((struct symbol *, struct coff_pending **)); + +static struct type * +coff_alloc_type PARAMS ((int)); + +static struct type ** +coff_lookup_type PARAMS ((int)); + /* Look up a coff type-number index. Return the address of the slot where the type for that index is stored. @@ -252,7 +315,8 @@ coff_lookup_type (index) type_vector_length = index * 2; } type_vector = (struct type **) - xrealloc (type_vector, type_vector_length * sizeof (struct type *)); + xrealloc ((char *) type_vector, + type_vector_length * sizeof (struct type *)); bzero (&type_vector[old_vector_length], (type_vector_length - old_vector_length) * sizeof(struct type *)); } @@ -273,12 +337,9 @@ coff_alloc_type (index) /* If we are referring to a type not known at all yet, allocate an empty type for it. We will fill it in later if we find out how. */ - if (type == 0) + if (type == NULL) { - type = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - bzero (type, sizeof (struct type)); - TYPE_VPTR_FIELDNO (type) = -1; + type = alloc_type (current_objfile); *type_addr = type; } return type; @@ -288,12 +349,12 @@ coff_alloc_type (index) /* Add a symbol to one of the lists of symbols. */ static void -add_symbol_to_list (symbol, listhead) +coff_add_symbol_to_list (symbol, listhead) struct symbol *symbol; - struct pending **listhead; + struct coff_pending **listhead; { - register struct pending *link - = (struct pending *) xmalloc (sizeof (struct pending)); + register struct coff_pending *link + = (struct coff_pending *) xmalloc (sizeof (struct coff_pending)); link->next = *listhead; link->symbol = symbol; @@ -304,13 +365,14 @@ add_symbol_to_list (symbol, listhead) Put the block on the list of pending blocks. */ static void -finish_block (symbol, listhead, old_blocks, start, end) +coff_finish_block (symbol, listhead, old_blocks, start, end, objfile) struct symbol *symbol; - struct pending **listhead; + struct coff_pending **listhead; struct pending_block *old_blocks; CORE_ADDR start, end; + struct objfile *objfile; { - register struct pending *next, *next1; + register struct coff_pending *next, *next1; register struct block *block; register struct pending_block *pblock; struct pending_block *opblock; @@ -321,7 +383,7 @@ finish_block (symbol, listhead, old_blocks, start, end) for (next = *listhead, i = 0; next; next = next->next, i++); block = (struct block *) - obstack_alloc (symbol_obstack, sizeof (struct block) + (i - 1) * sizeof (struct symbol *)); + obstack_alloc (&objfile->symbol_obstack, sizeof (struct block) + (i - 1) * sizeof (struct symbol *)); /* Copy the symbols into the block. */ @@ -383,7 +445,8 @@ finish_block (symbol, listhead, old_blocks, start, end) } static struct blockvector * -make_blockvector () +make_blockvector (objfile) + struct objfile *objfile; { register struct pending_block *next, *next1; register struct blockvector *blockvector; @@ -394,12 +457,12 @@ make_blockvector () for (next = pending_blocks, i = 0; next; next = next->next, i++); blockvector = (struct blockvector *) - obstack_alloc (symbol_obstack, sizeof (struct blockvector) + (i - 1) * sizeof (struct block *)); + obstack_alloc (&objfile->symbol_obstack, sizeof (struct blockvector) + (i - 1) * sizeof (struct block *)); /* Copy the blocks into the blockvector. This is done in reverse order, which happens to put the blocks into the proper order (ascending starting address). - finish_block has hair to insert each block into the list + coff_finish_block has hair to insert each block into the list after its subblocks in order to make sure this is true. */ BLOCKVECTOR_NBLOCKS (blockvector) = i; @@ -421,7 +484,7 @@ make_blockvector () /* Manage the vector of line numbers. */ static void -record_line (line, pc) +coff_record_line (line, pc) int line; CORE_ADDR pc; { @@ -432,7 +495,7 @@ record_line (line, pc) { line_vector_length *= 2; line_vector = (struct linetable *) - xrealloc (line_vector, sizeof (struct linetable) + xrealloc ((char *) line_vector, sizeof (struct linetable) + (line_vector_length * sizeof (struct linetable_entry))); } @@ -446,11 +509,11 @@ record_line (line, pc) it indicates the start of data for one original source file. */ static void -start_symtab () +coff_start_symtab () { - file_symbols = 0; - global_symbols = 0; - context_stack = 0; + coff_file_symbols = 0; + coff_global_symbols = 0; + coff_context_stack = 0; within_function = 0; last_source_file = 0; @@ -495,28 +558,28 @@ complete_symtab (name, start_addr, size) struct symtab for that file and put it in the list of all such. */ static void -end_symtab (objfile) +coff_end_symtab (objfile) struct objfile *objfile; { register struct symtab *symtab; - register struct context_stack *cstk; + register struct coff_context_stack *cstk; register struct blockvector *blockvector; register struct linetable *lv; /* Finish the lexical context of the last function in the file. */ - if (context_stack) + if (coff_context_stack) { - cstk = context_stack; - context_stack = 0; + cstk = coff_context_stack; + coff_context_stack = 0; /* Make a block for the local symbols within. */ - finish_block (cstk->name, &local_symbols, cstk->old_blocks, - cstk->start_addr, cur_src_end_addr); + coff_finish_block (cstk->name, &coff_local_symbols, cstk->old_blocks, + cstk->start_addr, cur_src_end_addr, objfile); free (cstk); } /* Ignore a file that has no functions with real debugging info. */ - if (pending_blocks == 0 && file_symbols == 0 && global_symbols == 0) + if (pending_blocks == 0 && coff_file_symbols == 0 && coff_global_symbols == 0) { free (line_vector); line_vector = 0; @@ -527,11 +590,11 @@ end_symtab (objfile) /* Create the two top-level blocks for this file (STATIC_BLOCK and GLOBAL_BLOCK). */ - finish_block (0, &file_symbols, 0, cur_src_start_addr, cur_src_end_addr); - finish_block (0, &global_symbols, 0, cur_src_start_addr, cur_src_end_addr); + coff_finish_block (0, &coff_file_symbols, 0, cur_src_start_addr, cur_src_end_addr, objfile); + coff_finish_block (0, &coff_global_symbols, 0, cur_src_start_addr, cur_src_end_addr, objfile); /* Create the blockvector that points to all the file's blocks. */ - blockvector = make_blockvector (); + blockvector = make_blockvector (objfile); /* Now create the symtab object for this source file. */ symtab = allocate_symtab (last_source_file, objfile); @@ -545,15 +608,11 @@ end_symtab (objfile) lv = line_vector; lv->nitems = line_vector_index; symtab->linetable = (struct linetable *) - xrealloc (lv, (sizeof (struct linetable) + xrealloc ((char *) lv, (sizeof (struct linetable) + lv->nitems * sizeof (struct linetable_entry))); free_named_symtabs (symtab->filename); - /* Link the new symtab into the list of such. */ - symtab->next = symtab_list; - symtab_list = symtab; - /* Reinitialize for beginning of new file. */ line_vector = 0; line_vector_length = -1; @@ -561,18 +620,18 @@ end_symtab (objfile) } static void -record_misc_function (name, address) +record_minimal_symbol (name, address) char *name; CORE_ADDR address; { - /* We don't want TDESC entry points on the misc_function_vector */ + /* We don't want TDESC entry points in the minimal symbol table */ if (name[0] == '@') return; - /* mf_text isn't true, but apparently COFF doesn't tell us what it really - is, so this guess is more useful than mf_unknown. */ - prim_record_misc_function (savestring (name, strlen (name)), + /* mst_text isn't true, but apparently COFF doesn't tell us what it really + is, so this guess is more useful than mst_unknown. */ + prim_record_minimal_symbol (savestring (name, strlen (name)), address, - (int)mf_text); + (int)mst_text); } /* coff_symfile_init () @@ -639,7 +698,7 @@ static void find_linenos (abfd, asect, vpinfo) bfd *abfd; sec_ptr asect; - void *vpinfo; + PTR vpinfo; { struct coff_symfile_info *info; int size, count; @@ -743,23 +802,25 @@ coff_symfile_read (sf, addr, mainline) if (val < 0) perror_with_name (name); - init_misc_bunches (); - make_cleanup (discard_misc_bunches, 0); + init_minimal_symbol_collection (); + make_cleanup (discard_minimal_symbols, 0); /* Now that the executable file is positioned at symbol table, process it and define symbols accordingly. */ read_coff_symtab (desc, num_symbols, sf->objfile); - patch_opaque_types (); + iterate_over_symtabs (patch_opaque_types, (PTR) NULL, (PTR) NULL, + (PTR) NULL); /* Sort symbols alphabetically within each block. */ sort_all_symtab_syms (); - /* Go over the misc symbol bunches and install them in vector. */ + /* Install any minimal symbols that have been collected as the current + minimal symbols for this objfile. */ - condense_misc_bunches (!mainline); + install_minimal_symbols (sf -> objfile); } static void @@ -768,18 +829,6 @@ coff_new_init () /* Nothin' to do */ } -/* Simplified internal version of coff symbol table information */ - -struct coff_symbol { - char *c_name; - int c_symnum; /* symbol number of this entry */ - int c_naux; /* 0 if syment only, 1 if syment + auxent, etc */ - long c_value; - int c_sclass; - int c_secnum; - unsigned int c_type; -}; - /* Given pointers to a symbol table in coff style exec file, analyze them and create struct symtab's describing the symbols. NSYMS is the number of symbols in the symbol table. @@ -793,7 +842,7 @@ read_coff_symtab (desc, nsyms, objfile) { int newfd; /* Avoid multiple closes on same desc */ FILE *stream; - register struct context_stack *new; + register struct coff_context_stack *new; struct coff_symbol coff_symbol; register struct coff_symbol *cs = &coff_symbol; static struct internal_syment main_sym; @@ -826,6 +875,7 @@ read_coff_symtab (desc, nsyms, objfile) old_chain = make_cleanup (free_objfile, objfile); make_cleanup (fclose, stream); + current_objfile = objfile; nlist_stream_global = stream; nlist_nsyms_global = nsyms; last_source_file = 0; @@ -838,7 +888,7 @@ read_coff_symtab (desc, nsyms, objfile) xmalloc (type_vector_length * sizeof (struct type *)); bzero (type_vector, type_vector_length * sizeof (struct type *)); - start_symtab (); + coff_start_symtab (); symnum = 0; while (symnum < nsyms) @@ -856,9 +906,9 @@ read_coff_symtab (desc, nsyms, objfile) if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE) { if (last_source_file) - end_symtab (objfile); + coff_end_symtab (objfile); - start_symtab (); + coff_start_symtab (); complete_symtab ("_globals_", 0, first_object_file_end); /* done with all files, everything from here on out is globals */ } @@ -871,10 +921,10 @@ read_coff_symtab (desc, nsyms, objfile) /* Typedefs should not be treated as symbol definitions. */ if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF) { - /* record as misc function. if we get '.bf' next, + /* record as a minimal symbol. if we get '.bf' next, * then we undo this step */ - record_misc_function (cs->c_name, cs->c_value); + record_minimal_symbol (cs->c_name, cs->c_value); fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr; fcn_start_addr = cs->c_value; @@ -909,8 +959,8 @@ read_coff_symtab (desc, nsyms, objfile) */ if (last_source_file) { - end_symtab (objfile); - start_symtab (); + coff_end_symtab (objfile); + coff_start_symtab (); } in_source_file = 1; break; @@ -956,16 +1006,16 @@ read_coff_symtab (desc, nsyms, objfile) Coff should provide the SEC_CODE flag for executable sections, then if we could look up sections by section number we could see if the flags indicate SEC_CODE. If so, then - record this symbol as a miscellaneous function. But why - are absolute syms recorded as functions, anyway? */ + record this symbol as a function in the minimal symbol table. + But why are absolute syms recorded as functions, anyway? */ if (cs->c_secnum <= text_bfd_scnum+1) {/* text or abs */ - record_misc_function (cs->c_name, cs->c_value); + record_minimal_symbol (cs->c_name, cs->c_value); break; } else { cs->c_type = T_INT; } } - (void) process_coff_symbol (cs, &main_aux); + (void) process_coff_symbol (cs, &main_aux, objfile); break; case C_FCN: @@ -977,20 +1027,20 @@ read_coff_symtab (desc, nsyms, objfile) /* main_aux.x_sym.x_misc.x_lnsz.x_lnno contains line number of '{' } */ if (cs->c_naux != 1) - complain (&bf_no_aux_complaint, cs->c_symnum); + complain (&bf_no_aux_complaint, (char *) cs->c_symnum); fcn_first_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno; - new = (struct context_stack *) - xmalloc (sizeof (struct context_stack)); + new = (struct coff_context_stack *) + xmalloc (sizeof (struct coff_context_stack)); new->depth = depth = 0; new->next = 0; - context_stack = new; + coff_context_stack = new; new->locals = 0; new->old_blocks = pending_blocks; new->start_addr = fcn_start_addr; fcn_cs_saved.c_name = getsymname (&fcn_sym_saved); new->name = process_coff_symbol (&fcn_cs_saved, - &fcn_aux_saved); + &fcn_aux_saved, objfile); } else if (strcmp (cs->c_name, ".ef") == 0) { @@ -999,22 +1049,22 @@ read_coff_symtab (desc, nsyms, objfile) */ /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno contains number of lines to '}' */ - new = context_stack; + new = coff_context_stack; if (new == 0) { - complain (&ef_complaint, cs->c_symnum); + complain (&ef_complaint, (char *) cs->c_symnum); within_function = 0; break; } if (cs->c_naux != 1) { - complain (&ef_no_aux_complaint, cs->c_symnum); + complain (&ef_no_aux_complaint, (char *) cs->c_symnum); fcn_last_line = 0x7FFFFFFF; } else { fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno; } enter_linenos (fcn_line_ptr, fcn_first_line, fcn_last_line); - finish_block (new->name, &local_symbols, new->old_blocks, + coff_finish_block (new->name, &coff_local_symbols, new->old_blocks, new->start_addr, #if defined (FUNCTION_EPILOGUE_SIZE) /* This macro should be defined only on @@ -1024,13 +1074,14 @@ read_coff_symtab (desc, nsyms, objfile) So use the .bf record information that points to the epilogue and add the size of the epilogue. */ - cs->c_value + FUNCTION_EPILOGUE_SIZE + cs->c_value + FUNCTION_EPILOGUE_SIZE, #else fcn_cs_saved.c_value + - fcn_aux_saved.x_sym.x_misc.x_fsize + fcn_aux_saved.x_sym.x_misc.x_fsize, #endif + objfile ); - context_stack = 0; + coff_context_stack = 0; within_function = 0; free (new); } @@ -1039,47 +1090,48 @@ read_coff_symtab (desc, nsyms, objfile) case C_BLOCK: if (strcmp (cs->c_name, ".bb") == 0) { - new = (struct context_stack *) - xmalloc (sizeof (struct context_stack)); + new = (struct coff_context_stack *) + xmalloc (sizeof (struct coff_context_stack)); depth++; new->depth = depth; - new->next = context_stack; - context_stack = new; - new->locals = local_symbols; + new->next = coff_context_stack; + coff_context_stack = new; + new->locals = coff_local_symbols; new->old_blocks = pending_blocks; new->start_addr = cs->c_value; new->name = 0; - local_symbols = 0; + coff_local_symbols = 0; } else if (strcmp (cs->c_name, ".eb") == 0) { - new = context_stack; + new = coff_context_stack; if (new == 0 || depth != new->depth) error ("Invalid symbol data: .bb/.eb symbol mismatch at symbol %d.", symnum); - if (local_symbols && context_stack->next) + if (coff_local_symbols && coff_context_stack->next) { /* Make a block for the local symbols within. */ - finish_block (0, &local_symbols, new->old_blocks, - new->start_addr, cs->c_value); + coff_finish_block (0, &coff_local_symbols, new->old_blocks, + new->start_addr, cs->c_value, objfile); } depth--; - local_symbols = new->locals; - context_stack = new->next; + coff_local_symbols = new->locals; + coff_context_stack = new->next; free (new); } break; default: - (void) process_coff_symbol (cs, &main_aux); + (void) process_coff_symbol (cs, &main_aux, objfile); break; } } if (last_source_file) - end_symtab (objfile); + coff_end_symtab (objfile); fclose (stream); discard_cleanups (old_chain); + current_objfile = NULL; } /* Routines for reading headers and symbols from executable. */ @@ -1264,7 +1316,6 @@ getfilename (aux_entry) static char buffer[BUFSIZ]; register char *temp; char *result; - extern char *rindex (); #ifndef COFF_NO_LONG_FILE_NAMES #if defined (x_zeroes) @@ -1287,7 +1338,7 @@ getfilename (aux_entry) buffer[FILNMLEN] = '\0'; } result = buffer; - if ((temp = rindex (result, '/')) != NULL) + if ((temp = strrchr (result, '/')) != NULL) result = temp + 1; return (result); } @@ -1347,7 +1398,7 @@ enter_linenos (file_offset, first_line, last_line) if (file_offset < linetab_offset) { - complain (&lineno_complaint, file_offset); + complain (&lineno_complaint, (char *) file_offset); if (file_offset > linetab_size) /* Too big to be an offset? */ return; file_offset += linetab_offset; /* Try reading at that linetab offset */ @@ -1365,33 +1416,12 @@ enter_linenos (file_offset, first_line, last_line) rawptr += local_linesz; /* The next function, or the sentinel, will have L_LNNO32 zero; we exit. */ if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line) - record_line (first_line + L_LNNO32 (&lptr), lptr.l_addr.l_paddr); + coff_record_line (first_line + L_LNNO32 (&lptr), lptr.l_addr.l_paddr); else break; } } -static int -hashname (name) - char *name; -{ - register char *p = name; - register int total = p[0]; - register int c; - - c = p[1]; - total += c << 2; - if (c) - { - c = p[2]; - total += c << 4; - if (c) - total += p[3] << 6; - } - - return total % HASHSIZE; -} - static void patch_type (type, real_type) struct type *type; @@ -1404,7 +1434,7 @@ patch_type (type, real_type) TYPE_LENGTH (target) = TYPE_LENGTH (real_target); TYPE_NFIELDS (target) = TYPE_NFIELDS (real_target); TYPE_FIELDS (target) = (struct field *) - obstack_alloc (symbol_obstack, field_size); + obstack_alloc (¤t_objfile -> type_obstack, field_size); bcopy (TYPE_FIELDS (real_target), TYPE_FIELDS (target), field_size); @@ -1417,86 +1447,100 @@ patch_type (type, real_type) } /* Patch up all appropriate typedef symbols in the opaque_type_chains - so that they can be used to print out opaque data structures properly */ + so that they can be used to print out opaque data structures properly. -static void -patch_opaque_types () -{ - struct symtab *s; + This is called via iterate_over_symtabs, and thus simply returns NULL + for each time it is called, to indicate that the iteration should + continue. */ - /* Look at each symbol in the per-file block of each symtab. */ - for (s = symtab_list; s; s = s->next) +/* ARGSUSED */ +static PTR +patch_opaque_types (objfile, s, arg1, arg2, arg3) + struct objfile *objfile; + struct symtab *s; + PTR arg1; + PTR arg2; + PTR arg3; +{ + register struct block *b; + register int i; + register struct symbol *real_sym; + + /* Go through the per-file symbols only */ + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); + for (i = BLOCK_NSYMS (b) - 1; i >= 0; i--) { - register struct block *b; - register int i; - - /* Go through the per-file symbols only */ - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); - for (i = BLOCK_NSYMS (b) - 1; i >= 0; i--) + /* Find completed typedefs to use to fix opaque ones. + Remove syms from the chain when their types are stored, + but search the whole chain, as there may be several syms + from different files with the same name. */ + real_sym = BLOCK_SYM (b, i); + if (SYMBOL_CLASS (real_sym) == LOC_TYPEDEF && + SYMBOL_NAMESPACE (real_sym) == VAR_NAMESPACE && + TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR && + TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0) { - register struct symbol *real_sym; - - /* Find completed typedefs to use to fix opaque ones. - Remove syms from the chain when their types are stored, - but search the whole chain, as there may be several syms - from different files with the same name. */ - real_sym = BLOCK_SYM (b, i); - if (SYMBOL_CLASS (real_sym) == LOC_TYPEDEF && - SYMBOL_NAMESPACE (real_sym) == VAR_NAMESPACE && - TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR && - TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0) + register char *name = SYMBOL_NAME (real_sym); + register int hash = hashname (name); + register struct symbol *sym, *prev; + + prev = 0; + for (sym = opaque_type_chain[hash]; sym;) { - register char *name = SYMBOL_NAME (real_sym); - register int hash = hashname (name); - register struct symbol *sym, *prev; - - prev = 0; - for (sym = opaque_type_chain[hash]; sym;) + if (name[0] == SYMBOL_NAME (sym)[0] && + !strcmp (name + 1, SYMBOL_NAME (sym) + 1)) { - if (name[0] == SYMBOL_NAME (sym)[0] && - !strcmp (name + 1, SYMBOL_NAME (sym) + 1)) + if (prev) { - if (prev) - SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym); - else - opaque_type_chain[hash] = SYMBOL_VALUE_CHAIN (sym); - - patch_type (SYMBOL_TYPE (sym), SYMBOL_TYPE (real_sym)); - - if (prev) - sym = SYMBOL_VALUE_CHAIN (prev); - else - sym = opaque_type_chain[hash]; + SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym); } else { - prev = sym; - sym = SYMBOL_VALUE_CHAIN (sym); + opaque_type_chain[hash] = SYMBOL_VALUE_CHAIN (sym); } + + patch_type (SYMBOL_TYPE (sym), SYMBOL_TYPE (real_sym)); + + if (prev) + { + sym = SYMBOL_VALUE_CHAIN (prev); + } + else + { + sym = opaque_type_chain[hash]; + } + } + else + { + prev = sym; + sym = SYMBOL_VALUE_CHAIN (sym); } } } } + return (NULL); } static struct symbol * -process_coff_symbol (cs, aux) +process_coff_symbol (cs, aux, objfile) register struct coff_symbol *cs; register union internal_auxent *aux; + struct objfile *objfile; { register struct symbol *sym - = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol)); + = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); char *name; #ifdef NAMES_HAVE_UNDERSCORE int offset = 1; #else int offset = 0; #endif + struct type *temptype; bzero (sym, sizeof (struct symbol)); name = cs->c_name; name = (name[0] == '_' ? name + offset : name); - SYMBOL_NAME (sym) = obstack_copy0 (symbol_obstack, name, strlen (name)); + SYMBOL_NAME (sym) = obstack_copy0 (&objfile->symbol_obstack, name, strlen (name)); /* default assumptions */ SYMBOL_VALUE (sym) = cs->c_value; @@ -1510,7 +1554,7 @@ process_coff_symbol (cs, aux) types of the arguments will be added as we read the symbol table. */ struct type *new = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); + obstack_alloc (&objfile->symbol_obstack, sizeof (struct type)); bcopy(lookup_function_type (decode_function_type (cs, cs->c_type, aux)), new, sizeof(struct type)); @@ -1523,9 +1567,9 @@ process_coff_symbol (cs, aux) SYMBOL_CLASS (sym) = LOC_BLOCK; if (cs->c_sclass == C_STAT) - add_symbol_to_list (sym, &file_symbols); + coff_add_symbol_to_list (sym, &coff_file_symbols); else if (cs->c_sclass == C_EXT) - add_symbol_to_list (sym, &global_symbols); + coff_add_symbol_to_list (sym, &coff_global_symbols); } else { @@ -1537,13 +1581,13 @@ process_coff_symbol (cs, aux) case C_AUTO: SYMBOL_CLASS (sym) = LOC_LOCAL; - add_symbol_to_list (sym, &local_symbols); + coff_add_symbol_to_list (sym, &coff_local_symbols); break; case C_EXT: SYMBOL_CLASS (sym) = LOC_STATIC; SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value; - add_symbol_to_list (sym, &global_symbols); + coff_add_symbol_to_list (sym, &coff_global_symbols); break; case C_STAT: @@ -1551,11 +1595,11 @@ process_coff_symbol (cs, aux) SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value; if (within_function) { /* Static symbol of local scope */ - add_symbol_to_list (sym, &local_symbols); + coff_add_symbol_to_list (sym, &coff_local_symbols); } else { /* Static symbol at top level of file */ - add_symbol_to_list (sym, &file_symbols); + coff_add_symbol_to_list (sym, &coff_file_symbols); } break; @@ -1565,7 +1609,7 @@ process_coff_symbol (cs, aux) case C_REG: SYMBOL_CLASS (sym) = LOC_REGISTER; SYMBOL_VALUE (sym) = SDB_REG_TO_REGNUM(cs->c_value); - add_symbol_to_list (sym, &local_symbols); + coff_add_symbol_to_list (sym, &coff_local_symbols); break; case C_LABEL: @@ -1578,32 +1622,38 @@ process_coff_symbol (cs, aux) /* Add parameter to function. */ add_param_to_type(&in_function_type,sym); #endif - add_symbol_to_list (sym, &local_symbols); + coff_add_symbol_to_list (sym, &coff_local_symbols); #if !defined (BELIEVE_PCC_PROMOTION) /* If PCC says a parameter is a short or a char, it is really an int. */ - if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (builtin_type_int) - && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT) { - SYMBOL_TYPE (sym) = TYPE_UNSIGNED (SYMBOL_TYPE (sym))? - builtin_type_unsigned_int: - builtin_type_int; - } + temptype = lookup_fundamental_type (current_objfile, FT_INTEGER); + if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (temptype) + && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT) + { + SYMBOL_TYPE (sym) = TYPE_UNSIGNED (SYMBOL_TYPE (sym)) + ? lookup_fundamental_type (current_objfile, + FT_UNSIGNED_INTEGER) + : temptype; + } #endif break; case C_REGPARM: SYMBOL_CLASS (sym) = LOC_REGPARM; SYMBOL_VALUE (sym) = SDB_REG_TO_REGNUM(cs->c_value); - add_symbol_to_list (sym, &local_symbols); + coff_add_symbol_to_list (sym, &coff_local_symbols); #if !defined (BELIEVE_PCC_PROMOTION) /* If PCC says a parameter is a short or a char, it is really an int. */ - if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (builtin_type_int) - && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT) { - SYMBOL_TYPE (sym) = TYPE_UNSIGNED (SYMBOL_TYPE (sym))? - builtin_type_unsigned_int: - builtin_type_int; - } + temptype = lookup_fundamental_type (current_objfile, FT_INTEGER); + if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (temptype) + && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT) + { + SYMBOL_TYPE (sym) = TYPE_UNSIGNED (SYMBOL_TYPE (sym)) + ? lookup_fundamental_type (current_objfile, + FT_UNSIGNED_INTEGER) + : temptype; + } #endif break; @@ -1612,10 +1662,8 @@ process_coff_symbol (cs, aux) SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; /* If type has no name, give it one */ - if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0 - && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) - = concat (SYMBOL_NAME (sym), NULL); + if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0) + TYPE_NAME (SYMBOL_TYPE (sym)) = concat (SYMBOL_NAME (sym), NULL); /* Keep track of any type which points to empty structured type, so it can be filled from a definition from another file */ @@ -1627,7 +1675,7 @@ process_coff_symbol (cs, aux) SYMBOL_VALUE_CHAIN (sym) = opaque_type_chain[i]; opaque_type_chain[i] = sym; } - add_symbol_to_list (sym, &file_symbols); + coff_add_symbol_to_list (sym, &coff_file_symbols); break; case C_STRTAG: @@ -1635,8 +1683,7 @@ process_coff_symbol (cs, aux) case C_ENTAG: SYMBOL_CLASS (sym) = LOC_TYPEDEF; SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; - if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0 - && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0) + if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0) TYPE_NAME (SYMBOL_TYPE (sym)) = concat ("", (cs->c_sclass == C_ENTAG @@ -1644,7 +1691,7 @@ process_coff_symbol (cs, aux) : (cs->c_sclass == C_STRTAG ? "struct " : "union ")), SYMBOL_NAME (sym), NULL); - add_symbol_to_list (sym, &file_symbols); + coff_add_symbol_to_list (sym, &coff_file_symbols); break; default: @@ -1700,8 +1747,10 @@ decode_type (cs, c_type, aux) *dim = 0; type = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); + obstack_alloc (¤t_objfile -> type_obstack, + sizeof (struct type)); bzero (type, sizeof (struct type)); + TYPE_OBJFILE (type) = current_objfile; base_type = decode_type (cs, new_c_type, aux); @@ -1753,40 +1802,40 @@ decode_base_type (cs, c_type, aux) { case T_NULL: /* shows up with "void (*foo)();" structure members */ - return builtin_type_void; + return lookup_fundamental_type (current_objfile, FT_VOID); #if 0 /* DGUX actually defines both T_ARG and T_VOID to the same value. */ #ifdef T_ARG case T_ARG: /* Shows up in DGUX, I think. Not sure where. */ - return builtin_type_void; /* shouldn't show up here */ + return lookup_fundamental_type (current_objfile, FT_VOID); /* shouldn't show up here */ #endif #endif /* 0 */ #ifdef T_VOID case T_VOID: /* Intel 960 COFF has this symbol and meaning. */ - return builtin_type_void; + return lookup_fundamental_type (current_objfile, FT_VOID); #endif case T_CHAR: - return builtin_type_char; + return lookup_fundamental_type (current_objfile, FT_CHAR); case T_SHORT: - return builtin_type_short; + return lookup_fundamental_type (current_objfile, FT_SHORT); case T_INT: - return builtin_type_int; + return lookup_fundamental_type (current_objfile, FT_INTEGER); case T_LONG: - return builtin_type_long; + return lookup_fundamental_type (current_objfile, FT_LONG); case T_FLOAT: - return builtin_type_float; + return lookup_fundamental_type (current_objfile, FT_FLOAT); case T_DOUBLE: - return builtin_type_double; + return lookup_fundamental_type (current_objfile, FT_DBL_PREC_FLOAT); case T_STRUCT: if (cs->c_naux != 1) @@ -1802,7 +1851,7 @@ decode_base_type (cs, c_type, aux) } else { - type = read_struct_type (cs->c_symnum, + type = coff_read_struct_type (cs->c_symnum, aux->x_sym.x_misc.x_lnsz.x_size, aux->x_sym.x_fcnary.x_fcn.x_endndx.l); } @@ -1822,7 +1871,7 @@ decode_base_type (cs, c_type, aux) } else { - type = read_struct_type (cs->c_symnum, + type = coff_read_struct_type (cs->c_symnum, aux->x_sym.x_misc.x_lnsz.x_size, aux->x_sym.x_fcnary.x_fcn.x_endndx.l); } @@ -1830,7 +1879,7 @@ decode_base_type (cs, c_type, aux) return type; case T_ENUM: - return read_enum_type (cs->c_symnum, + return coff_read_enum_type (cs->c_symnum, aux->x_sym.x_misc.x_lnsz.x_size, aux->x_sym.x_fcnary.x_fcn.x_endndx.l); @@ -1839,19 +1888,19 @@ decode_base_type (cs, c_type, aux) break; case T_UCHAR: - return builtin_type_unsigned_char; + return lookup_fundamental_type (current_objfile, FT_UNSIGNED_CHAR); case T_USHORT: - return builtin_type_unsigned_short; + return lookup_fundamental_type (current_objfile, FT_UNSIGNED_SHORT); case T_UINT: - return builtin_type_unsigned_int; + return lookup_fundamental_type (current_objfile, FT_UNSIGNED_INTEGER); case T_ULONG: - return builtin_type_unsigned_long; + return lookup_fundamental_type (current_objfile, FT_UNSIGNED_LONG); } complain (&unexpected_type_complaint, cs->c_name); - return builtin_type_void; + return lookup_fundamental_type (current_objfile, FT_VOID); } /* This page contains subroutines of read_type. */ @@ -1860,7 +1909,7 @@ decode_base_type (cs, c_type, aux) and return an object describing the type. */ static struct type * -read_struct_type (index, length, lastsym) +coff_read_struct_type (index, length, lastsym) int index; int length; int lastsym; @@ -1941,7 +1990,8 @@ read_struct_type (index, length, lastsym) TYPE_NFIELDS (type) = nfields; TYPE_FIELDS (type) = (struct field *) - obstack_alloc (symbol_obstack, sizeof (struct field) * nfields); + obstack_alloc (¤t_objfile -> type_obstack, + sizeof (struct field) * nfields); /* Copy the saved-up fields into the field vector. */ @@ -1958,7 +2008,7 @@ read_struct_type (index, length, lastsym) /* ARGSUSED */ static struct type * -read_enum_type (index, length, lastsym) +coff_read_enum_type (index, length, lastsym) int index; int length; int lastsym; @@ -1967,12 +2017,12 @@ read_enum_type (index, length, lastsym) register struct type *type; int nsyms = 0; int done = 0; - struct pending **symlist; + struct coff_pending **symlist; struct coff_symbol member_sym; register struct coff_symbol *ms = &member_sym; struct internal_syment sub_sym; union internal_auxent sub_aux; - struct pending *osyms, *syms; + struct coff_pending *osyms, *syms; register int n; char *name; #ifdef NAMES_HAVE_UNDERSCORE @@ -1983,9 +2033,9 @@ read_enum_type (index, length, lastsym) type = coff_alloc_type (index); if (within_function) - symlist = &local_symbols; + symlist = &coff_local_symbols; else - symlist = &file_symbols; + symlist = &coff_file_symbols; osyms = *symlist; while (!done && symnum < lastsym && symnum < nlist_nsyms_global) @@ -2004,7 +2054,7 @@ read_enum_type (index, length, lastsym) SYMBOL_CLASS (sym) = LOC_CONST; SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; SYMBOL_VALUE (sym) = ms->c_value; - add_symbol_to_list (sym, symlist); + coff_add_symbol_to_list (sym, symlist); nsyms++; break; @@ -2023,7 +2073,8 @@ read_enum_type (index, length, lastsym) TYPE_CODE (type) = TYPE_CODE_ENUM; TYPE_NFIELDS (type) = nsyms; TYPE_FIELDS (type) = (struct field *) - obstack_alloc (symbol_obstack, sizeof (struct field) * nsyms); + obstack_alloc (¤t_objfile -> type_obstack, + sizeof (struct field) * nsyms); /* Find the symbols for the values and put them into the type. The symbols can be found in the symlist that we put them on diff --git a/gdb/cplus-dem.c b/gdb/cplus-dem.c index ed40e37..afe9ee7 100644 --- a/gdb/cplus-dem.c +++ b/gdb/cplus-dem.c @@ -78,18 +78,6 @@ extern char *cplus_demangle (const char *type, int mode); extern char *cplus_demangle (); #endif -#ifdef __STDC__ -/* GDB prototypes these as void* in defs.h, so we better too, at least - as long as we're including defs.h. */ -/* FIXME extern void *xmalloc (int); - extern void *xrealloc (char *, int); */ -extern void free (void *); -#else -extern char *xmalloc (); -extern char *xrealloc (); -extern void free (); -#endif - static char **typevec = 0; static int ntypes = 0; static int typevec_size = 0; diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 5e002df..1f86c8a 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -31,9 +31,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ fledged symbol table by going back and reading the symbols for real. dbx_psymtab_to_symtab() is the function that does this */ -#include <stdio.h> -#include <string.h> #include "defs.h" +#include <string.h> #ifdef USG #include <sys/types.h> @@ -453,9 +452,9 @@ dbx_symfile_read (sf, addr, mainline) /* Free up any memory we allocated for ourselves. */ if (!mainline) { - (*sf->objfile->free) (info->stringtab); /* Stringtab is only saved for mainline */ + mfree (sf->objfile->md, info->stringtab); /* Stringtab is only saved for mainline */ } - (*sf->objfile->free) (info); + mfree (sf->objfile->md, info); sf->sym_private = NULL; /* Zap pointer to our (now gone) info struct */ if (!have_partial_symbols ()) { @@ -510,7 +509,7 @@ dbx_symfile_init (sf) unsigned char size_temp[4]; /* Allocate struct to keep track of the symfile */ - sf->sym_private = (*sf->objfile->xmalloc) (sizeof (*info)); + sf->sym_private = xmmalloc (sf->objfile->md, sizeof (*info)); info = (struct dbx_symfile_info *)sf->sym_private; /* FIXME POKING INSIDE BFD DATA STRUCTURES */ @@ -536,7 +535,7 @@ dbx_symfile_init (sf) if (info->stringtab_size >= 0) { /* Yes, this should be malloc, not xmalloc. We check its result. */ - info->stringtab = (char *) (*sf->objfile->malloc) (info->stringtab_size); + info->stringtab = (char *) mmalloc (sf->objfile->md, info->stringtab_size); /* Caller is responsible for freeing the string table. No cleanup. */ } else @@ -628,9 +627,9 @@ init_psymbol_list (total_symbols, objfile) { /* Free any previously allocated psymbol lists. */ if (objfile -> global_psymbols.list) - (*objfile -> free) (objfile -> global_psymbols.list); + mfree (objfile -> md, objfile -> global_psymbols.list); if (objfile -> static_psymbols.list) - (*objfile -> free) (objfile -> static_psymbols.list); + mfree (objfile -> md, objfile -> static_psymbols.list); /* Current best guess is that there are approximately a twentieth of the total symbols (in a debugging file) are global or static @@ -638,9 +637,9 @@ init_psymbol_list (total_symbols, objfile) objfile -> global_psymbols.size = total_symbols / 10; objfile -> static_psymbols.size = total_symbols / 10; objfile -> global_psymbols.next = objfile -> global_psymbols.list = (struct partial_symbol *) - (*objfile -> xmalloc) (objfile -> global_psymbols.size * sizeof (struct partial_symbol)); + xmmalloc (objfile -> md, objfile -> global_psymbols.size * sizeof (struct partial_symbol)); objfile -> static_psymbols.next = objfile -> static_psymbols.list = (struct partial_symbol *) - (*objfile -> xmalloc) (objfile -> static_psymbols.size * sizeof (struct partial_symbol)); + xmmalloc (objfile -> md, objfile -> static_psymbols.size * sizeof (struct partial_symbol)); } /* Initialize the list of bincls to contain none and have some @@ -653,7 +652,7 @@ init_bincl_list (number, objfile) { bincls_allocated = number; next_bincl = bincl_list = (struct header_file_location *) - (*objfile -> xmalloc) (bincls_allocated * sizeof(struct header_file_location)); + xmmalloc (objfile -> md, bincls_allocated * sizeof(struct header_file_location)); } /* Add a bincl to the list. */ @@ -669,7 +668,7 @@ add_bincl_to_list (pst, name, instance) int offset = next_bincl - bincl_list; bincls_allocated *= 2; bincl_list = (struct header_file_location *) - (*pst->objfile->xrealloc) ((char *)bincl_list, + xmrealloc (pst->objfile->md, (char *)bincl_list, bincls_allocated * sizeof (struct header_file_location)); next_bincl = bincl_list + offset; } @@ -703,7 +702,7 @@ static void free_bincl_list (objfile) struct objfile *objfile; { - (*objfile -> free) (bincl_list); + mfree (objfile -> md, bincl_list); bincls_allocated = 0; } @@ -975,7 +974,21 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset, && pst->n_static_syms == 0) { /* Throw away this psymtab, it's empty. We can't deallocate it, since it is on the obstack, but we can forget to chain it on the list. */ - ; + struct partial_symtab *prev_pst; + + /* First, snip it out of the psymtab chain */ + + if (pst->objfile->psymtabs == pst) + pst->objfile->psymtabs = pst->next; + else + for (prev_pst = pst->objfile->psymtabs; prev_pst; prev_pst = pst->next) + if (prev_pst->next == pst) + prev_pst->next = pst->next; + + /* Next, put it on a free list for recycling */ + + pst->next = pst->objfile->free_psymtabs; + pst->objfile->free_psymtabs = pst; } } @@ -1100,8 +1113,8 @@ dbx_psymtab_to_symtab (pst) #endif { #ifdef BROKEN_LARGE_ALLOCA - stringtab = (char *) (*pst->objfile->xmalloc) (stsize); - make_cleanup (pst->objfile->free, stringtab); + stringtab = (char *) xmalloc (stsize); + make_cleanup (free, stringtab); #else stringtab = (char *) alloca (stsize); #endif @@ -1567,7 +1580,7 @@ process_one_symbol (type, desc, valu, name, offset) { int i; struct symbol *sym = - (struct symbol *) (*our_objfile -> xmalloc) (sizeof (struct symbol)); + (struct symbol *) xmmalloc (our_objfile -> md, sizeof (struct symbol)); bzero (sym, sizeof *sym); SYMBOL_NAME (sym) = savestring (name, strlen (name)); SYMBOL_CLASS (sym) = LOC_BLOCK; @@ -107,39 +107,33 @@ cplus_demangle PARAMS ((const char *, int)); extern char * cplus_mangle_opname PARAMS ((char *, int)); -/* From mmap-*.c */ +/* From libmmalloc.a (memory mapped malloc library) */ extern PTR -mmap_malloc PARAMS ((long)); +mmalloc_attach PARAMS ((int, PTR)); extern PTR -mmap_realloc PARAMS ((PTR, long)); +mmalloc_detach PARAMS ((PTR)); extern PTR -mmap_xmalloc PARAMS ((long)); +mmalloc PARAMS ((PTR, long)); extern PTR -mmap_xrealloc PARAMS ((PTR, long)); +mrealloc PARAMS ((PTR, PTR, long)); extern void -mmap_free PARAMS ((PTR)); +mfree PARAMS ((PTR, PTR)); -extern PTR -mmap_sbrk PARAMS ((int)); - -extern PTR -mmap_base PARAMS ((void)); - -extern PTR -mmap_page_align PARAMS ((PTR)); +extern int +mmalloc_setkey PARAMS ((PTR, int, PTR)); extern PTR -mmap_remap PARAMS ((PTR, long, int, long)); +mmalloc_getkey PARAMS ((PTR, int)); /* From utils.c */ extern void -init_malloc PARAMS ((void)); +init_malloc PARAMS ((PTR)); extern void request_quit PARAMS ((int)); @@ -501,16 +495,43 @@ extern char * savestring PARAMS ((const char *, int)); extern char * +msavestring PARAMS ((void *, const char *, int)); + +extern char * strsave PARAMS ((const char *)); extern char * +mstrsave PARAMS ((void *, const char *)); + +extern char * concat PARAMS ((char *, ...)); extern PTR xmalloc PARAMS ((long)); extern PTR -xrealloc PARAMS ((char *, long)); +xrealloc PARAMS ((PTR, long)); + +extern PTR +xmmalloc PARAMS ((PTR, long)); + +extern PTR +xmrealloc PARAMS ((PTR, PTR, long)); + +extern PTR +mmalloc PARAMS ((PTR, long)); + +extern PTR +mrealloc PARAMS ((PTR, PTR, long)); + +extern void +mfree PARAMS ((PTR, PTR)); + +extern int +mmcheck PARAMS ((PTR, void (*) (void))); + +extern int +mmtrace PARAMS ((void)); extern int parse_escape PARAMS ((char **)); @@ -527,6 +548,9 @@ extern NORETURN void /* Not specified as volatile in ... */ exit PARAMS ((int)); /* 4.10.4.3 */ extern NORETURN void /* Does not return to the caller. */ +nomem PARAMS ((long)); + +extern NORETURN void /* Does not return to the caller. */ return_to_top_level PARAMS ((void)); extern void @@ -553,9 +577,10 @@ freeargv PARAMS ((char **)); /* For now, we can't include <stdlib.h> because it conflicts with "../include/getopt.h". (FIXME) - However, since any prototypes for any functions defined in the ANSI - specific, defined in any header files in an ANSI conforming environment, - must match those in the ANSI standard, we can just duplicate them here + However, if a function is defined in the ANSI C standard and a prototype + for that function is defined and visible in any header file in an ANSI + conforming environment, then that prototype must match the definition in + the ANSI standard. So we can just duplicate them here without conflict, since they must be the same in all conforming ANSI environments. If these cause problems, then the environment is not ANSI conformant. */ @@ -570,6 +595,7 @@ extern double atof PARAMS ((const char *nptr)); /* 4.10.1.1 */ #ifndef MALLOC_INCOMPATIBLE + extern PTR malloc PARAMS ((size_t size)); /* 4.10.3.3 */ @@ -577,8 +603,9 @@ extern PTR realloc PARAMS ((void *ptr, size_t size)); /* 4.10.3.4 */ extern void -free PARAMS ((void *)); /* 4.10.3.2 */ -#endif +free PARAMS ((void *)); /* 4.10.3.2 */ + +#endif /* MALLOC_INCOMPATIBLE */ extern void qsort PARAMS ((void *base, size_t nmemb, /* 4.10.5.2 */ @@ -172,8 +172,6 @@ mipsread.o : mipsread.c defs.h ${srcdir}/../include/ansidecl.h xm.h config.statu symfile.h buildsym.h ${srcdir}/../include/coff/mips.h \ ${srcdir}/../bfd/libaout.h ${srcdir}/../include/aout/aout64.h ${srcdir}/../include/aout/stab_gnu.h \ ${srcdir}/../include/aout/stab.def ${srcdir}/../include/coff/ecoff-ext.h partial-stab.h -mmap-alloc.o : mmap-alloc.c defs.h ${srcdir}/../include/ansidecl.h xm.h config.status tm.h config.status -mmap-sbrk.o : mmap-sbrk.c defs.h ${srcdir}/../include/ansidecl.h xm.h config.status tm.h config.status news-xdep.o : news-xdep.c Onindy.o : ${srcdir}/nindy-share/Onindy.c ${srcdir}/nindy-share/ttycntl.h \ ${srcdir}/nindy-share/block_io.h ${srcdir}/../include/wait.h ${srcdir}/nindy-share/env.h \ @@ -261,16 +259,13 @@ sparc-xdep.o : sparc-xdep.c defs.h ${srcdir}/../include/ansidecl.h xm.h config.s stack.o : stack.c defs.h ${srcdir}/../include/ansidecl.h xm.h config.status tm.h config.status value.h symtab.h \ ${srcdir}/../include/obstack.h gdbtypes.h expression.h language.h frame.h gdbcmd.h \ command.h gdbcore.h ${srcdir}/../include/bfd.h target.h breakpoint.h -state.o : state.c defs.h ${srcdir}/../include/ansidecl.h xm.h config.status tm.h config.status symtab.h \ - ${srcdir}/../include/obstack.h ${srcdir}/../include/bfd.h symfile.h state.h sun3-xdep.o : sun3-xdep.c defs.h ${srcdir}/../include/ansidecl.h xm.h config.status tm.h config.status \ inferior.h symtab.h ${srcdir}/../include/obstack.h breakpoint.h frame.h value.h \ gdbtypes.h expression.h gdbcore.h ${srcdir}/../include/bfd.h sun386-xdep.o : sun386-xdep.c symfile.o : symfile.c defs.h ${srcdir}/../include/ansidecl.h xm.h config.status tm.h config.status symtab.h \ ${srcdir}/../include/obstack.h gdbtypes.h gdbcore.h ${srcdir}/../include/bfd.h frame.h \ - target.h value.h expression.h symfile.h gdbcmd.h command.h breakpoint.h \ - state.h + target.h value.h expression.h symfile.h gdbcmd.h command.h breakpoint.h symm-tdep.o : symm-tdep.c defs.h ${srcdir}/../include/ansidecl.h xm.h config.status tm.h config.status frame.h \ inferior.h symtab.h ${srcdir}/../include/obstack.h breakpoint.h value.h gdbtypes.h \ expression.h gdbcore.h ${srcdir}/../include/bfd.h diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 20c9dab..c74d2db 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -98,11 +98,11 @@ typedef unsigned int DIEREF; /* Reference to a DIE */ extern CORE_ADDR startup_file_start; /* From blockframe.c */ extern CORE_ADDR startup_file_end; /* From blockframe.c */ extern CORE_ADDR entry_scope_lowpc; /* From blockframe.c */ -extern CORE_ADDR entry_scope_highpc; /* From blockframc.c */ +extern CORE_ADDR entry_scope_highpc; /* From blockframe.c */ extern CORE_ADDR main_scope_lowpc; /* From blockframe.c */ -extern CORE_ADDR main_scope_highpc; /* From blockframc.c */ +extern CORE_ADDR main_scope_highpc; /* From blockframe.c */ extern int info_verbose; /* From main.c; nonzero => verbose */ - +extern char *warning_pre_print; /* From utils.c */ /* The DWARF debugging information consists of two major pieces, one is a block of DWARF Information Entries (DIE's) and the other @@ -534,7 +534,7 @@ dwarfwarn (va_alist) va_start (ap); fmt = va_arg (ap, char *); warning_setup (); - fprintf (stderr, "DWARF warning (ref 0x%x): ", curdie -> dieref); + fprintf (stderr, "warning: DWARF ref 0x%x: ", curdie -> dieref); if (curdie -> at_name) { fprintf (stderr, "'%s': ", curdie -> at_name); @@ -1915,7 +1915,7 @@ psymtab_to_symtab_1 (pst) { if (pst->readin) { - warning ("Psymtab for %s already read in. Shouldn't happen.", + warning ("psymtab for %s already read in. Shouldn't happen.", pst -> filename); } else @@ -1983,7 +1983,7 @@ dwarf_psymtab_to_symtab (pst) { if (pst -> readin) { - warning ("Psymtab for %s already read in. Shouldn't happen.", + warning ("psymtab for %s already read in. Shouldn't happen.", pst -> filename); } else @@ -2046,11 +2046,11 @@ init_psymbol_list (objfile, total_symbols) if (objfile -> global_psymbols.list) { - (*objfile -> free) (objfile -> global_psymbols.list); + mfree (objfile -> md, objfile -> global_psymbols.list); } if (objfile -> static_psymbols.list) { - (*objfile -> free) (objfile -> static_psymbols.list); + mfree (objfile -> md, objfile -> static_psymbols.list); } /* Current best guess is that there are approximately a twentieth @@ -2061,11 +2061,11 @@ init_psymbol_list (objfile, total_symbols) objfile -> static_psymbols.size = total_symbols / 10; objfile -> global_psymbols.next = objfile -> global_psymbols.list = (struct partial_symbol *) - (*objfile -> xmalloc) (objfile -> global_psymbols.size + xmmalloc (objfile -> md, objfile -> global_psymbols.size * sizeof (struct partial_symbol)); objfile -> static_psymbols.next = objfile -> static_psymbols.list = (struct partial_symbol *) - (*objfile -> xmalloc) (objfile -> static_psymbols.size + xmmalloc (objfile -> md, objfile -> static_psymbols.size * sizeof (struct partial_symbol)); } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index aaf7d27..41f2978 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -810,141 +810,141 @@ lookup_fundamental_type (objfile, typeid) type = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, - "boolean", (struct objfile *) NULL); + "boolean", objfile); break; case FT_STRING: type = init_type (TYPE_CODE_PASCAL_ARRAY, TARGET_CHAR_BIT / TARGET_CHAR_BIT, 0, - "string", (struct objfile *) NULL); + "string", objfile); break; case FT_CHAR: type = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, 0, - "char", (struct objfile *) NULL); + "char", objfile); break; case FT_SIGNED_CHAR: type = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, TYPE_FLAG_SIGNED, - "signed char", (struct objfile *) NULL); + "signed char", objfile); break; case FT_UNSIGNED_CHAR: type = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, - "unsigned char", (struct objfile *) NULL); + "unsigned char", objfile); break; case FT_SHORT: type = init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, 0, - "short", (struct objfile *) NULL); + "short", objfile); break; case FT_SIGNED_SHORT: type = init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, TYPE_FLAG_SIGNED, - "signed short", (struct objfile *) NULL); + "signed short", objfile); break; case FT_UNSIGNED_SHORT: type = init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, - "unsigned short", (struct objfile *) NULL); + "unsigned short", objfile); break; case FT_INTEGER: type = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 0, - "int", (struct objfile *) NULL); + "int", objfile); break; case FT_SIGNED_INTEGER: type = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, TYPE_FLAG_SIGNED, - "signed int", (struct objfile *) NULL); + "signed int", objfile); break; case FT_UNSIGNED_INTEGER: type = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, - "unsigned int", (struct objfile *) NULL); + "unsigned int", objfile); break; case FT_LONG: type = init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, 0, - "long", (struct objfile *) NULL); + "long", objfile); break; case FT_SIGNED_LONG: type = init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, TYPE_FLAG_SIGNED, - "signed long", (struct objfile *) NULL); + "signed long", objfile); break; case FT_UNSIGNED_LONG: type = init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, - "unsigned long", (struct objfile *) NULL); + "unsigned long", objfile); break; case FT_LONG_LONG: type = init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, 0, - "long long", (struct objfile *) NULL); + "long long", objfile); break; case FT_SIGNED_LONG_LONG: type = init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, TYPE_FLAG_SIGNED, - "signed long long", (struct objfile *) NULL); + "signed long long", objfile); break; case FT_UNSIGNED_LONG_LONG: type = init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, "unsigned long long", - (struct objfile *) NULL); + objfile); break; case FT_FLOAT: type = init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT, 0, - "float", (struct objfile *) NULL); + "float", objfile); break; case FT_DBL_PREC_FLOAT: type = init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, 0, - "double", (struct objfile *) NULL); + "double", objfile); break; case FT_EXT_PREC_FLOAT: type = init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, 0, - "long double", (struct objfile *) NULL); + "long double", objfile); break; case FT_COMPLEX: type = init_type (TYPE_CODE_FLT, TARGET_COMPLEX_BIT / TARGET_CHAR_BIT, 0, - "complex", (struct objfile *) NULL); + "complex", objfile); break; case FT_DBL_PREC_COMPLEX: type = init_type (TYPE_CODE_FLT, TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT, 0, - "double complex", (struct objfile *) NULL); + "double complex", objfile); break; case FT_EXT_PREC_COMPLEX: type = init_type (TYPE_CODE_FLT, TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT, 0, "long double complex", - (struct objfile *) NULL); + objfile); break; } /* Install the newly created type in the objfile's fundamental_types diff --git a/gdb/i386-xdep.c b/gdb/i386-xdep.c index f0a412a..65bba6f 100644 --- a/gdb/i386-xdep.c +++ b/gdb/i386-xdep.c @@ -160,13 +160,13 @@ print_387_status (status, ep) printf (" %g\n", val); } if (ep->r0) - printf ("warning: reserved0 is %s\n", local_hex_string(ep->r0)); + warning ("reserved0 is %s\n", local_hex_string(ep->r0)); if (ep->r1) - printf ("warning: reserved1 is %s\n", local_hex_string(ep->r1)); + warning ("reserved1 is %s\n", local_hex_string(ep->r1)); if (ep->r2) - printf ("warning: reserved2 is %s\n", local_hex_string(ep->r2)); + warning ("reserved2 is %s\n", local_hex_string(ep->r2)); if (ep->r3) - printf ("warning: reserved3 is %s\n", local_hex_string(ep->r3)); + warning ("reserved3 is %s\n", local_hex_string(ep->r3)); } #ifndef U_FPSTATE diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index b930aaa..1d801fa 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -97,7 +97,7 @@ print_387_control_word (control) printf (";"); } printf ("\n"); - if (control & 0xe080) printf ("warning: reserved bits on: %s\n", + if (control & 0xe080) warning ("reserved bits on: %s\n", local_hex_string(control & 0xe080)); } diff --git a/gdb/infrun.c b/gdb/infrun.c index 07083f0..051682f 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -652,7 +652,7 @@ child_create_inferior (exec_file, allargs, env) correct program, and are poised at the first instruction of the new program. */ #ifdef SOLIB_CREATE_INFERIOR_HOOK - SOLIB_CREATE_INFERIOR_HOOK (); + SOLIB_CREATE_INFERIOR_HOOK (pid); #endif /* Should this perhaps just be a "proceed" call? FIXME */ @@ -1232,7 +1232,7 @@ wait_for_inferior () goto step_over_function; tmp = SKIP_TRAMPOLINE_CODE (stop_pc); - if (tmp != NULL) + if (tmp != 0) stop_func_start = tmp; if (find_pc_function (stop_func_start) != 0) @@ -1316,7 +1316,7 @@ step_into_function: step_range_end = sal.end; goto save_pc; } - abort(); /* We never fall through here */ + /* We never fall through here */ } if (trap_expected diff --git a/gdb/language.c b/gdb/language.c index d96b3b5..01ed270 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -85,6 +85,7 @@ set_type_range PARAMS ((void)); /* Forward declaration */ extern const struct language_defn unknown_language_defn; +extern char *warning_pre_print; /* The current (default at startup) state of type and range checking. (If the modes are set to "auto", though, these are changed based @@ -755,7 +756,7 @@ binop_type_check(arg1,arg2,op) if ((numeric_type(t1) && pointer_type(t2)) || (pointer_type(t1) && numeric_type(t2))) { - printf("warning: combining pointer and integer.\n"); + warning ("combining pointer and integer.\n"); break; } case BINOP_MUL: @@ -780,7 +781,7 @@ binop_type_check(arg1,arg2,op) else if ((pointer_type(t1) && integral_type(t2)) || (integral_type(t1) && pointer_type(t2))) { - printf("warning: combining integer and pointer.\n"); + warning ("combining integer and pointer.\n"); break; } else if (!simple_type(t1) || !simple_type(t2)) @@ -809,7 +810,7 @@ binop_type_check(arg1,arg2,op) type_op_error ("A pointer can only be assigned an integer.",op); else if (pointer_type(t1) && integral_type(t2)) { - printf("warning: combining integer and pointer."); + warning ("combining integer and pointer."); break; } else if (!simple_type(t1) || !simple_type(t2)) @@ -834,7 +835,7 @@ binop_type_check(arg1,arg2,op) case UNOP_IND: if (integral_type(t1)) { - printf("warning: combining pointer and integer.\n"); + warning ("combining pointer and integer.\n"); break; } else if (!pointer_type(t1)) @@ -906,9 +907,7 @@ op_error (fmt,op,fatal) error (fmt,op_string(op)); else { - printf("warning: "); - printf(fmt,op_string(op)); - printf("\n"); + warning (fmt,op_string(op)); } } @@ -917,7 +916,7 @@ op_error (fmt,op,fatal) the rest of the arguments should be its arguments. If [type|range]_check is [type|range]_check_on, then return_to_top_level() is called in the style of error (). Otherwise, the message is prefixed - by "warning: " and we do not return to the top level. */ + by the value of warning_pre_print and we do not return to the top level. */ void type_error (va_alist) @@ -927,7 +926,7 @@ type_error (va_alist) char *string; if (type_check==type_check_warn) - fprintf(stderr,"warning: "); + fprintf(stderr,warning_pre_print); else target_terminal_ours(); @@ -948,7 +947,7 @@ range_error (va_alist) char *string; if (range_check==range_check_warn) - fprintf(stderr,"warning: "); + fprintf(stderr,warning_pre_print); else target_terminal_ours(); diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index ab0cb9e..c68ca6b 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -40,6 +40,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "value.h" #include "parser-defs.h" +/* Ensure that if the generated parser contains any calls to malloc/realloc, + that they get mapped to xmalloc/xrealloc. */ + +#define malloc xmalloc +#define realloc xrealloc + /* These MUST be included in any grammar file!!!! Please choose unique names! */ #define yymaxdepth m2_maxdepth @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdio.h> #include "defs.h" #include "gdbcmd.h" #include "symtab.h" @@ -180,6 +179,10 @@ extern char *version; extern char *error_pre_print; +/* Message to be printed before the warning message, when a warning occurs. */ + +extern char *warning_pre_print; + extern char lang_frame_mismatch_warn[]; /* language.c */ /* Whether GDB's stdin is on a terminal. */ @@ -254,6 +257,9 @@ static char dirbuf[1024]; void (*window_hook) PARAMS ((FILE *, char *)); extern int frame_file_full_name; +extern int mapped_symbol_files; +extern int readnow_symbol_files; + int epoch_interface; int xgdb_verbose; @@ -323,7 +329,7 @@ catch_errors (func, args, errstring) saved_cleanup_chain = save_cleanups (); saved_error_pre_print = error_pre_print; - bcopy (to_top_level, saved, sizeof (jmp_buf)); + memcpy ((char *)saved, (char *)to_top_level, sizeof (jmp_buf)); error_pre_print = errstring; if (setjmp (to_top_level) == 0) @@ -334,7 +340,7 @@ catch_errors (func, args, errstring) restore_cleanups (saved_cleanup_chain); error_pre_print = saved_error_pre_print; - bcopy (saved, to_top_level, sizeof (jmp_buf)); + memcpy ((char *)to_top_level, (char *)saved, sizeof (jmp_buf)); return val; } @@ -345,7 +351,7 @@ disconnect (signo) int signo; { kill_inferior_fast (); - signal (SIGHUP, SIG_DFL); + signal (signo, SIG_DFL); kill (getpid (), SIGHUP); } @@ -407,7 +413,7 @@ main (argc, argv) register int i; /* This needs to happen before the first use of malloc. */ - init_malloc (); + init_malloc ((PTR) NULL); #if defined (ALIGN_STACK_ON_STARTUP) i = (int) &count & 0x3; @@ -457,6 +463,10 @@ main (argc, argv) with no equivalent). */ static struct option long_options[] = { + {"readnow", no_argument, &readnow_symbol_files, 1}, + {"r", no_argument, &readnow_symbol_files, 1}, + {"mapped", no_argument, &mapped_symbol_files, 1}, + {"m", no_argument, &mapped_symbol_files, 1}, {"quiet", no_argument, &quiet, 1}, {"q", no_argument, &quiet, 1}, {"nx", no_argument, &inhibit_gdbinit, 1}, @@ -636,6 +646,7 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); } error_pre_print = "\n\n"; + warning_pre_print = "\n\nwarning: "; /* Now perform all the actions indicated by the arguments. */ if (cdarg != NULL) @@ -683,6 +694,7 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); if (!quiet) printf_filtered ("\n"); error_pre_print = "\n"; + warning_pre_print = "\nwarning: "; /* Set the initial language. */ { @@ -721,6 +733,7 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); /* Error messages should no longer be distinguished with extra output. */ error_pre_print = 0; + warning_pre_print = "warning: "; { struct stat homebuf, cwdbuf; @@ -745,8 +758,8 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); zero in case one of them fails (this guarantees that they won't match if either exists). */ - bzero (&homebuf, sizeof (struct stat)); - bzero (&cwdbuf, sizeof (struct stat)); + memset (&homebuf, 0, sizeof (struct stat)); + memset (&cwdbuf, 0, sizeof (struct stat)); stat (homeinit, &homebuf); stat (gdbinit, &cwdbuf); /* We'll only need this if @@ -1585,6 +1598,20 @@ validate_comname (comname) } } +#ifdef IBM6000 + +lowercase (char *str) +{ + while (*str) { + + /* isupper(), tolower() are function calls in AIX. */ + if ( *str >= 'A' && *str <= 'Z') + *str = *str + 'a' - 'A'; + ++str; + } +} +#endif + static void define_command (comname, from_tty) char *comname; @@ -1596,6 +1623,14 @@ define_command (comname, from_tty) validate_comname (comname); +#ifdef IBM6000 + + /* If the rest of the commands will be case insensetive, this one + should behave in the same manner. */ + + lowercase (comname); +#endif + /* Look it up, and verify that we got an exact match. */ c = lookup_cmd (&tem, cmdlist, "", -1, 1); if (c && 0 != strcmp (comname, c->name)) @@ -2085,14 +2120,16 @@ initialize_history() { char *tmpenv; - if (tmpenv = getenv ("HISTSIZE")) + tmpenv = getenv ("HISTSIZE"); + if (tmpenv) history_size = atoi (tmpenv); else if (!history_size) history_size = 256; stifle_history (history_size); - if (tmpenv = getenv ("GDBHISTFILE")) + tmpenv = getenv ("GDBHISTFILE"); + if (tmpenv) history_filename = savestring (tmpenv, strlen(tmpenv)); else if (!history_filename) { /* We include the current directory so that if the user changes diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 9367204..1d7faaa 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -78,7 +78,7 @@ compact_minimal_symbols PARAMS ((struct minimal_symbol *, int)); /* Call the function specified by FUNC for each currently available minimal symbol, for as long as this function continues to return NULL. If the function ever returns non-NULL, then the iteration over the minimal - symbols is terminated,, the result is returned to the caller. + symbols is terminated and the result is returned to the caller. The function called has full control over the form and content of the information returned via the non-NULL result, which may be as simple as a diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 8937f24..eebb24a 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -26,70 +26,140 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "symtab.h" #include "symfile.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> #include <obstack.h> +/* Prototypes for local functions */ + +static int +open_mapped_file PARAMS ((char *basefile, long mtime, int mapped)); + +static CORE_ADDR +map_to_address PARAMS ((void)); + /* Externally visible variables that are owned by this module. */ struct objfile *object_files; /* Linked list of all objfiles */ +int mapped_symbol_files; /* Try to use mapped symbol files */ /* Allocate a new objfile struct, fill it in as best we can, and return it. It is also linked into the list of all known object files. */ struct objfile * -allocate_objfile (abfd, filename, dumpable) +allocate_objfile (abfd, filename, mapped) bfd *abfd; char *filename; - int dumpable; + int mapped; { - struct objfile *objfile; + struct objfile *objfile = NULL; + int fd; + void *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 (filename, bfd_get_mtime (abfd), mapped); + if (fd >= 0) + { + if (((mapto = map_to_address ()) == NULL) || + ((md = mmalloc_attach (fd, (void *) mapto)) == NULL)) + { + close (fd); + } + else if ((objfile = (struct objfile *) mmalloc_getkey (md, 0)) != NULL) + { + objfile -> md = md; + /* 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); + /* Update memory corruption handler function addresses */ + init_malloc (objfile -> md); + } + else + { + objfile = (struct objfile *) xmmalloc (md, sizeof (struct objfile)); + (void) memset (objfile, 0, sizeof (struct objfile)); + objfile -> md = md; + objfile -> flags |= OBJF_MAPPED; + mmalloc_setkey (objfile -> md, 0, objfile); + obstack_full_begin (&objfile -> psymbol_obstack, 0, 0, + xmmalloc, mfree, objfile -> md, + OBSTACK_MMALLOC_LIKE); + obstack_full_begin (&objfile -> symbol_obstack, 0, 0, + xmmalloc, mfree, objfile -> md, + OBSTACK_MMALLOC_LIKE); + obstack_full_begin (&objfile -> type_obstack, 0, 0, + xmmalloc, mfree, objfile -> md, + OBSTACK_MMALLOC_LIKE); + /* Set up to detect internal memory corruption */ + init_malloc (objfile -> md); + } + } + + if (mapped && (objfile == NULL)) + { + warning ("symbol table for '%s' will not be mapped", filename); + } - /* First, if the objfile is to be dumpable, we must malloc the structure - itself using the mmap version, and arrange that all memory allocation - for the objfile uses the mmap routines. Otherwise, just use the - old sbrk'd malloc routines. */ +#else /* defined(NO_MMALLOC) || !defined(HAVE_MMAP) */ - if (dumpable) + if (mapped) { - objfile = (struct objfile *) mmap_xmalloc (sizeof (struct objfile)); - (void) memset (objfile, 0, sizeof (struct objfile)); - objfile -> malloc = mmap_malloc; - objfile -> realloc = mmap_realloc; - objfile -> xmalloc = mmap_xmalloc; - objfile -> xrealloc = mmap_xrealloc; - objfile -> free = mmap_free; - objfile -> flags |= OBJF_DUMPABLE; + warning ("this version of gdb does not support mapped symbol tables."); + + /* Turn off the global flag so we don't try to do mapped symbol tables + any more, which shuts up gdb unless the user specifically gives the + "mapped" keyword again. */ + + mapped_symbol_files = 0; } - else + +#endif /* !defined(NO_MMALLOC) && defined(HAVE_MMAP) */ + + /* If we don't support mapped symbol files, didn't ask for the file to be + mapped, or failed to open the mapped file for some reason, then revert + back to an unmapped objfile. */ + + if (objfile == NULL) { objfile = (struct objfile *) xmalloc (sizeof (struct objfile)); (void) memset (objfile, 0, sizeof (struct objfile)); - objfile -> malloc = (PTR (*) PARAMS ((long))) malloc; - objfile -> realloc = (PTR (*) PARAMS ((PTR, long))) realloc; - objfile -> xmalloc = xmalloc; - objfile -> xrealloc = xrealloc; - objfile -> free = free; + objfile -> md = NULL; + obstack_full_begin (&objfile -> psymbol_obstack, 0, 0, xmalloc, free, + (void *) 0, 0); + obstack_full_begin (&objfile -> symbol_obstack, 0, 0, xmalloc, free, + (void *) 0, 0); + obstack_full_begin (&objfile -> type_obstack, 0, 0, xmalloc, free, + (void *) 0, 0); + } - /* Now, malloc a fresh copy of the filename string using the malloc - specified as appropriate for the objfile. */ + /* Now, malloc a fresh copy of the filename string. */ - objfile -> name = (*objfile -> xmalloc) (strlen (filename) + 1); + objfile -> name = xmmalloc (objfile -> md, strlen (filename) + 1); strcpy (objfile -> name, filename); objfile -> obfd = abfd; objfile -> mtime = bfd_get_mtime (abfd); - /* Set up the various obstacks to use the memory allocation/free - functions that are appropriate for this objfile. */ - - obstack_full_begin (&objfile -> psymbol_obstack, 0, 0, - objfile -> xmalloc, objfile -> free); - obstack_full_begin (&objfile -> symbol_obstack, 0, 0, - objfile -> xmalloc, objfile -> free); - obstack_full_begin (&objfile -> type_obstack, 0, 0, - objfile -> xmalloc, objfile -> free); - /* Push this file onto the head of the linked list of other such files. */ objfile -> next = object_files; @@ -111,7 +181,7 @@ free_objfile (objfile) if (objfile -> name) { - (*objfile -> free) (objfile -> name); + mfree (objfile -> md, objfile -> name); } if (objfile -> obfd) { @@ -156,10 +226,9 @@ free_objfile (objfile) #endif - /* The last thing we do is free the objfile struct itself, using the - free() that is appropriate for the objfile. */ + /* The last thing we do is free the objfile struct itself */ - (*objfile -> free) (objfile); + mfree (objfile -> md, objfile); } @@ -337,3 +406,118 @@ iterate_over_psymtabs (func, arg1, arg2, arg3) } return (result); } + + +/* Look for a mapped symbol file that corresponds to BASEFILE and is more + recent than MTIME. If MAPPED is nonzero, the user has asked that gdb + use a mapped symbol file for this base file, so create a new one if + one does not currently exist. + + If found, then return an open file descriptor for the file, otherwise + return -1. + + This routine is responsible for implementing the policy that generates + the name of the mapped symbol file from the name of a file containing + symbols that gdb would like to read. */ + +static int +open_mapped_file (basefile, mtime, mapped) + char *basefile; + long mtime; + int mapped; +{ + int fd; + char *symfilename; + struct stat sbuf; + + /* For now, all we do is look in the local directory for a file with + the name of the base file and an extension of ".syms" */ + + symfilename = concat ("./", basename (basefile), ".syms", (char *) NULL); + + /* Check to see if the desired file already exists and is more recent than + the corresponding base file (specified by the passed MTIME parameter). + The open will fail if the file does not already exist. */ + + if ((fd = open (symfilename, O_RDWR)) >= 0) + { + if (fstat (fd, &sbuf) != 0) + { + close (fd); + perror_with_name (symfilename); + } + else if (sbuf.st_mtime > mtime) + { + return (fd); + } + else + { + close (fd); + fd = -1; + } + } + + /* Either the file does not already exist, or the base file has changed + since it was created. In either case, if the user has specified use of + a mapped file, then create a new mapped file, truncating any existing + one. + + In the case where there is an existing file, but it is out of date, and + the user did not specify mapped, the existing file is just silently + ignored. Perhaps we should warn about this case (FIXME?). + + By default the file is rw for everyone, with the user's umask taking + care of turning off the permissions the user wants off. */ + + if (mapped) + { + fd = open (symfilename, O_RDWR | O_CREAT | O_TRUNC, 0666); + } + + return (fd); +} + +/* Return the base address at which we would like the next objfile's + mapped data to start. + + For now, we use the kludge that the configuration specifies a base + address to which it is safe to map the first mmalloc heap, and an + increment to add to this address for each successive heap. There are + a lot of issues to deal with here to make this work reasonably, including: + + Avoid memory collisions with existing mapped address spaces + + Reclaim address spaces when their mmalloc heaps are unmapped + + When mmalloc heaps are shared between processes they have to be + mapped at the same addresses in each + + Once created, a mmalloc heap that is to be mapped back in must be + mapped at the original address. I.E. each objfile will expect to + be remapped at it's original address. This becomes a problem if + the desired address is already in use. + + etc, etc, etc. + + */ + + +static CORE_ADDR +map_to_address () +{ + +#if defined(MMAP_BASE_ADDRESS) && defined (MMAP_INCREMENT) + + static CORE_ADDR next = MMAP_BASE_ADDRESS; + CORE_ADDR mapto = next; + + next += MMAP_INCREMENT; + return (mapto); + +#else + + return (0); + +#endif + +} diff --git a/gdb/source.c b/gdb/source.c index 369788f..f4ab71a 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -17,10 +17,9 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdio.h> #include "defs.h" #include "symtab.h" -#include "param.h" +#include "expression.h" #include "language.h" #include "command.h" #include "gdbcmd.h" @@ -36,14 +35,45 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <fcntl.h> #include "gdbcore.h" #include "regex.h" +#include "symfile.h" + +/* Prototypes for local functions. */ + +static int +open_source_file PARAMS ((struct symtab *)); + +static int +get_filename_and_charpos PARAMS ((struct symtab *, char **)); + +static void +reverse_search_command PARAMS ((char *, int)); + +static void +forward_search_command PARAMS ((char *, int)); + +static void +line_info PARAMS ((char *, int)); + +static void +list_command PARAMS ((char *, int)); + +static void +ambiguous_line_spec PARAMS ((struct symtabs_and_lines *)); + +static void +source_info PARAMS ((void)); + +static void +show_directories PARAMS ((void)); + +static void +find_source_lines PARAMS ((struct symtab *, int)); /* If we use this declaration, it breaks because of fucking ANSI "const" stuff on some systems. We just have to not declare it at all, have it default to int, and possibly botch on a few systems. Thanks, ANSIholes... */ /* extern char *strstr(); */ -extern void set_next_address (); - /* Path of directories to search for source files. Same format as the PATH environment variable's value. */ @@ -63,7 +93,7 @@ int current_source_line; and friends should be rewritten to count characters and see where things are wrapping, but that would be a fair amount of work. */ -unsigned lines_to_list = 10; +int lines_to_list = 10; /* Line number of last line printed. Default for various commands. current_source_line is usually, but not always, the same as this. */ @@ -79,8 +109,8 @@ static int first_line_listed; symtab. Sigh. Behavior specification: If it is called with a non-zero argument, that is the symtab to select. If it is not, first lookup "main"; if it exists, use the symtab and line it - defines. If not, take the last symtab in the symtab_list (if it - exists) or the last symtab in the psymtab_list (if *it* exists). If + defines. If not, take the last symtab in the symtab lists (if it + exists) or the last symtab in the psymtab lists (if *it* exists). If none of this works, report an error. */ void @@ -91,6 +121,7 @@ select_source_symtab (s) struct symtab_and_line sal; struct partial_symtab *ps; struct partial_symtab *cs_pst = 0; + struct objfile *ofp; if (s) { @@ -116,35 +147,47 @@ select_source_symtab (s) current_source_line = 1; - for (s = symtab_list; s; s = s->next) + for (ofp = object_files; ofp != NULL; ofp = ofp -> next) { - char *name = s->filename; - int len = strlen (name); - if (! (len > 2 && !strcmp (&name[len - 2], ".h"))) - current_source_symtab = s; + for (s = ofp -> symtabs; s; s = s->next) + { + char *name = s -> filename; + int len = strlen (name); + if (! (len > 2 && (strcmp (&name[len - 2], ".h") == 0))) + { + current_source_symtab = s; + } + } } if (current_source_symtab) return; - /* Howabout the partial symtab list? */ + /* Howabout the partial symbol tables? */ - if (partial_symtab_list) + for (ofp = object_files; ofp != NULL; ofp = ofp -> next) { - ps = partial_symtab_list; - while (ps) + for (ps = ofp -> psymtabs; ps != NULL; ps = ps -> next) { - char *name = ps->filename; + char *name = ps -> filename; int len = strlen (name); - if (! (len > 2 && !strcmp (&name[len - 2], ".h"))) - cs_pst = ps; - ps = ps->next; + if (! (len > 2 && (strcmp (&name[len - 2], ".h") == 0))) + { + cs_pst = ps; + } } - if (cs_pst) - if (cs_pst->readin) + } + if (cs_pst) + { + if (cs_pst -> readin) + { fatal ("Internal: select_source_symtab: readin pst found and no symtabs."); - else + } + else + { current_source_symtab = PSYMTAB_TO_SYMTAB (cs_pst); + } } + if (current_source_symtab) return; @@ -166,18 +209,22 @@ void forget_cached_source_info () { register struct symtab *s; + register struct objfile *objfile; - for (s = symtab_list; s; s = s->next) + for (objfile = object_files; objfile != NULL; objfile = objfile -> next) { - if (s->line_charpos != 0) - { - free (s->line_charpos); - s->line_charpos = 0; - } - if (s->fullname != 0) + for (s = objfile -> symtabs; s != NULL; s = s -> next) { - free (s->fullname); - s->fullname = 0; + if (s -> line_charpos != NULL) + { + mfree (objfile -> md, s -> line_charpos); + s -> line_charpos = NULL; + } + if (s -> fullname != NULL) + { + mfree (objfile -> md, s -> fullname); + s -> fullname = NULL; + } } } } @@ -231,15 +278,14 @@ mod_path (dirname, which_path) do { - extern char *index (); char *name = dirname; register char *p; struct stat st; { - char *colon = index (name, ':'); - char *space = index (name, ' '); - char *tab = index (name, '\t'); + char *colon = strchr (name, ':'); + char *space = strchr (name, ' '); + char *tab = strchr (name, '\t'); if (colon == 0 && space == 0 && tab == 0) p = dirname = name + strlen (name); else @@ -293,7 +339,7 @@ mod_path (dirname, which_path) if (name[0] == '~') name = tilde_expand (name); else if (name[0] != '/' && name[0] != '$') - name = concat (current_directory, "/", name); + name = concat (current_directory, "/", name, NULL); else name = savestring (name, p - name); make_cleanup (free, name); @@ -323,7 +369,7 @@ mod_path (dirname, which_path) goto skip_dup; /* Same dir twice in one cmd */ strcpy (p, &p[len+1]); /* Copy from next \0 or : */ } - p = index (p, ':'); + p = strchr (p, ':'); if (p != 0) ++p; else @@ -338,15 +384,15 @@ mod_path (dirname, which_path) c = old[prefix]; old[prefix] = '\0'; - temp = concat (old, ":", name); + temp = concat (old, ":", name, NULL); old[prefix] = c; - *which_path = concat (temp, "", &old[prefix]); + *which_path = concat (temp, "", &old[prefix], NULL); prefix = strlen (temp); free (temp); } else { - *which_path = concat (name, (old[0]? ":" : old), old); + *which_path = concat (name, (old[0]? ":" : old), old, NULL); prefix = strlen (name); } free (old); @@ -431,7 +477,7 @@ openp (path, try_cwd_first, string, mode, prot, filename_opened) fd = -1; for (p = path; p; p = p1 ? p1 + 1 : 0) { - p1 = (char *) index (p, ':'); + p1 = (char *) strchr (p, ':'); if (p1) len = p1 - p; else @@ -478,7 +524,7 @@ openp (path, try_cwd_first, string, mode, prot, filename_opened) *filename_opened = concat (current_directory, '/' == current_directory[strlen(current_directory)-1]? "": "/", - filename); + filename, NULL); } return fd; @@ -486,13 +532,15 @@ openp (path, try_cwd_first, string, mode, prot, filename_opened) /* Open a source file given a symtab S. Returns a file descriptor or negative number for error. */ -int + +static int open_source_file (s) struct symtab *s; { char *path = source_path; char *p; int result; + char *fullname; /* Quick way out if we already know its full name */ if (s->fullname) @@ -501,7 +549,7 @@ open_source_file (s) if (result >= 0) return result; /* Didn't work -- free old one, try again. */ - free (s->fullname); + mfree (s->objfile->md, s->fullname); s->fullname = NULL; } @@ -525,7 +573,21 @@ open_source_file (s) } } - return openp (path, 0, s->filename, O_RDONLY, 0, &s->fullname); + result = openp (path, 0, s->filename, O_RDONLY, 0, &s->fullname); + if (result < 0) + { + /* Didn't work. Try using just the basename. */ + p = basename (s->filename); + if (p != s->filename) + result = openp(path, 0, p, O_RDONLY,0, &s->fullname); + } + if (result >= 0) + { + fullname = s -> fullname; + s -> fullname = mstrsave (s -> objfile -> md, s -> fullname); + free (fullname); + } + return result; } @@ -543,12 +605,19 @@ find_source_lines (s, desc) register char *data, *p, *end; int nlines = 0; int lines_allocated = 1000; - int *line_charpos = (int *) xmalloc (lines_allocated * sizeof (int)); + int *line_charpos; + long exec_mtime; + line_charpos = (int *) xmmalloc (s -> objfile -> md, + lines_allocated * sizeof (int)); if (fstat (desc, &st) < 0) perror_with_name (s->filename); - if (exec_bfd && bfd_get_mtime(exec_bfd) < st.st_mtime) - printf ("Source file is more recent than executable.\n"); + + if (exec_bfd) { + exec_mtime = bfd_get_mtime(exec_bfd); + if (exec_mtime && exec_mtime < st.st_mtime) + printf ("Source file is more recent than executable.\n"); + } #ifdef BROKEN_LARGE_ALLOCA data = (char *) xmalloc (st.st_size); @@ -571,19 +640,24 @@ find_source_lines (s, desc) if (nlines == lines_allocated) { lines_allocated *= 2; - line_charpos = (int *) xrealloc (line_charpos, - sizeof (int) * lines_allocated); + line_charpos = + (int *) xmrealloc (s -> objfile -> md, (char *) line_charpos, + sizeof (int) * lines_allocated); } line_charpos[nlines++] = p - data; } } s->nlines = nlines; - s->line_charpos = (int *) xrealloc (line_charpos, nlines * sizeof (int)); + s->line_charpos = + (int *) xmrealloc (s -> objfile -> md, (char *) line_charpos, + nlines * sizeof (int)); } /* Return the character position of a line LINE in symtab S. Return 0 if anything is invalid. */ +#if 0 /* Currently unused */ + int source_line_charpos (s, line) struct symtab *s; @@ -618,13 +692,16 @@ source_charpos_line (s, chr) line = s->nlines; return line; } + +#endif /* 0 */ + /* Get full pathname and line number positions for a symtab. Return nonzero if line numbers may have changed. Set *FULLNAME to actual name of the file as found by `openp', or to 0 if the file is not found. */ -int +static int get_filename_and_charpos (s, fullname) struct symtab *s; char **fullname; @@ -781,7 +858,7 @@ list_command (arg, from_tty) int linenum_beg = 0; char *p; - if (symtab_list == 0 && partial_symtab_list == 0) + if (!have_full_symbols () && !have_partial_symbols()) error ("No symbol table is loaded. Use the \"file\" command."); /* Pull in a current source symtab if necessary */ @@ -889,11 +966,11 @@ list_command (arg, from_tty) error ("No source file for address %s.", local_hex_string(sal.pc)); sym = find_pc_function (sal.pc); if (sym) - printf ("%s is in %s (%s, line %d).\n", + printf ("%s is in %s (%s:%d).\n", local_hex_string(sal.pc), SYMBOL_NAME (sym), sal.symtab->filename, sal.line); else - printf ("%s is in %s, line %d.\n", + printf ("%s is at %s:%d.\n", local_hex_string(sal.pc), sal.symtab->filename, sal.line); } @@ -978,11 +1055,13 @@ line_info (arg, from_tty) printf ("Line %d of \"%s\" is at pc %s but contains no code.\n", sal.line, sal.symtab->filename, local_hex_string(start_pc)); else - printf ("Line %d of \"%s\" starts at pc %s", - sal.line, sal.symtab->filename, - local_hex_string(start_pc)); - printf (" and ends at %s.\n", - local_hex_string(end_pc)); + { + printf ("Line %d of \"%s\" starts at pc %s", + sal.line, sal.symtab->filename, + local_hex_string(start_pc)); + printf (" and ends at %s.\n", + local_hex_string(end_pc)); + } /* x/i should display this line's code. */ set_next_address (start_pc); /* Repeating "info line" should do the following line. */ diff --git a/gdb/symfile.c b/gdb/symfile.c index 7629fd8..93815b5 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdio.h> #include "defs.h" #include "symtab.h" #include "gdbtypes.h" @@ -29,7 +28,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "symfile.h" #include "gdbcmd.h" #include "breakpoint.h" -#include "state.h" #include <obstack.h> #include <assert.h> @@ -43,6 +41,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ CORE_ADDR entry_point; /* Where execution starts in symfile */ struct sym_fns *symtab_fns = NULL; /* List of all available sym_fns. */ +int readnow_symbol_files; /* Read full symbols immediately */ /* External variables and functions referenced. */ @@ -59,9 +58,6 @@ load_command PARAMS ((char *, int)); static void add_symbol_file_command PARAMS ((char *, int)); -static struct objfile * -symbol_file_add_digested PARAMS ((sfd *, int)); - static void cashier_psymtab PARAMS ((struct partial_symtab *)); @@ -428,48 +424,10 @@ syms_from_objfile (objfile, addr, mainline, verbo) /* We're done reading the symbol file; finish off complaints. */ clear_complaints(0, verbo); - /* Setup the breakpoint(s) for trapping longjmp(), as it may have been - defined by this new file. */ - create_longjmp_breakpoint(); -} - -/* Reload a predigested symbol file from a dumped state file. - - FIXME: For now, we load only the first dumped objfile that we - find, for two reasons. (1) Our custom malloc and mmap'd sbrk - implementation only supports one mmap'd objfile at a time, so we - can only create state files with one dumped objfile in them and - would have no way to deal with multiple dumped objfiles when reading - the state file back in even if we could create them. (2) We currently - have no way to select a specific objfile to load from a state file - containing a dump of more than one objfile, so we just select the - first one we encounter. */ - -static struct objfile * -symbol_file_add_digested (asfd, from_tty) - sfd *asfd; - int from_tty; -{ - struct objfile *objfile; - bfd *sym_bfd; - - /* First locate and map in the dumped symbol information */ - - objfile = objfile_from_statefile (asfd); - - /* Push this file onto the head of the linked list of other such files. */ - - objfile -> next = object_files; - object_files = objfile; - -#if 0 /* FIXME: Things to deal with... */ - objfile -> obfd = abfd; - objfile -> mtime = bfd_get_mtime (abfd); - obstack_full_begin (&objfile -> psymbol_obstack, 0, 0, xmalloc, free); - obstack_full_begin (&objfile -> symbol_obstack, 0, 0, xmalloc, free); - obstack_full_begin (&objfile -> type_obstack, 0, 0, xmalloc, free); -#endif + /* Fixup all the breakpoints that may have been redefined by this + symbol file. */ + breakpoint_re_set (); } /* Process a symbol file, as either the main file or as a dynamically @@ -486,17 +444,17 @@ symbol_file_add_digested (asfd, from_tty) Upon failure, jumps back to command level (never returns). */ struct objfile * -symbol_file_add (name, from_tty, addr, mainline, dumpable) +symbol_file_add (name, from_tty, addr, mainline, mapped) char *name; int from_tty; CORE_ADDR addr; int mainline; - int dumpable; + int mapped; { struct objfile *objfile; bfd *sym_bfd; - objfile = symfile_open (name, dumpable); + objfile = symfile_open (name, mapped); sym_bfd = objfile->obfd; /* There is a distinction between having no symbol table @@ -510,25 +468,39 @@ symbol_file_add (name, from_tty, addr, mainline, dumpable) error ("%s has no symbol-table", name); } - if ((have_full_symbols () || have_partial_symbols ()) - && mainline - && from_tty - && !query ("Load new symbol table from \"%s\"? ", name)) - error ("Not confirmed."); + /* If the objfile uses a mapped symbol file, and we have a psymtab for + it, then skip reading any symbols at this time. */ - if (from_tty || info_verbose) + if ((objfile -> psymtabs != NULL) && (objfile -> flags & OBJF_MAPPED)) { - printf_filtered ("Reading symbols from %s...", name); - wrap_here (""); - fflush (stdout); + if (from_tty || info_verbose) + { + printf_filtered ("Mapped symbols for %s.\n", name); + fflush (stdout); + } } - - syms_from_objfile (objfile, addr, mainline, from_tty); - - if (from_tty || info_verbose) + else { - printf_filtered ("done.\n"); - fflush (stdout); + if ((have_full_symbols () || have_partial_symbols ()) + && mainline + && from_tty + && !query ("Load new symbol table from \"%s\"? ", name)) + error ("Not confirmed."); + + if (from_tty || info_verbose) + { + printf_filtered ("Reading symbols from %s...", name); + wrap_here (""); + fflush (stdout); + } + + syms_from_objfile (objfile, addr, mainline, from_tty); + + if (from_tty || info_verbose) + { + printf_filtered ("done.\n"); + fflush (stdout); + } } return (objfile); } @@ -546,8 +518,7 @@ symbol_file_command (args, from_tty) struct cleanup *cleanups; struct objfile *objfile; struct partial_symtab *psymtab; - sfd *sym_sfd; - int dumpable = 0; + int mapped = 0; int readnow = 0; dont_repeat (); @@ -575,16 +546,16 @@ symbol_file_command (args, from_tty) { if ((argv = buildargv (args)) == NULL) { - fatal ("virtual memory exhausted.", 0); + nomem (0); } cleanups = make_cleanup (freeargv, (char *) argv); name = *argv; while (*++argv != NULL) { - if (!strcmp (*argv, "dumpable")) + if (!strcmp (*argv, "mapped")) { - dumpable = 1; + mapped = 1; } else if (!strcmp (*argv, "readnow")) { @@ -594,25 +565,19 @@ symbol_file_command (args, from_tty) if (name != NULL) { - if ((sym_sfd = sfd_fopen (name, "r")) != NULL) + /* Getting new symbols may change our opinion about what is + frameless. */ + reinit_frame_cache (); + objfile = symbol_file_add (name, from_tty, (CORE_ADDR)0, 1, + mapped); + readnow |= readnow_symbol_files; + if (readnow) { - (void) symbol_file_add_digested (sym_sfd, from_tty); - } - else - { - /* Getting new symbols may change our opinion about what is - frameless. */ - reinit_frame_cache (); - objfile = symbol_file_add (name, from_tty, (CORE_ADDR)0, 1, - dumpable); - if (readnow) + for (psymtab = objfile -> psymtabs; + psymtab != NULL; + psymtab = psymtab -> next) { - for (psymtab = objfile -> psymtabs; - psymtab != NULL; - psymtab = psymtab -> next) - { - (void) psymtab_to_symtab (psymtab); - } + (void) psymtab_to_symtab (psymtab); } } } @@ -626,9 +591,9 @@ symbol_file_command (args, from_tty) In case of trouble, error() is called. */ static struct objfile * -symfile_open (name, dumpable) +symfile_open (name, mapped) char *name; - int dumpable; + int mapped; { bfd *sym_bfd; int desc; @@ -662,7 +627,7 @@ symfile_open (name, dumpable) name, bfd_errmsg (bfd_error)); } - objfile = allocate_objfile (sym_bfd, name, dumpable); + objfile = allocate_objfile (sym_bfd, name, mapped); return objfile; } @@ -778,6 +743,14 @@ reread_symbols () the_big_top: for (objfile = object_files; objfile; objfile = objfile->next) { if (objfile->obfd) { +#ifdef IBM6000 + /* If this object is from a shared library, then you should + stat on the library name, not member name. */ + + if (objfile->obfd->my_archive) + res = stat (objfile->obfd->my_archive->filename, &new_statbuf); + else +#endif res = stat (objfile->name, &new_statbuf); if (res != 0) { /* FIXME, should use print_sys_errmsg but it's not filtered. */ diff --git a/gdb/symfile.h b/gdb/symfile.h index 67226b9..c0fdf4f 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -1,5 +1,5 @@ /* Definitions for reading symbol files into GDB. - Copyright (C) 1990, 1991 Free Software Foundation, Inc. + Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc. This file is part of GDB. @@ -17,52 +17,133 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#if !defined (SYMFILE_H) +#define SYMFILE_H + /* This file requires that you first include "bfd.h". */ +struct psymbol_allocation_list { + struct partial_symbol *list; + struct partial_symbol *next; + int size; +}; + +/* Master structure for keeping track of each input file from which + gdb reads symbols. One of these is allocated for each such file we + access, e.g. the exec_file, symbol_file, and any shared library object + files. */ -/* Structure for keeping track of object files. +struct objfile +{ - One of these is allocated for each object file we access, e.g. the - exec_file, symbol_file, and any shared library object files. */ + /* All struct objfile's are chained together by their next pointers. + The global variable "object_files" points to the first link in this + chain. */ -struct objfile { - /* All struct objfile's are chained together by their next pointers. */ struct objfile *next; - /* Each objfile points to a chain of struct symtabs derived from this - object file. They are chained by their objfile_chain pointers, and - each one points back to this struct objfile. */ + /* The object file's name. Malloc'd; free it if you free this struct. */ + + char *name; + + /* Some flag bits for this objfile. */ + + unsigned short flags; + + /* Each objfile points to a linked list of symtabs derived from this file, + one symtab structure for each compilation unit (source file). Each link + in the symtab list contains a backpointer to this objfile. */ + struct symtab *symtabs; - /* Ditto for psymtabs. */ + /* Each objfile points to a linked list of partial symtabs derived from + this file, one partial symtab structure for each compilation unit + (source file). */ + struct partial_symtab *psymtabs; - /* The object file's name. Malloc'd; free it if you free this struct. */ - char *name; + /* List of freed partial symtabs, available for re-use */ + + struct partial_symtab *free_psymtabs; /* The object file's BFD. Can be null, in which case bfd_open (name) and put the result here. */ + bfd *obfd; /* The modification timestamp of the object file, as of the last time we read its symbols. */ + long mtime; + + /* Obstacks to hold objects that should be freed when we load a new symbol + table from this object file. */ + + struct obstack psymbol_obstack; /* Partial symbols */ + struct obstack symbol_obstack; /* Full symbols */ + struct obstack type_obstack; /* Types */ + + /* Vectors of all partial symbols read in from file. The actual data + is stored in the psymbol_obstack. */ + + struct psymbol_allocation_list global_psymbols; + struct psymbol_allocation_list static_psymbols; + + /* Each file contains a pointer to an array of minimal symbols for all + global symbols that are defined within the file. The array is terminated + by a "null symbol", one that has a NULL pointer for the name and a zero + value for the address. This makes it easy to walk through the array + when passed a pointer to somewhere in the middle of it. There is also + a count of the number of symbols, which does include the terminating + null symbol. The array itself, as well as all the data that it points + to, should be allocated on the symbol_obstack for this file. */ + + struct minimal_symbol *msymbols; + int minimal_symbol_count; + + /* For object file formats which don't specify fundamental types, gdb + can create such types. For now, it maintains a vector of pointers + to these internally created fundamental types on a per objfile basis, + however it really should ultimately keep them on a per-compilation-unit + basis, to account for linkage-units that consist of a number of + compilation units that may have different fundamental types, such as + linking C modules with ADA modules, or linking C modules that are + compiled with 32-bit ints with C modules that are compiled with 64-bit + ints (not inherently evil with a smarter linker). */ + + struct type **fundamental_types; + + /* The mmalloc() malloc-descriptor for this objfile if we are using + the memory mapped malloc() package to manage storage for this objfile's + data. NULL if we are not. */ + + void *md; + }; +/* Defines for the objfile flag word. */ + +/* Gdb can arrange to allocate storage for all objects related to a + particular objfile in a designated section of it's address space, + managed at a low level by mmap() and using a special version of + malloc that handles malloc/free/realloc on top of the mmap() interface. + This allows the "internal gdb state" for a particular objfile to be + dumped to a gdb state file and subsequently reloaded at a later time. */ + +#define OBJF_MAPPED (1 << 0) /* Objfile data is mmap'd */ + /* Structure to keep track of symbol reading functions for various object file types. */ struct sym_fns { - /* sym_name - is the name, or name prefix, of the BFD "target type" that this + /* is the name, or name prefix, of the BFD "target type" that this set of functions handles. E.g. "a.out" or "sunOs" or "coff" or "elf". */ char *sym_name; - /* sym_namelen - counts how many bytes of sym_name should be checked against the + /* counts how many bytes of sym_name should be checked against the BFD target type of the file being read. If an exact match is desired, specify the number of characters in sym_name plus 1 for the NUL. If a prefix match is desired, specify the number of characters in @@ -70,19 +151,18 @@ struct sym_fns { int sym_namelen; - /* sym_new_init - initializes anything that is global to the entire + /* initializes anything that is global to the entire symbol table. It is called during symbol_file_add, when we begin debugging an entirely new program. */ - void (*sym_new_init) (); + void (*sym_new_init) PARAMS ((void)); /* sym_init (sf) reads any initial information from a symbol file, and initializes the struct sym_fns SF in preparation for sym_read(). It is called every time we read a symbol file for any reason. */ - void (*sym_init) (); + void (*sym_init) PARAMS ((struct sym_fns *)); /* sym_read (sf, addr, mainline) reads a symbol file into a psymtab (or possibly a symtab). @@ -93,86 +173,133 @@ struct sym_fns { symbol file (e.g. shared library or dynamically loaded file) is being read. */ - void (*sym_read) (); + void (*sym_read) PARAMS ((struct sym_fns *, CORE_ADDR, int)); - /* sym_bfd - is the accessor for the symbol file being read. */ + /* is the accessor for the symbol file being read. */ - bfd *sym_bfd; + bfd *sym_bfd; - /* sym_private - is where information can be shared among sym_init and sym_read. + /* is where information can be shared among sym_init and sym_read. It is typically a pointer to malloc'd memory. */ char *sym_private; /* Should be void * */ - /* next - finds the next struct sym_fns. They are allocated and initialized + /* is the "struct objfile" for the object file being read. */ + + struct objfile *objfile; + + /* finds the next struct sym_fns. They are allocated and initialized in whatever module implements the functions pointed to; an initializer calls add_symtab_fns to add them to the global chain. */ + struct sym_fns *next; - /* objfile - is the "struct objfile" for the object file being read. */ - struct objfile *objfile; }; -extern void extend_psymbol_list(); +extern void +extend_psymbol_list PARAMS ((struct psymbol_allocation_list *, + struct objfile *)); /* Add any kind of symbol to a psymbol_allocation_list. */ -#define ADD_PSYMBOL_VT_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE, VT)\ +#define ADD_PSYMBOL_VT_TO_LIST(NAME,NAMELENGTH,NAMESPACE,CLASS,LIST,VALUE,VT) \ do { \ register struct partial_symbol *psym; \ if ((LIST).next >= (LIST).list + (LIST).size) \ - extend_psymbol_list(&(LIST)); \ + extend_psymbol_list (&(LIST),objfile); \ psym = (LIST).next++; \ \ - SYMBOL_NAME (psym) = (char *) obstack_alloc (psymbol_obstack, \ + SYMBOL_NAME (psym) = (char *) obstack_alloc (&objfile->psymbol_obstack, \ (NAMELENGTH) + 1); \ - strncpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH)); \ + memcpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH)); \ SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0'; \ SYMBOL_NAMESPACE (psym) = (NAMESPACE); \ SYMBOL_CLASS (psym) = (CLASS); \ VT (psym) = (VALUE); \ } while (0); +#ifdef DEBUG + +/* Since one arg is a struct, we have to pass in a ptr and deref it (sigh) */ + +#define ADD_PSYMBOL_TO_LIST(name, namelength, namespace, class, list, value) \ + add_psymbol_to_list (name, namelength, namespace, class, &list, value) + +#define ADD_PSYMBOL_ADDR_TO_LIST(name, namelength, namespace, class, list, value) \ + add_psymbol_addr_to_list (name, namelength, namespace, class, &list, value) + +#else /* !DEBUG */ + +/* Add a symbol with an integer value to a psymtab. */ + +#define ADD_PSYMBOL_TO_LIST(name, namelength, namespace, class, list, value) \ + ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, list, value, SYMBOL_VALUE) + +/* Add a symbol with a CORE_ADDR value to a psymtab. */ + +#define ADD_PSYMBOL_ADDR_TO_LIST(name, namelength, namespace, class, list, value)\ + ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, list, value, SYMBOL_VALUE_ADDRESS) + +#endif /* DEBUG */ + /* Functions */ -extern struct symtab *allocate_symtab (); -extern struct objfile *allocate_objfile (); -extern void free_objfile (); -extern int free_named_symtabs (); -extern void fill_in_vptr_fieldno (); -extern void add_symtab_fns (); -extern void syms_from_objfile (); +extern void +sort_pst_symbols PARAMS ((struct partial_symtab *)); + +extern struct symtab * +allocate_symtab PARAMS ((char *, struct objfile *)); + +extern struct objfile * +allocate_objfile PARAMS ((bfd *, char *, int)); + +extern void +free_objfile PARAMS ((struct objfile *)); + +extern void +free_all_objfiles PARAMS ((void)); + +extern int +free_named_symtabs PARAMS ((char *)); -/* Functions for dealing with the misc "function" vector, really a misc - address<->symbol mapping vector for things we don't have debug symbols - for. */ +extern void +fill_in_vptr_fieldno PARAMS ((struct type *)); -extern void init_misc_bunches (); -extern void prim_record_misc_function (); -extern void discard_misc_bunches (); -extern void condense_misc_bunches (); +extern void +add_symtab_fns PARAMS ((struct sym_fns *)); + +extern void +syms_from_objfile PARAMS ((struct objfile *, CORE_ADDR, int, int)); + +extern struct partial_symtab * +start_psymtab_common PARAMS ((struct objfile *, CORE_ADDR, char *, CORE_ADDR, + struct partial_symbol *, + struct partial_symbol *)); /* Sorting your symbols for fast lookup or alphabetical printing. */ -extern void sort_block_syms (); -extern void sort_symtab_syms (); -extern void sort_all_symtab_syms (); -extern void sort_block_syms (); +extern void +sort_block_syms PARAMS ((struct block *)); + +extern void +sort_symtab_syms PARAMS ((struct symtab *)); + +extern void +sort_all_symtab_syms PARAMS ((void)); /* Make a copy of the string at PTR with SIZE characters in the symbol obstack (and add a null character at the end in the copy). Returns the address of the copy. */ -extern char *obsavestring (); +extern char * +obsavestring PARAMS ((char *, int, struct obstack *)); /* Concatenate strings S1, S2 and S3; return the new string. Space is found in the symbol_obstack. */ -extern char *obconcat (); +extern char * +obconcat PARAMS ((struct obstack *obstackp, const char *, const char *, + const char *)); /* Variables */ @@ -183,18 +310,20 @@ extern struct objfile *symfile_objfile; /* Where execution starts in symfile */ -CORE_ADDR entry_point; +extern CORE_ADDR entry_point; /* Root of object file struct chain. */ -struct objfile *object_files; +extern struct objfile *object_files; -/* Vectors of all partial symbols read in from file. */ +/* Traverse all object files. ALL_OBJFILES_SAFE works even if you delete + the objfile during the traversal. */ -extern struct psymbol_allocation_list { - struct partial_symbol *list, *next; - int size; -} global_psymbols, static_psymbols; +#define ALL_OBJFILES(obj) \ + for (obj = object_files; 0 != obj; obj = obj->next) + +#define ALL_OBJFILES_SAFE(obj,nxt) \ + for (obj = object_files; obj? (nxt=obj->next, 1): 0; obj = nxt) /* Support for complaining about things in the symbol file that aren't catastrophic. @@ -214,7 +343,65 @@ struct complaint { extern struct complaint complaint_root[1]; +/* Externally visible variables defined in symfile.c */ + +/* The object file that the main symbol table was loaded from (e.g. the + argument to the "symbol-file" or "file" command). */ + +extern struct objfile *symfile_objfile; + +/* Where execution starts in symfile */ + +extern CORE_ADDR entry_point; + +/* Root of object file struct chain. */ + +extern struct objfile *object_files; + /* Functions that handle complaints. (in symfile.c) */ -void complain(); -void clear_complaints(); +extern void +complain PARAMS ((struct complaint *, char *)); + +extern void +clear_complaints PARAMS ((int sym_reading, int noisy)); + +/* From symfile.c */ + +extern struct partial_symtab * +allocate_psymtab PARAMS ((char *, struct objfile *)); + +/* From minsyms.c */ + +extern PTR +iterate_over_msymbols PARAMS ((PTR (*func) (struct objfile *, + struct minimal_symbol *, + PTR arg1, PTR arg2, PTR arg3), + PTR arg1, PTR arg2, PTR arg3)); + +/* From objfiles.c */ + +extern PTR +iterate_over_objfiles PARAMS ((PTR (*func) (struct objfile *, + PTR arg1, PTR arg2, PTR arg3), + PTR arg1, PTR arg2, PTR arg3)); + +extern PTR +iterate_over_symtabs PARAMS ((PTR (*func) (struct objfile *, struct symtab *, + PTR arg1, PTR arg2, PTR arg3), + PTR arg1, PTR arg2, PTR arg3)); + +extern PTR +iterate_over_psymtabs PARAMS ((PTR (*func) (struct objfile *, + struct partial_symtab *, + PTR arg1, PTR arg2, PTR arg3), + PTR arg1, PTR arg2, PTR arg3)); + +/* From dwarfread.c */ + +extern void +dwarf_build_psymtabs PARAMS ((int, char *, CORE_ADDR, int, unsigned int, + unsigned int, unsigned int, unsigned int, + struct objfile *)); + +#endif /* !defined(SYMFILE_H) */ diff --git a/gdb/symm-xdep.c b/gdb/symm-xdep.c index b7d9a91..65cab34 100644 --- a/gdb/symm-xdep.c +++ b/gdb/symm-xdep.c @@ -291,13 +291,13 @@ struct pt_regset ep; printf (" %g\n", val); } if (ep.pr_fpu.fpu_rsvd1) - printf ("warning: rsvd1 is 0x%x\n", ep.pr_fpu.fpu_rsvd1); + warning ("rsvd1 is 0x%x\n", ep.pr_fpu.fpu_rsvd1); if (ep.pr_fpu.fpu_rsvd2) - printf ("warning: rsvd2 is 0x%x\n", ep.pr_fpu.fpu_rsvd2); + warning ("rsvd2 is 0x%x\n", ep.pr_fpu.fpu_rsvd2); if (ep.pr_fpu.fpu_rsvd3) - printf ("warning: rsvd3 is 0x%x\n", ep.pr_fpu.fpu_rsvd3); + warning ("rsvd3 is 0x%x\n", ep.pr_fpu.fpu_rsvd3); if (ep.pr_fpu.fpu_rsvd5) - printf ("warning: rsvd5 is 0x%x\n", ep.pr_fpu.fpu_rsvd5); + warning ("rsvd5 is 0x%x\n", ep.pr_fpu.fpu_rsvd5); } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 3c1df3e..4a3dc08 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -1,5 +1,5 @@ /* Do various things to symbol tables (other than lookup), for GDB. - Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc. + Copyright 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc. This file is part of GDB. @@ -18,9 +18,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdio.h> #include "defs.h" #include "symtab.h" +#include "gdbtypes.h" #include "bfd.h" #include "symfile.h" #include "breakpoint.h" @@ -28,21 +28,99 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "obstack.h" #include <string.h> + +#ifndef DEV_TTY +#define DEV_TTY "/dev/tty" +#endif + +/* Prototypes for local functions */ + +static PTR +dump_symtab PARAMS ((struct objfile *, struct symtab *, PTR, PTR, PTR)); + +static PTR +dump_psymtab PARAMS ((struct objfile *, struct partial_symtab *, PTR, PTR, + PTR)); + +static PTR +dump_msymbols PARAMS ((struct objfile *, PTR, PTR, PTR)); + +static PTR +dump_objfile PARAMS ((struct objfile *, PTR, PTR, PTR)); + +static void +printobjfiles_command PARAMS ((void)); + +static int +block_depth PARAMS ((struct block *)); + +static void +print_partial_symbol PARAMS ((struct partial_symbol *, int, char *, FILE *)); + +static void +printpsyms_command PARAMS ((char *, int)); + +static void +print_symbol PARAMS ((struct symbol *, int, FILE *)); + +static void +printsyms_command PARAMS ((char *, int)); + +static void +free_symtab_block PARAMS ((struct objfile *, struct block *)); + +static void +printmsyms_command PARAMS ((char *, int)); + +static void +dump_symtab_lines PARAMS ((struct symtab *)); + +static void +dump_symtabs PARAMS ((struct symtab *)); + +static void +dump_last_symtab PARAMS ((struct symtab *)); + +static void +dump_blockvector PARAMS ((struct blockvector *)); + +static void +dump_block PARAMS ((struct block *)); + +static char * +dump_addrclass PARAMS ((int)); + +static char * +dump_namespace PARAMS ((int)); + +static void +dump_symbol PARAMS ((struct symbol *)); + +static void +dump_type PARAMS ((struct type *)); + +static void +dump_linetable PARAMS ((struct linetable *)); + +static void +dump_strtbl PARAMS ((void)); + /* Free a struct block <- B and all the symbols defined in that block. */ static void -free_symtab_block (b) +free_symtab_block (objfile, b) + struct objfile *objfile; struct block *b; { register int i, n; n = BLOCK_NSYMS (b); for (i = 0; i < n; i++) { - free (SYMBOL_NAME (BLOCK_SYM (b, i))); - free (BLOCK_SYM (b, i)); + mfree (objfile -> md, SYMBOL_NAME (BLOCK_SYM (b, i))); + mfree (objfile -> md, BLOCK_SYM (b, i)); } - free (b); + mfree (objfile -> md, b); } /* Free all the storage associated with the struct symtab <- S. @@ -75,9 +153,9 @@ free_symtab (s) bv = BLOCKVECTOR (s); n = BLOCKVECTOR_NBLOCKS (bv); for (i = 0; i < n; i++) - free_symtab_block (BLOCKVECTOR_BLOCK (bv, i)); + free_symtab_block (s -> objfile, BLOCKVECTOR_BLOCK (bv, i)); /* Free the blockvector itself. */ - free (bv); + mfree (s -> objfile -> md, bv); /* Also free the linetable. */ case free_linetable: @@ -85,73 +163,202 @@ free_symtab (s) or by some other symtab, except for our linetable. Free that now. */ if (LINETABLE (s)) - free (LINETABLE (s)); + mfree (s -> objfile -> md, LINETABLE (s)); break; } /* If there is a single block of memory to free, free it. */ - if (s->free_ptr) - free (s->free_ptr); + if (s -> free_ptr != NULL) + mfree (s -> objfile -> md, s -> free_ptr); /* Free source-related stuff */ - if (s->line_charpos) - free (s->line_charpos); - if (s->fullname) - free (s->fullname); - free (s); + if (s -> line_charpos != NULL) + mfree (s -> objfile -> md, s -> line_charpos); + if (s -> fullname != NULL) + mfree (s -> objfile -> md, s -> fullname); + mfree (s -> objfile -> md, s); } - -static int block_depth (); -static void print_symbol (); -static void print_partial_symbol (); -void -printsyms_command (filename) - char *filename; +static PTR +dump_objfile (objfile, arg1, arg2, arg3) + struct objfile *objfile; + PTR arg1; + PTR arg2; + PTR arg3; { - FILE *outfile; - register struct symtab *s; - register int i, j; - int len, blen; - register struct linetable *l; - struct blockvector *bv; - register struct block *b; - int depth; - struct cleanup *cleanups; - extern int fclose(); - char *symname; + struct symtab *symtab; + struct partial_symtab *psymtab; - if (filename == 0) - error_no_arg ("file to write symbol data in"); + printf_filtered ("\nObject file %s: ", objfile -> name); + printf_filtered ("Objfile at %x, bfd at %x, %d minsyms\n\n", + objfile, objfile -> obfd, objfile->minimal_symbol_count); - /* If a second arg is supplied, it is a source file name to match on */ - symname = strchr (filename, ' '); - if (symname) - *symname++ = '\0'; + if (objfile -> psymtabs) + { + printf_filtered ("Psymtabs:\n"); + for (psymtab = objfile -> psymtabs; + psymtab != NULL; + psymtab = psymtab -> next) + { + printf_filtered ("%s at %x, ", psymtab -> filename, psymtab); + if (psymtab -> objfile != objfile) + { + printf_filtered ("NOT ON CHAIN! "); + } + wrap_here (" "); + } + printf_filtered ("\n\n"); + } - filename = tilde_expand (filename); - make_cleanup (free, filename); + if (objfile -> symtabs) + { + printf_filtered ("Symtabs:\n"); + for (symtab = objfile -> symtabs; + symtab != NULL; + symtab = symtab->next) + { + printf_filtered ("%s at %x, ", symtab -> filename, symtab); + if (symtab -> objfile != objfile) + { + printf_filtered ("NOT ON CHAIN! "); + } + wrap_here (" "); + } + printf_filtered ("\n\n"); + } + return (NULL); +} + +static PTR +dump_msymbols (objfile, arg1, arg2, arg3) + struct objfile *objfile; + PTR arg1; + PTR arg2; + PTR arg3; +{ + FILE *outfile = (FILE *) arg1; + char *symname = (char *) arg2; + struct minimal_symbol *msymbol; + int index; + char ms_type; - outfile = fopen (filename, "w"); - if (outfile == 0) - perror_with_name (filename); + /* Print minimal symbols from this objfile unless a specific linkage + unit file was requested, in which case we only print the symbols + for that one. */ + if (symname == NULL || (strcmp (symname, objfile -> name) == 0)) + { + fprintf_filtered (outfile, "\nObject file %s:\n\n", objfile -> name); + for (index = 0, msymbol = objfile -> msymbols; + msymbol -> name != NULL; msymbol++, index++) + { + switch (msymbol -> type) + { + case mst_unknown: + ms_type = 'u'; + break; + case mst_text: + ms_type = 't'; + break; + case mst_data: + ms_type = 'd'; + break; + case mst_bss: + ms_type = 'b'; + break; + case mst_abs: + ms_type = 'a'; + break; + default: + ms_type = '?'; + break; + } + fprintf_filtered (outfile, "[%2d] %c %#10x %s\n", index, ms_type, + msymbol -> address, msymbol -> name); + } + if (objfile -> minimal_symbol_count != index) + { + warning ("internal error: minimal symbol count %d != %d", + objfile -> minimal_symbol_count, index); + } + fprintf_filtered (outfile, "\n"); + } + return (NULL); +} - cleanups = make_cleanup (fclose, outfile); - immediate_quit++; +static PTR +dump_psymtab (objfile, psymtab, arg1, arg2, arg3) + struct objfile *objfile; + struct partial_symtab *psymtab; + PTR arg1; + PTR arg2; + PTR arg3; +{ + FILE *outfile = (FILE *) arg1; + char *symname = (char *) arg2; - for (s = symtab_list; s; s = s->next) + /* If source file name is specified, reject all but that one. */ + if (symname == NULL || (strcmp (symname, psymtab -> filename) == 0)) { - /* If source file name is specified, reject all but that one. */ - if (symname) - if (0 != strncmp (symname, s->filename, strlen (symname))) - continue; + fprintf_filtered (outfile, "\nPartial symtab for source file %s ", + psymtab -> filename); + fprintf_filtered (outfile, "(object 0x%x)\n\n", psymtab); + fprintf (outfile, " Read from object file %s (0x%x)\n", + objfile -> name, objfile); + + if (psymtab -> readin) + { + fprintf_filtered (outfile, + " Full symtab was read (at 0x%x by function at 0x%x)\n", + psymtab -> symtab, psymtab -> read_symtab); + } + fprintf_filtered (outfile, " Relocate symbols by 0x%x\n", + psymtab -> addr); + fprintf_filtered (outfile, " Symbols cover text addresses 0x%x-0x%x\n", + psymtab -> textlow, psymtab -> texthigh); + fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n", + psymtab -> number_of_dependencies); + if (psymtab -> n_global_syms > 0) + { + print_partial_symbol (objfile -> global_psymbols.list + + psymtab -> globals_offset, + psymtab -> n_global_syms, "Global", outfile); + } + if (psymtab -> n_static_syms > 0) + { + print_partial_symbol (objfile -> static_psymbols.list + + psymtab -> statics_offset, + psymtab -> n_static_syms, "Static", outfile); + } + fprintf_filtered (outfile, "\n"); + } + return (NULL); +} - fprintf (outfile, "Symtab for file %s\n", s->filename); - fprintf (outfile, "Read from object file %s (%x)\n", s->objfile->name, - s->objfile); +static PTR +dump_symtab (objfile, symtab, arg1, arg2, arg3) + struct objfile *objfile; + struct symtab *symtab; + PTR arg1; + PTR arg2; + PTR arg3; +{ + FILE *outfile = (FILE *) arg1; + char *symname = (char *) arg2; + register int i, j; + int len, blen; + register struct linetable *l; + struct blockvector *bv; + register struct block *b; + int depth; + if (symname == NULL || (strcmp (symname, symtab -> filename) == 0)) + { + fprintf (outfile, "\nSymtab for file %s\n", symtab->filename); + fprintf (outfile, "Read from object file %s (%x)\n", objfile->name, + objfile); + /* First print the line table. */ - l = LINETABLE (s); + l = LINETABLE (symtab); if (l) { fprintf (outfile, "\nLine table:\n\n"); len = l->nitems; @@ -161,7 +368,7 @@ printsyms_command (filename) } /* Now print the block info. */ fprintf (outfile, "\nBlockvector:\n\n"); - bv = BLOCKVECTOR (s); + bv = BLOCKVECTOR (symtab); len = BLOCKVECTOR_NBLOCKS (bv); for (i = 0; i < len; i++) { @@ -181,10 +388,54 @@ printsyms_command (filename) print_symbol (BLOCK_SYM (b, j), depth + 1, outfile); } } + fprintf (outfile, "\n"); + } + return (NULL); +} - fprintf (outfile, "\n\n"); +static void +printsyms_command (args, from_tty) + char *args; + int from_tty; +{ + char **argv; + FILE *outfile; + struct cleanup *cleanups; + char *symname = NULL; + char *filename = DEV_TTY; + + dont_repeat (); + + if (args == NULL) + { + error ("printsyms takes an output file name and optional symbol file name"); + } + else if ((argv = buildargv (args)) == NULL) + { + nomem (0); + } + cleanups = make_cleanup (freeargv, (char *) argv); + + if (argv[0] != NULL) + { + filename = argv[0]; + /* If a second arg is supplied, it is a source file name to match on */ + if (argv[1] != NULL) + { + symname = argv[1]; + } } + filename = tilde_expand (filename); + make_cleanup (free, filename); + + outfile = fopen (filename, "w"); + if (outfile == 0) + perror_with_name (filename); + make_cleanup (fclose, (char *) outfile); + + immediate_quit++; + iterate_over_symtabs (dump_symtab, (PTR) outfile, (PTR) symname, (PTR) NULL); immediate_quit--; do_cleanups (cleanups); } @@ -301,23 +552,38 @@ print_symbol (symbol, depth, outfile) fprintf (outfile, "\n"); } -void -printpsyms_command (filename) - char *filename; +static void +printpsyms_command (args, from_tty) + char *args; + int from_tty; { + char **argv; FILE *outfile; - struct partial_symtab *p; struct cleanup *cleanups; - extern int fclose(); - char *symname; + char *symname = NULL; + char *filename = DEV_TTY; - if (filename == 0) - error_no_arg ("file to write partial symbol data in"); + dont_repeat (); - /* If a second arg is supplied, it is a source file name to match on */ - symname = strchr (filename, ' '); - if (symname) - *symname++ = '\0'; + if (args == NULL) + { + error ("printpsyms takes an output file name and optional symbol file name"); + } + else if ((argv = buildargv (args)) == NULL) + { + nomem (0); + } + cleanups = make_cleanup (freeargv, (char *) argv); + + if (argv[0] != NULL) + { + filename = argv[0]; + /* If a second arg is supplied, it is a source file name to match on */ + if (argv[1] != NULL) + { + symname = argv[1]; + } + } filename = tilde_expand (filename); make_cleanup (free, filename); @@ -325,50 +591,21 @@ printpsyms_command (filename) outfile = fopen (filename, "w"); if (outfile == 0) perror_with_name (filename); + make_cleanup (fclose, outfile); - cleanups = make_cleanup (fclose, outfile); immediate_quit++; - - for (p = partial_symtab_list; p; p = p->next) - { - /* If source file name is specified, reject all but that one. */ - if (symname) - if (0 != strncmp (symname, p->filename, strlen (symname))) - continue; - - fprintf_filtered (outfile, "Partial symtab for source file %s ", - p->filename); - fprintf_filtered (outfile, "(object 0x%x)\n\n", p); - fprintf (outfile, " Read from object file %s (0x%x)\n", p->objfile->name, - p->objfile); - - if (p->readin) - fprintf_filtered (outfile, " Full symtab was read (at 0x%x by function at 0x%x)\n", - p->symtab, p->read_symtab); - fprintf_filtered (outfile, " Relocate symbols by 0x%x\n", p->addr); - fprintf_filtered (outfile, " Symbols cover text addresses 0x%x-0x%x\n", - p->textlow, p->texthigh); - fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n", - p->number_of_dependencies); - if (p->n_global_syms > 0) - print_partial_symbol (global_psymbols.list + p->globals_offset, - p->n_global_syms, "Global", outfile); - if (p->n_static_syms > 0) - print_partial_symbol (static_psymbols.list + p->statics_offset, - p->n_static_syms, "Static", outfile); - fprintf_filtered (outfile, "\n\n"); - } - + iterate_over_psymtabs (dump_psymtab, (PTR) outfile, (PTR) symname, + (PTR) NULL); immediate_quit--; do_cleanups (cleanups); } static void print_partial_symbol (p, count, what, outfile) -struct partial_symbol *p; -int count; -char *what; -FILE *outfile; + struct partial_symbol *p; + int count; + char *what; + FILE *outfile; { fprintf_filtered (outfile, " %s partial symbols:\n", what); @@ -444,122 +681,254 @@ FILE *outfile; } } -/* Return the nexting depth of a block within other blocks in its symtab. */ +static void +printmsyms_command (args, from_tty) + char *args; + int from_tty; +{ + char **argv; + FILE *outfile; + struct cleanup *cleanups; + char *filename = DEV_TTY; + char *symname = NULL; -static int -block_depth (block) - struct block *block; + dont_repeat (); + + if (args == NULL) + { + error ("printmsyms takes an output file name and optional symbol file name"); + } + else if ((argv = buildargv (args)) == NULL) + { + nomem (0); + } + cleanups = make_cleanup (freeargv, argv); + + if (argv[0] != NULL) + { + filename = argv[0]; + /* If a second arg is supplied, it is a source file name to match on */ + if (argv[1] != NULL) + { + symname = argv[1]; + } + } + + filename = tilde_expand (filename); + make_cleanup (free, filename); + + outfile = fopen (filename, "w"); + if (outfile == 0) + perror_with_name (filename); + make_cleanup (fclose, outfile); + + immediate_quit++; + iterate_over_objfiles (dump_msymbols, (PTR) outfile, (PTR) symname, + (PTR) NULL); + immediate_quit--; + fprintf_filtered (outfile, "\n\n"); + do_cleanups (cleanups); +} + +static void +printobjfiles_command () { - register int i = 0; - while (block = BLOCK_SUPERBLOCK (block)) i++; - return i; + dont_repeat (); + + immediate_quit++; + iterate_over_objfiles (dump_objfile, (PTR) NULL, (PTR) NULL, (PTR) NULL); + immediate_quit--; } + +/* Debugging functions from xcoffread.c originally. Some are redundant + and should probably disappear. */ + static void -printobjfiles_command () +dump_strtbl () { - struct objfile *objfile; - struct symtab *symtab; - struct partial_symtab *psymtab; - int first; +#if 0 /* We don't know its length FIXME */ + int ii; + printf ("===STRING TABLE DUMP...\n\n"); + for ( ii=0; ii < strtbl_len; ++ii ) + printf ("%c", isprint (*(strtbl+ii)) ? *(strtbl+ii) : ' '); + printf ("\n"); +#endif +} - for (objfile = object_files; objfile; objfile = objfile->next) { - printf_filtered ("\nObject file %s: ", objfile->name); - printf_filtered ("Objfile at %x, bfd at %x\n\n", objfile, objfile->obfd); +static void +dump_linetable (ltb) + struct linetable *ltb; +{ + int ii; + for (ii=0; ii < ltb->nitems; ++ii) + printf ("line: %d, addr: 0x%x\n", ltb->item[ii].line, ltb->item[ii].pc); +} - if (objfile->psymtabs) { - printf_filtered ("Psymtabs:\n"); - for (psymtab = objfile->psymtabs; - psymtab; - psymtab = psymtab->objfile_chain) { - printf_filtered ("%s at %x, ", psymtab->filename, psymtab); - if (psymtab->objfile != objfile) - printf_filtered ("NOT ON CHAIN! "); - wrap_here (" "); - } - printf_filtered ("\n\n"); - } +static void +dump_type (typeP) + struct type *typeP; +{ + printf ("0x%x: name: %s\n", typeP, typeP->name ? typeP->name : "(nil)"); +} - if (objfile->symtabs) { - printf_filtered ("Symtabs:\n"); - for (symtab = objfile->symtabs; - symtab; - symtab = symtab->objfile_chain) { - printf_filtered ("%s at %x, ", symtab->filename, symtab); - if (symtab->objfile != objfile) - printf_filtered ("NOT ON CHAIN! "); - wrap_here (" "); - } - printf_filtered ("\n\n"); - } +static void +dump_symbol (pp) + struct symbol *pp; +{ + printf (" sym: %s\t%s,\t%s\ttype: 0x%x, val: 0x%x end: 0x%x\n", + pp->name, dump_namespace (pp->namespace), + dump_addrclass (pp->class), pp->type, + SYMBOL_CLASS(pp) == LOC_BLOCK ? BLOCK_START(SYMBOL_BLOCK_VALUE(pp)) + : pp->value.value, + SYMBOL_CLASS(pp) == LOC_BLOCK ? BLOCK_END(SYMBOL_BLOCK_VALUE(pp)) : 0); +} + +static char * +dump_namespace (ns) +int ns; +{ + static char *ns_name [] = { + "UNDEF_NS", "VAR_NS", "STRUCT_NS", "LABEL_NS"}; + + switch (ns) { + case UNDEF_NAMESPACE: + case VAR_NAMESPACE: + case STRUCT_NAMESPACE: + case LABEL_NAMESPACE: + return ns_name[ns]; + } + + return "***ERROR***"; +} + +static char * +dump_addrclass (ac) +int ac; /* address class */ +{ + static char *ac_name [] = { + "LOC_UNDEF", + "LOC_CONST", + "LOC_STATIC", + "LOC_REGISTER", + "LOC_ARG", + "LOC_REF_ARG", + "LOC_REGPARM", + "LOC_LOCAL", + "LOC_TYPEDEF", + "LOC_LABEL", + "LOC_BLOCK", + "LOC_CONST_BYTES", + "LOC_LOCAL_ARG", + }; + switch (ac) { + case LOC_UNDEF: + case LOC_CONST: + case LOC_STATIC: + case LOC_REGISTER: + case LOC_ARG: + case LOC_REF_ARG: + case LOC_REGPARM: + case LOC_LOCAL: + case LOC_TYPEDEF: + case LOC_LABEL: + case LOC_BLOCK: + case LOC_CONST_BYTES: + case LOC_LOCAL_ARG: + return ac_name [ac]; } + return "***ERROR***"; +} + +static void +dump_block (pp) + struct block *pp; +{ + int ii; + printf ("BLOCK..: start: 0x%x, end: 0x%x\n", pp->startaddr, pp->endaddr); + for (ii=0; ii < pp->nsyms; ++ii) + dump_symbol (pp->sym[ii]); +} - /* Now check for psymtabs that aren't owned by an objfile. */ +static void +dump_blockvector (pp) + struct blockvector *pp; +{ + int ii; + for (ii=0; ii < pp->nblocks; ++ii) + dump_block (pp->block [ii]); +} - first = 1; - for (psymtab = partial_symtab_list; psymtab; psymtab = psymtab->next) { - for (objfile = object_files; objfile; objfile = objfile->next) { - if (psymtab->objfile == objfile) - goto next; +static void +dump_last_symtab (pp) + struct symtab *pp; +{ + for ( ; pp; pp = pp->next) { + if ( pp->next == 0 ) { + printf ("SYMTAB NAME: %s\n", pp->filename); + dump_blockvector (pp->blockvector); } - if (first) - printf_filtered ("Psymtabs that aren't owned by any objfile:\n"); - first = 0; - printf_filtered (" %s at %x, psymtab->objfile %x\n", psymtab->filename, - psymtab, psymtab->objfile); - next: ; } +} - /* Now check for symtabs that aren't owned by an objfile. */ +static void +dump_symtabs (pp) + struct symtab *pp; +{ + for ( ; pp; pp = pp->next) { + printf ("SYMTAB NAME: %s\n", pp->filename ? pp->filename : "(nil)"); +/* if (pp->linetable) + dump_linetable (pp->linetable); */ + dump_blockvector (pp->blockvector); + } +} - first = 1; - for (symtab = symtab_list; symtab; symtab = symtab->next) { - for (objfile = object_files; objfile; objfile = objfile->next) { - if (symtab->objfile == objfile) - goto next2; - } - if (first) - printf_filtered ("Symtabs that aren't owned by any objfile:\n"); - first = 0; - printf_filtered (" %s at %x, symtab->objfile %x\n", symtab->filename, - symtab, symtab->objfile); - next2: ; +static void +dump_symtab_lines (pp) + struct symtab *pp; +{ + for ( ; pp; pp = pp->next) { + printf ("SYMTAB NAME: %s\n", pp->filename ? pp->filename : "(nil)"); + if (pp->linetable) + dump_linetable (pp->linetable); + /* dump_blockvector (pp->blockvector); */ } } + + -struct cplus_struct_type cplus_struct_default; +/* Return the nexting depth of a block within other blocks in its symtab. */ -void -allocate_cplus_struct_type (type) - struct type *type; +static int +block_depth (block) + struct block *block; { - if (!HAVE_CPLUS_STRUCT (type)) - { - int nfields = TYPE_NFIELDS (type); - TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *) - obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type)); - *(TYPE_CPLUS_SPECIFIC(type)) = cplus_struct_default; - } + register int i = 0; + while (block = BLOCK_SUPERBLOCK (block)) i++; + return i; } + /* Increase the space allocated for LISTP. */ void -extend_psymbol_list(listp) +extend_psymbol_list (listp, objfile) register struct psymbol_allocation_list *listp; + struct objfile *objfile; { int new_size; if (listp->size == 0) { new_size = 255; listp->list = (struct partial_symbol *) - xmalloc (new_size * sizeof (struct partial_symbol)); + xmmalloc (objfile -> md, new_size * sizeof (struct partial_symbol)); } else { new_size = listp->size * 2; listp->list = (struct partial_symbol *) - xrealloc (listp->list, new_size * sizeof (struct partial_symbol)); + xmrealloc (objfile -> md, (char *) listp->list, + new_size * sizeof (struct partial_symbol)); } /* Next assumes we only went one over. Should be good if program works correctly */ @@ -585,9 +954,9 @@ add_psymbol_to_list (name, namelength, namespace, class, listp, psymval) register struct partial_symbol *psym; if (listp -> next >= listp -> list + listp -> size) - extend_psymbol_list (listp); + extend_psymbol_list (listp, objfile); psym = listp -> next++; - SYMBOL_NAME (psym) = (char *) obstack_alloc (psymbol_obstack, + SYMBOL_NAME (psym) = (char *) obstack_alloc (&objfile->psymbol_obstack, namelength + 1); memcpy (SYMBOL_NAME (psym), name, namelength); SYMBOL_NAME (psym)[namelength] = '\0'; @@ -612,9 +981,9 @@ add_psymbol_addr_to_list (name, namelength, namespace, class, listp, psymval) register struct partial_symbol *psym; if (listp -> next >= listp -> list + listp -> size) - extend_psymbol_list (listp); + extend_psymbol_list (listp, objfile); psym = listp -> next++; - SYMBOL_NAME (psym) = (char *) obstack_alloc (psymbol_obstack, + SYMBOL_NAME (psym) = (char *) obstack_alloc (&objfile->psymbol_obstack, namelength + 1); memcpy (SYMBOL_NAME (psym), name, namelength); SYMBOL_NAME (psym)[namelength] = '\0'; @@ -628,15 +997,15 @@ add_psymbol_addr_to_list (name, namelength, namespace, class, listp, psymval) void _initialize_symmisc () { - symtab_list = (struct symtab *) 0; - partial_symtab_list = (struct partial_symtab *) 0; - - add_com ("printsyms", class_obscure, printsyms_command, - "Print dump of current symbol definitions to file OUTFILE.\n\ + add_com ("printmsyms", class_obscure, printmsyms_command, + "Print dump of current minimal symbol definitions to file OUTFILE.\n\ If a SOURCE file is specified, dump only that file's symbols."); add_com ("printpsyms", class_obscure, printpsyms_command, "Print dump of current partial symbol definitions to file OUTFILE.\n\ If a SOURCE file is specified, dump only that file's partial symbols."); + add_com ("printsyms", class_obscure, printsyms_command, + "Print dump of current symbol definitions to file OUTFILE.\n\ +If a SOURCE file is specified, dump only that file's symbols."); add_com ("printobjfiles", class_obscure, printobjfiles_command, "Print dump of current object file definitions."); } diff --git a/gdb/symtab.c b/gdb/symtab.c index 407a608..55f3899 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdio.h> #include "defs.h" #include "symtab.h" #include "gdbtypes.h" @@ -342,6 +341,40 @@ find_pc_psymbol (psymtab, pc) } +/* Function called via iterate_over_msymbols() that tests a minimal symbol + to see if the minimal symbol's name is a C++ mangled name that matches + a user visible name. The user visible name (pname) is passed as arg1 + and the number of leading characters that must match in both the mangled + name and the user name (matchcount) is passed as arg2. Returns a pointer + to the minimal symbol if it matches, NULL otherwise. */ + +static PTR +cplus_mangled_symbol (objfile, msymbol, arg1, arg2, arg3) + struct objfile *objfile; + struct minimal_symbol *msymbol; + PTR arg1; + PTR arg2; + PTR arg3; +{ + char *pname = (char *) arg1; + int matchcount = (int) arg2; + char *demangled; + struct minimal_symbol *foundit = NULL; + + if (strncmp (msymbol -> name, pname, matchcount) == 0) + { + if ((demangled = cplus_demangle (msymbol -> name, -1)) != NULL) + { + if (strcmp (demangled, pname) == 0) + { + foundit = msymbol; + } + free (demangled); + } + } + return ((PTR) foundit); +} + /* Find the definition for a specified symbol name NAME in namespace NAMESPACE, visible from lexical block BLOCK. Returns the struct symbol pointer, or zero if no symbol is found. @@ -483,50 +516,30 @@ lookup_symbol (name, block, namespace, is_a_field_of_this, symtab) if (namespace == VAR_NAMESPACE) { msymbol = lookup_minimal_symbol (name, (struct objfile *) NULL); - /* Look for a mangled C++ name for NAME. */ if (msymbol == NULL) { - int name_len = strlen (name); - -#if 0 /* FIXME: Needs to be fixed to use new minimal symbol tables */ - for (ind = misc_function_count; --ind >= 0; ) - /* Assume orginal name is prefix of mangled name. */ - if (!strncmp (misc_function_vector[ind].name, name, name_len)) - { - char *demangled = - cplus_demangle(misc_function_vector[ind].name, -1); - if (demangled != NULL) - { - int cond = strcmp (demangled, name); - free (demangled); - if (!cond) - break; - } - } - /* Loop terminates on no match with ind == -1. */ -#endif + /* Look for a mangled C++ name for NAME. */ + msymbol = (struct minimal_symbol *) + iterate_over_msymbols (cplus_mangled_symbol, (PTR) name, + (PTR) strlen (name), (PTR) NULL); } - if (msymbol != NULL) { s = find_pc_symtab (msymbol -> address); - /* If S is zero, there are no debug symbols for this file. + /* If S is NULL, there are no debug symbols for this file. Skip this stuff and check for matching static symbols below. */ - if (s) + if (s != NULL) { bv = BLOCKVECTOR (s); block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); sym = lookup_block_symbol (block, msymbol -> name, namespace); -#if 0 /* defined(IBM6000) */ - /* we kept static functions in misc_function_vector as well as + /* We kept static functions in minimal symbol table as well as in static scope. We want to find them in the symbol table. */ - if (!sym) { block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); - sym = lookup_block_symbol (block, misc_function_vector[ind].name, - namespace); + sym = lookup_block_symbol (block, msymbol -> name, + namespace); } -#endif /* sym == 0 if symbol was found in the minimal symbol table but not in the symtab. diff --git a/gdb/xm-amix.h b/gdb/xm-amix.h index c100f68..a5c33a3 100644 --- a/gdb/xm-amix.h +++ b/gdb/xm-amix.h @@ -33,3 +33,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __GNUC__ # define NORETURN /**/ #endif + +/* If you expect to use the mmalloc package to obtain mapped symbol files, + for now you have to specify some parameters that determine how gdb places + the mappings in it's address space. See the comments in map_to_address() + for details. This is expected to only be a short term solution. Yes it + is a kludge. + FIXME: Make this more automatic. */ + +#define MMAP_BASE_ADDRESS 0xC2000000 /* First mapping here */ +#define MMAP_INCREMENT 0x01000000 /* Increment to next mapping */ diff --git a/gdb/xm-i386v4.h b/gdb/xm-i386v4.h index 1668508..9528d61 100644 --- a/gdb/xm-i386v4.h +++ b/gdb/xm-i386v4.h @@ -33,3 +33,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __GNUC__ # define NORETURN /**/ #endif + +/* If you expect to use the mmalloc package to obtain mapped symbol files, + for now you have to specify some parameters that determine how gdb places + the mappings in it's address space. See the comments in map_to_address() + for details. This is expected to only be a short term solution. Yes it + is a kludge. + FIXME: Make this more automatic. */ + +#define MMAP_BASE_ADDRESS 0x81000000 /* First mapping here */ +#define MMAP_INCREMENT 0x01000000 /* Increment to next mapping */ diff --git a/gdb/xm-sun3os4.h b/gdb/xm-sun3os4.h index de0a640..b9401f9 100644 --- a/gdb/xm-sun3os4.h +++ b/gdb/xm-sun3os4.h @@ -30,3 +30,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* SunOS 4.x has memory mapped files. */ #define HAVE_MMAP + +/* If you expect to use the mmalloc package to obtain mapped symbol files, + for now you have to specify some parameters that determine how gdb places + the mappings in it's address space. See the comments in map_to_address() + for details. This is expected to only be a short term solution. Yes it + is a kludge. + FIXME: Make this more automatic. */ + +#define MMAP_BASE_ADDRESS 0xE0000000 /* First mapping here */ +#define MMAP_INCREMENT 0x01000000 /* Increment to next mapping */ diff --git a/gdb/xm-sun4os4.h b/gdb/xm-sun4os4.h index 6deb334..fb03aef 100644 --- a/gdb/xm-sun4os4.h +++ b/gdb/xm-sun4os4.h @@ -30,3 +30,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* SunOS 4.x has memory mapped files. */ #define HAVE_MMAP + +/* If you expect to use the mmalloc package to obtain mapped symbol files, + for now you have to specify some parameters that determine how gdb places + the mappings in it's address space. See the comments in map_to_address() + for details. This is expected to only be a short term solution. Yes it + is a kludge. + FIXME: Make this more automatic. */ + +#define MMAP_BASE_ADDRESS 0xE0000000 /* First mapping here */ +#define MMAP_INCREMENT 0x01000000 /* Increment to next mapping */ |