1991-10-26 07:21:30 +00:00
|
|
|
|
/* Build symbol tables in GDB's internal format.
|
1999-01-31 23:57:18 +00:00
|
|
|
|
Copyright 1986-1993, 1996-1999 Free Software Foundation, Inc.
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
1995-08-02 03:41:12 +00:00
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
1992-02-22 01:46:16 +00:00
|
|
|
|
#if !defined (BUILDSYM_H)
|
|
|
|
|
#define BUILDSYM_H 1
|
|
|
|
|
|
1991-10-26 07:21:30 +00:00
|
|
|
|
/* This module provides definitions used for creating and adding to
|
|
|
|
|
the symbol table. These routines are called from various symbol-
|
1999-01-31 23:57:18 +00:00
|
|
|
|
file-reading routines.
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
They originated in dbxread.c of gdb-4.2, and were split out to
|
|
|
|
|
make xcoffread.c more maintainable by sharing code.
|
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
Variables declared in this file can be defined by #define-ing the
|
|
|
|
|
name EXTERN to null. It is used to declare variables that are
|
|
|
|
|
normally extern, but which get defined in a single module using
|
|
|
|
|
this technique. */
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
#ifndef EXTERN
|
1992-07-28 04:22:18 +00:00
|
|
|
|
#define EXTERN extern
|
1991-10-26 07:21:30 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
#define HASHSIZE 127 /* Size of things hashed via
|
|
|
|
|
hashname() */
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* Name of source file whose symbol data we are now processing. This
|
|
|
|
|
comes from a symbol of type N_SO. */
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
EXTERN char *last_source_file;
|
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* Core address of start of text of current source file. This too
|
|
|
|
|
comes from the N_SO symbol. */
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
EXTERN CORE_ADDR last_source_start_addr;
|
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* The list of sub-source-files within the current individual
|
|
|
|
|
compilation. Each file gets its own symtab with its own linetable
|
|
|
|
|
and associated info, but they all share one blockvector. */
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
struct subfile
|
1999-01-31 23:57:18 +00:00
|
|
|
|
{
|
|
|
|
|
struct subfile *next;
|
|
|
|
|
char *name;
|
|
|
|
|
char *dirname;
|
|
|
|
|
struct linetable *line_vector;
|
|
|
|
|
int line_vector_length;
|
|
|
|
|
enum language language;
|
|
|
|
|
char *debugformat;
|
|
|
|
|
};
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
EXTERN struct subfile *subfiles;
|
|
|
|
|
|
|
|
|
|
EXTERN struct subfile *current_subfile;
|
|
|
|
|
|
|
|
|
|
/* Global variable which, when set, indicates that we are processing a
|
|
|
|
|
.o file compiled with gcc */
|
|
|
|
|
|
|
|
|
|
EXTERN unsigned char processing_gcc_compilation;
|
|
|
|
|
|
1993-06-18 17:40:50 +00:00
|
|
|
|
/* When set, we are processing a .o file compiled by sun acc. This is
|
|
|
|
|
misnamed; it refers to all stabs-in-elf implementations which use
|
|
|
|
|
N_UNDF the way Sun does, including Solaris gcc. Hopefully all
|
|
|
|
|
stabs-in-elf implementations ever invented will choose to be
|
|
|
|
|
compatible. */
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1992-06-13 02:18:44 +00:00
|
|
|
|
EXTERN unsigned char processing_acc_compilation;
|
|
|
|
|
|
1998-12-10 21:25:43 +00:00
|
|
|
|
/* elz: added this flag to know when a block is compiled with HP
|
|
|
|
|
compilers (cc, aCC). This is necessary because of the macro
|
1999-01-31 23:57:18 +00:00
|
|
|
|
COERCE_FLOAT_TO_DOUBLE defined in tm_hppa.h, which causes a
|
|
|
|
|
coercion of float to double to always occur in parameter passing
|
|
|
|
|
for a function called by gdb (see the function value_arg_coerce in
|
|
|
|
|
valops.c). This is necessary only if the target was compiled with
|
|
|
|
|
gcc, not with HP compilers or with g++ */
|
1998-12-10 21:25:43 +00:00
|
|
|
|
|
|
|
|
|
EXTERN unsigned char processing_hp_compilation;
|
|
|
|
|
|
1991-10-26 07:21:30 +00:00
|
|
|
|
/* Count symbols as they are processed, for error messages. */
|
|
|
|
|
|
|
|
|
|
EXTERN unsigned int symnum;
|
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* 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. */
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
#define PENDINGSIZE 100
|
|
|
|
|
|
|
|
|
|
struct pending
|
1999-01-31 23:57:18 +00:00
|
|
|
|
{
|
|
|
|
|
struct pending *next;
|
|
|
|
|
int nsyms;
|
|
|
|
|
struct symbol *symbol[PENDINGSIZE];
|
|
|
|
|
};
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
/* Here are the three lists that symbols are put on. */
|
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* static at top level, and types */
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
EXTERN struct pending *file_symbols;
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* global functions and variables */
|
1991-10-27 22:26:02 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
EXTERN struct pending *global_symbols;
|
1998-12-10 21:25:43 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* everything local to lexical context */
|
|
|
|
|
|
|
|
|
|
EXTERN struct pending *local_symbols;
|
|
|
|
|
|
|
|
|
|
/* func params local to lexical context */
|
|
|
|
|
|
|
|
|
|
EXTERN struct pending *param_symbols;
|
|
|
|
|
|
|
|
|
|
/* Stack representing unclosed lexical contexts (that will become
|
|
|
|
|
blocks, eventually). */
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
struct context_stack
|
1999-01-31 23:57:18 +00:00
|
|
|
|
{
|
|
|
|
|
/* Outer locals at the time we entered */
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
struct pending *locals;
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* Pending func params at the time we entered */
|
1998-12-10 21:25:43 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
struct pending *params;
|
1998-12-10 21:25:43 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* Pointer into blocklist as of entry */
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
struct pending_block *old_blocks;
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* Name of function, if any, defining context */
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
struct symbol *name;
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* PC where this context starts */
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
CORE_ADDR start_addr;
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* Temp slot for exception handling. */
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
CORE_ADDR end_addr;
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* For error-checking matching push/pop */
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
int depth;
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
};
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
EXTERN struct context_stack *context_stack;
|
|
|
|
|
|
|
|
|
|
/* Index of first unused entry in context stack. */
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1991-10-26 07:21:30 +00:00
|
|
|
|
EXTERN int context_stack_depth;
|
|
|
|
|
|
|
|
|
|
/* Currently allocated size of context stack. */
|
|
|
|
|
|
|
|
|
|
EXTERN int context_stack_size;
|
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* Macro "function" for popping contexts from the stack. Pushing is
|
|
|
|
|
done by a real function, push_context. This returns a pointer to a
|
|
|
|
|
struct context_stack. */
|
1991-11-09 10:50:07 +00:00
|
|
|
|
|
1992-07-28 04:22:18 +00:00
|
|
|
|
#define pop_context() (&context_stack[--context_stack_depth]);
|
1991-11-09 10:50:07 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* Nonzero if within a function (so symbols should be local, if
|
|
|
|
|
nothing says specifically). */
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
|
|
|
|
EXTERN int within_function;
|
|
|
|
|
|
|
|
|
|
/* List of blocks already made (lexical contexts already closed).
|
|
|
|
|
This is used at the end to make the blockvector. */
|
|
|
|
|
|
|
|
|
|
struct pending_block
|
1999-01-31 23:57:18 +00:00
|
|
|
|
{
|
|
|
|
|
struct pending_block *next;
|
|
|
|
|
struct block *block;
|
|
|
|
|
};
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
1998-06-14 14:48:27 +00:00
|
|
|
|
/* Pointer to the head of a linked list of symbol blocks which have
|
1999-01-31 23:57:18 +00:00
|
|
|
|
already been finalized (lexical contexts already closed) and which
|
|
|
|
|
are just waiting to be built into a blockvector when finalizing the
|
1998-06-14 14:48:27 +00:00
|
|
|
|
associated symtab. */
|
|
|
|
|
|
|
|
|
|
EXTERN struct pending_block *pending_blocks;
|
1991-10-26 07:21:30 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
|
1991-11-09 10:50:07 +00:00
|
|
|
|
struct subfile_stack
|
1999-01-31 23:57:18 +00:00
|
|
|
|
{
|
|
|
|
|
struct subfile_stack *next;
|
|
|
|
|
char *name;
|
|
|
|
|
};
|
1991-11-09 10:50:07 +00:00
|
|
|
|
|
|
|
|
|
EXTERN struct subfile_stack *subfile_stack;
|
1991-12-27 21:11:37 +00:00
|
|
|
|
|
* defs.h: Delete extraneous whitespace at end of file.
* symfile.h: Move #include of demangle.h outside conditional.
* objfiles.h (struct objstats, OBJSTAT, OBJSTATS): New struct
and macros to hold per-objfile statistics for internal instrumentation.
(struct objfile): Add OBJSTATS member, which is optional.
* buildsym.h (next_symbol_text_func): Now takes objfile argument.
Also update copyright to 1995.
* dbxread.c (dbx_next_symbol_text): Now takes objfile argument.
(dbx_symfile_init, coffstab_build_psymtabs, elfstab_build_psymtabs,
stabsect_build_psymtabs): Accumulate string table size.
(dbx_next_symbol_text, read_dbx_symtab, read_ofile_symtab):
Accumulate number of stabs symbols read.
* dwarfread.c (new_symbol, symthesize_typedef):
Accumulate number of full symbols created.
* gdbtypes.c (alloc_type): Accumulate number of types.
* maint.c (maintenance_print_statistics): New function.
* mdebugread.c (mdebug_next_symbol_text): Now takes objfile argument.
* minsyms.c (prim_record_minimal_symbol_and_info): Accumulate
number of minimal symbols read.
* os9kread.c (read_os9k_psymtab): next_symbol_text takes objfile arg.
* partial-stab.h: next_symbol_text takes objfile arg.
* stabsread.c (error_type, STABS_CONTINUE): Now takes objfile arg and
uses it to call next_symbol_text.
* symfile.c (add_psymbol_to_list, add_psymbol_addr_to_list):
Accumulate number of partial symbols created.
* symfile.h (ADD_PSYMBOL_VT_TO_LIST): Accumulate number of partial
symbols created.
* symmisc.c (print_objfile_statistics): Print the per-objfile
internal instrumentation statistics gathered.
* xcoffread.c (xcoff_next_symbol_text): Now takes objfile argument.
1995-12-21 04:08:27 +00:00
|
|
|
|
#define next_symbol_text(objfile) (*next_symbol_text_func)(objfile)
|
1991-12-27 21:11:37 +00:00
|
|
|
|
|
|
|
|
|
/* Function to invoke get the next symbol. Return the symbol name. */
|
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
EXTERN char *(*next_symbol_text_func) (struct objfile *);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1992-07-28 04:22:18 +00:00
|
|
|
|
/* Vector of types defined so far, indexed by their type numbers.
|
1999-01-31 23:57:18 +00:00
|
|
|
|
Used for both stabs and coff. (In newer sun systems, dbx uses a
|
|
|
|
|
pair of numbers in parens, as in "(SUBFILENUM,NUMWITHINSUBFILE)".
|
|
|
|
|
Then these numbers must be translated through the type_translations
|
|
|
|
|
hash table to get the index into the type vector.) */
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1992-07-28 04:22:18 +00:00
|
|
|
|
EXTERN struct type **type_vector;
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1992-07-28 04:22:18 +00:00
|
|
|
|
/* Number of elements allocated for type_vector currently. */
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1992-07-28 04:22:18 +00:00
|
|
|
|
EXTERN int type_vector_length;
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
/* Initial size of type vector. Is realloc'd larger if needed, and
|
|
|
|
|
realloc'd down to the size actually used, when completed. */
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1992-07-28 04:22:18 +00:00
|
|
|
|
#define INITIAL_TYPE_VECTOR_LENGTH 160
|
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void add_symbol_to_list (struct symbol *symbol,
|
|
|
|
|
struct pending **listhead);
|
1992-07-28 04:22:18 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern struct symbol *find_symbol_in_list (struct pending *list,
|
|
|
|
|
char *name, int length);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void finish_block (struct symbol *symbol,
|
|
|
|
|
struct pending **listhead,
|
|
|
|
|
struct pending_block *old_blocks,
|
|
|
|
|
CORE_ADDR start, CORE_ADDR end,
|
|
|
|
|
struct objfile *objfile);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void really_free_pendings (int foo);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void start_subfile (char *name, char *dirname);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void patch_subfile_names (struct subfile *subfile, char *name);
|
1992-08-06 19:59:46 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void push_subfile (void);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern char *pop_subfile (void);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern struct symtab *end_symtab (CORE_ADDR end_addr,
|
|
|
|
|
struct objfile *objfile, int section);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
/* Defined in stabsread.c. */
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void scan_file_globals (struct objfile *objfile);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void buildsym_new_init (void);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void buildsym_init (void);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern struct context_stack *push_context (int desc, CORE_ADDR valu);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void start_symtab (char *name, char *dirname, CORE_ADDR start_addr);
|
1992-02-22 01:46:16 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern int hashname (char *name);
|
|
|
|
|
|
|
|
|
|
extern void free_pending_blocks (void);
|
1996-10-08 19:00:38 +00:00
|
|
|
|
|
|
|
|
|
/* FIXME: Note that this is used only in buildsym.c and dstread.c,
|
1999-01-31 23:57:18 +00:00
|
|
|
|
which should be fixed to not need direct access to
|
|
|
|
|
make_blockvector. */
|
1996-10-08 19:00:38 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern struct blockvector *make_blockvector (struct objfile *objfile);
|
1996-10-08 19:00:38 +00:00
|
|
|
|
|
|
|
|
|
/* FIXME: Note that this is used only in buildsym.c and dstread.c,
|
1999-01-31 23:57:18 +00:00
|
|
|
|
which should be fixed to not need direct access to
|
|
|
|
|
record_pending_block. */
|
1996-10-08 19:00:38 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void record_pending_block (struct objfile *objfile,
|
|
|
|
|
struct block *block,
|
|
|
|
|
struct pending_block *opblock);
|
1996-10-08 19:00:38 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void record_debugformat (char *format);
|
1997-06-28 06:10:06 +00:00
|
|
|
|
|
1999-02-01 00:38:25 +00:00
|
|
|
|
extern void merge_symbol_lists (struct pending **srclist,
|
|
|
|
|
struct pending **targetlist);
|
1998-12-10 21:25:43 +00:00
|
|
|
|
|
1992-07-28 04:22:18 +00:00
|
|
|
|
#undef EXTERN
|
|
|
|
|
|
1999-01-31 23:57:18 +00:00
|
|
|
|
#endif /* defined (BUILDSYM_H) */
|