* symfile.c (reread_symbols): When re-reading symbols, do all the

right operations ourself, rather than calling symbol_file_command.
	If we re-read something, call clear_symtab_users not just
	breakpoint_re_set.
	* objfiles.h, objfiles.c (build_objfile_section_table): No longer
	static.
	* symfile.c (clear_symtab_users): Call clear_pc_function_cache.
	* coffread.c, dbxread.c, elfread.c, mipsread.c, nlmread.c, paread.c
	(*_symfile_offsets): Set objfile->num_sections.
	* remote.c (remote_wait), symfile.c (syms_from_objfile):
	Don't muck with objfile->num_sections now that all the symbol
	readers set it.
	* elfread.c: Clean up obsolete comment about handling only DWARF.
	* paread.c: Remove comment about how we should use an "ordinary"
	file format with an hppa suffix.  There is nothing ordinary about SOM.
This commit is contained in:
Jim Kingdon 1993-10-30 20:21:19 +00:00
parent df0393e345
commit 4d57c5995e
11 changed files with 270 additions and 204 deletions

View file

@ -1,3 +1,25 @@
Sat Oct 30 08:32:53 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
* symfile.c (reread_symbols): When re-reading symbols, do all the
right operations ourself, rather than calling symbol_file_command.
If we re-read something, call clear_symtab_users not just
breakpoint_re_set.
* objfiles.h, objfiles.c (build_objfile_section_table): No longer
static.
* symfile.c (clear_symtab_users): Call clear_pc_function_cache.
* coffread.c, dbxread.c, elfread.c, mipsread.c, nlmread.c, paread.c
(*_symfile_offsets): Set objfile->num_sections.
* remote.c (remote_wait), symfile.c (syms_from_objfile):
Don't muck with objfile->num_sections now that all the symbol
readers set it.
* elfread.c: Clean up obsolete comment about handling only DWARF.
* paread.c: Remove comment about how we should use an "ordinary"
file format with an hppa suffix. There is nothing ordinary about SOM.
* config/i386/{i386m3.mh,i386mk.mh}, config/mips/mipsm3.mh,
config/ns32k/ns32km3.mh: Change MMALLOC_LIB to MMALLOC.
* TODO: Update Mach stuff.
Fri Oct 29 16:30:36 1993 Stan Shebs (shebs@rtl.cygnus.com) Fri Oct 29 16:30:36 1993 Stan Shebs (shebs@rtl.cygnus.com)
LynxOS support: LynxOS support:

View file

@ -28,6 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "objfiles.h" #include "objfiles.h"
#include "buildsym.h" #include "buildsym.h"
#include "gdb-stabs.h" #include "gdb-stabs.h"
#include "stabsread.h"
#include "complaints.h" #include "complaints.h"
#include <obstack.h> #include <obstack.h>
@ -2045,10 +2046,11 @@ coff_symfile_offsets (objfile, addr)
struct section_offsets *section_offsets; struct section_offsets *section_offsets;
int i; int i;
objfile->num_sections = SECT_OFF_MAX;
section_offsets = (struct section_offsets *) section_offsets = (struct section_offsets *)
obstack_alloc (&objfile -> psymbol_obstack, obstack_alloc (&objfile -> psymbol_obstack,
sizeof (struct section_offsets) + sizeof (struct section_offsets)
sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1)); + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
for (i = 0; i < SECT_OFF_MAX; i++) for (i = 0; i < SECT_OFF_MAX; i++)
ANOFFSET (section_offsets, i) = addr; ANOFFSET (section_offsets, i) = addr;

View file

@ -212,9 +212,6 @@ free_header_files PARAMS ((void));
static void static void
init_header_files PARAMS ((void)); init_header_files PARAMS ((void));
static struct pending *
copy_pending PARAMS ((struct pending *, int, struct pending *));
static void static void
read_ofile_symtab PARAMS ((struct partial_symtab *)); read_ofile_symtab PARAMS ((struct partial_symtab *));
@ -1547,7 +1544,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
/* If this is nonzero, we've seen a non-gcc N_OPT symbol for this source /* If this is nonzero, we've seen a non-gcc N_OPT symbol for this source
file. Used to detect the SunPRO solaris compiler. */ file. Used to detect the SunPRO solaris compiler. */
int n_opt_found; static int n_opt_found;
/* The stab type used for the definition of the last function. /* The stab type used for the definition of the last function.
N_STSYM or N_GSYM for SunOS4 acc; N_FUN for other compilers. */ N_STSYM or N_GSYM for SunOS4 acc; N_FUN for other compilers. */
@ -1763,52 +1760,12 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
break; break;
case N_BCOMM: case N_BCOMM:
if (common_block) common_block_start (name, objfile);
{
/* Note: this does not detect nesting if the previous N_BCOMM
was at the beginning of a scope (and thus common_block was
NULL). Not necessarily worth worrying about unless we run
into a compiler which actually has this bug. */
static struct complaint msg = {
"Invalid symbol data: common within common at symtab pos %d",
0, 0};
complain (&msg, symnum);
}
common_block = local_symbols;
common_block_i = local_symbols ? local_symbols->nsyms : 0;
break; break;
case N_ECOMM: case N_ECOMM:
common_block_end (objfile);
/* Symbols declared since the BCOMM are to have the common block
start address added in when we know it. common_block and
common_block_i point to the first symbol after the BCOMM in
the local_symbols list; copy the list and hang it off the
symbol for the common block name for later fixup. */
/* If there is a N_ECOMM unmatched by a N_BCOMM, we treat all
the local_symbols as part of the common block. It might be
better to just ignore the N_ECOMM, but then we'd need to
distinguish between a N_BCOMM at the start of a scope, or no
N_BCOMM at all (currently they both have common_block NULL).
Not necessarily worth worrying about unless we run into a
compiler which actually has this bug. */
{
int i;
struct symbol *sym =
(struct symbol *) xmmalloc (objfile -> md, sizeof (struct symbol));
memset (sym, 0, sizeof *sym);
SYMBOL_NAME (sym) = savestring (name, strlen (name));
SYMBOL_CLASS (sym) = LOC_BLOCK;
SYMBOL_NAMESPACE (sym) = (enum namespace)((long)
copy_pending (local_symbols, common_block_i, common_block));
i = hashname (SYMBOL_NAME (sym));
SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
global_sym_chain[i] = sym;
common_block = 0;
break; break;
}
/* The following symbol types need to have the appropriate offset added /* The following symbol types need to have the appropriate offset added
to their value; then we process symbol definitions in the name. */ to their value; then we process symbol definitions in the name. */
@ -1816,28 +1773,23 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
case N_STSYM: /* Static symbol in data seg */ case N_STSYM: /* Static symbol in data seg */
case N_LCSYM: /* Static symbol in BSS seg */ case N_LCSYM: /* Static symbol in BSS seg */
case N_ROSYM: /* Static symbol in Read-only data seg */ case N_ROSYM: /* Static symbol in Read-only data seg */
/* HORRID HACK DEPT. However, it's Sun's furgin' fault. FIXME. /* HORRID HACK DEPT. However, it's Sun's furgin' fault.
Solaris2's stabs-in-coff makes *most* symbols relative Solaris2's stabs-in-elf makes *most* symbols relative
but leaves a few absolute. N_STSYM and friends sit on the fence. but leaves a few absolute (at least for Solaris 2.1 and version
2.0.1 of the SunPRO compiler). N_STSYM and friends sit on the fence.
.stab "foo:S...",N_STSYM is absolute (ld relocates it) .stab "foo:S...",N_STSYM is absolute (ld relocates it)
.stab "foo:V...",N_STSYM is relative (section base subtracted). .stab "foo:V...",N_STSYM is relative (section base subtracted).
This leaves us no choice but to search for the 'S' or 'V'... This leaves us no choice but to search for the 'S' or 'V'...
(or pass the whole section_offsets stuff down ONE MORE function (or pass the whole section_offsets stuff down ONE MORE function
call level, which we really don't want to do). call level, which we really don't want to do). */
The above is indeed true for Solaris 2.1. I'm not sure what
happens in Solaris 2.3, in which ld stops relocating stabs. */
{ {
char *p; char *p;
p = strchr (name, ':'); p = strchr (name, ':');
if (p != 0 && p[1] == 'S') if (p != 0 && p[1] == 'S')
{ {
/* FIXME! We relocate it by the TEXT offset, in case the /* The linker relocated it. There used to be a kludge here
whole module moved in memory. But this is wrong, since to add the text offset, but that will break if we ever
the sections can side around independently. (I suspect that start using the text offset (currently it is always zero). */
the text offset is always zero anyway--elfread.c doesn't
process (and Sun cc doesn't produce) Ttext.text symbols). */
valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
goto define_a_symbol; goto define_a_symbol;
} }
/* Since it's not the kludge case, re-dispatch to the right handler. */ /* Since it's not the kludge case, re-dispatch to the right handler. */
@ -2026,36 +1978,6 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
previous_stab_code = type; previous_stab_code = type;
} }
/* Copy a pending list, used to record the contents of a common
block for later fixup. We copy the symbols starting with all
symbols in BEG, and ending with the symbols which are in
END at index ENDI. */
static struct pending *
copy_pending (beg, endi, end)
struct pending *beg;
int endi;
struct pending *end;
{
struct pending *new = 0;
struct pending *next;
int j;
/* Copy all the struct pendings before end. */
for (next = beg; next != NULL && next != end; next = next->next)
{
for (j = 0; j < next->nsyms; j++)
add_symbol_to_list (next->symbol[j], &new);
}
/* Copy however much of END we need. If END is NULL, it means copy
all the local symbols (which we already did above). */
if (end != NULL)
for (j = endi; j < end->nsyms; j++)
add_symbol_to_list (end->symbol[j], &new);
return new;
}
/* FIXME: The only difference between this and elfstab_build_psymtabs is /* FIXME: The only difference between this and elfstab_build_psymtabs is
the call to install_minimal_symbols for elf. If the differences are the call to install_minimal_symbols for elf. If the differences are
really that small, the code should be shared. */ really that small, the code should be shared. */
@ -2254,10 +2176,11 @@ dbx_symfile_offsets (objfile, addr)
struct section_offsets *section_offsets; struct section_offsets *section_offsets;
int i; int i;
objfile->num_sections = SECT_OFF_MAX;
section_offsets = (struct section_offsets *) section_offsets = (struct section_offsets *)
obstack_alloc (&objfile -> psymbol_obstack, obstack_alloc (&objfile -> psymbol_obstack,
sizeof (struct section_offsets) + sizeof (struct section_offsets)
sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1)); + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
for (i = 0; i < SECT_OFF_MAX; i++) for (i = 0; i < SECT_OFF_MAX; i++)
ANOFFSET (section_offsets, i) = addr; ANOFFSET (section_offsets, i) = addr;

View file

@ -616,10 +616,11 @@ elf_symfile_offsets (objfile, addr)
struct section_offsets *section_offsets; struct section_offsets *section_offsets;
int i; int i;
objfile->num_sections = SECT_OFF_MAX;
section_offsets = (struct section_offsets *) section_offsets = (struct section_offsets *)
obstack_alloc (&objfile -> psymbol_obstack, obstack_alloc (&objfile -> psymbol_obstack,
sizeof (struct section_offsets) + sizeof (struct section_offsets)
sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1)); + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
for (i = 0; i < SECT_OFF_MAX; i++) for (i = 0; i < SECT_OFF_MAX; i++)
ANOFFSET (section_offsets, i) = addr; ANOFFSET (section_offsets, i) = addr;
@ -694,21 +695,7 @@ elfstab_offset_sections (objfile, pst)
complain (&stab_info_mismatch_complaint, filename); complain (&stab_info_mismatch_complaint, filename);
} }
/* Register that we are able to handle ELF object file formats and DWARF /* Register that we are able to handle ELF object file formats. */
debugging formats.
Unlike other object file formats, where the debugging information format
is implied by the object file format, the ELF object file format and the
DWARF debugging information format are two distinct, and potentially
separate entities. I.E. it is perfectly possible to have ELF objects
with debugging formats other than DWARF. And it is conceivable that the
DWARF debugging format might be used with another object file format,
like COFF, by simply using COFF's custom section feature.
GDB, and to a lesser extent BFD, should support the notion of separate
object file formats and debugging information formats. For now, we just
use "elf" in the same sense as "a.out" or "coff", to imply both the ELF
object file format and the DWARF debugging format. */
static struct sym_fns elf_sym_fns = static struct sym_fns elf_sym_fns =
{ {

View file

@ -183,9 +183,6 @@ struct complaint unknown_type_qual_complaint =
struct complaint array_index_type_complaint = struct complaint array_index_type_complaint =
{"illegal array index type for %s, assuming int", 0, 0}; {"illegal array index type for %s, assuming int", 0, 0};
struct complaint array_bitsize_complaint =
{"size of array target type for %s not known, assuming %d bits", 0, 0};
struct complaint bad_tag_guess_complaint = struct complaint bad_tag_guess_complaint =
{"guessed tag type of %s incorrectly", 0, 0}; {"guessed tag type of %s incorrectly", 0, 0};
@ -590,7 +587,15 @@ static struct parse_stack
struct parse_stack *next, *prev; struct parse_stack *next, *prev;
struct symtab *cur_st; /* Current symtab. */ struct symtab *cur_st; /* Current symtab. */
struct block *cur_block; /* Block in it. */ struct block *cur_block; /* Block in it. */
int blocktype; /* What are we parsing. */
/* What are we parsing. stFile, or stBlock are for files and
blocks. stProc or stStaticProc means we have seen the start of a
procedure, but not the start of the block within in. When we see
the start of that block, we change it to stNil, without pushing a
new block, i.e. stNil means both a procedure and a block. */
int blocktype;
int maxsyms; /* Max symbols in this block. */ int maxsyms; /* Max symbols in this block. */
struct type *cur_type; /* Type we parse fields for. */ struct type *cur_type; /* Type we parse fields for. */
int cur_field; /* Field number in cur_type. */ int cur_field; /* Field number in cur_type. */
@ -1134,6 +1139,17 @@ parse_symbol (sh, ax, ext_sh, bigend)
/* beginnning of (code) block. Value of symbol /* beginnning of (code) block. Value of symbol
is the displacement from procedure start */ is the displacement from procedure start */
push_parse_stack (); push_parse_stack ();
/* Do not start a new block if this is the outermost block of a
procedure. This allows the LOC_BLOCK symbol to point to the
block with the local variables, so funcname::var works. */
if (top_stack->blocktype == stProc
|| top_stack->blocktype == stStaticProc)
{
top_stack->blocktype = stNil;
break;
}
top_stack->blocktype = stBlock; top_stack->blocktype = stBlock;
b = new_block (top_stack->maxsyms); b = new_block (top_stack->maxsyms);
BLOCK_START (b) = sh->value + top_stack->procadr; BLOCK_START (b) = sh->value + top_stack->procadr;
@ -1197,6 +1213,12 @@ parse_symbol (sh, ax, ext_sh, bigend)
BLOCK_END (top_stack->cur_block) = sh->value + top_stack->procadr; BLOCK_END (top_stack->cur_block) = sh->value + top_stack->procadr;
shrink_block (top_stack->cur_block, top_stack->cur_st); shrink_block (top_stack->cur_block, top_stack->cur_st);
} }
else if (sh->sc == scText && top_stack->blocktype == stNil)
{
/* End of outermost block. Pop parse stack and ignore. The
following stEnd of stProc will take care of the block. */
;
}
else if (sh->sc == scText && top_stack->blocktype == stFile) else if (sh->sc == scText && top_stack->blocktype == stFile)
{ {
/* End of file. Pop parse stack and ignore. Higher /* End of file. Pop parse stack and ignore. Higher
@ -1676,20 +1698,19 @@ upgrade_type (fd, tpp, tq, ax, bigend, sym_name)
t = create_array_type ((struct type *) NULL, *tpp, range); t = create_array_type ((struct type *) NULL, *tpp, range);
/* Check whether supplied array element bit size matches /* We used to fill in the supplied array element bitsize
the known size of the element type. If this complaint here if the TYPE_LENGTH of the target type was zero.
ends up not happening, we can remove this code. It's This happens for a `pointer to an array of anonymous structs',
here because we aren't sure we understand this *&%&$ but in this case the array element bitsize is also zero,
symbol format. */ so nothing is gained.
id = TYPE_LENGTH (TYPE_TARGET_TYPE (t)) << 3; /* bitsize */ And we used to check the TYPE_LENGTH of the target type against
if (id == 0) the supplied array element bitsize.
{ gcc causes a mismatch for `pointer to array of object',
/* Most likely an undefined type */ since the sdb directives it uses do not have a way of
id = rf; specifying the bitsize, but it does no harm (the
TYPE_LENGTH (TYPE_TARGET_TYPE (t)) = id >> 3; TYPE_LENGTH should be correct) and we should be able to
} ignore the erroneous bitsize from the auxiliary entry safely.
if (id != rf) dbx seems to ignore it too. */
complain (&array_bitsize_complaint, sym_name, rf);
*tpp = t; *tpp = t;
return 4 + off; return 4 + off;
@ -3595,6 +3616,7 @@ mipscoff_symfile_offsets (objfile, addr)
struct section_offsets *section_offsets; struct section_offsets *section_offsets;
int i; int i;
objfile->num_sections = SECT_OFF_MAX;
section_offsets = ((struct section_offsets *) section_offsets = ((struct section_offsets *)
obstack_alloc (&objfile->psymbol_obstack, obstack_alloc (&objfile->psymbol_obstack,
(sizeof (struct section_offsets) (sizeof (struct section_offsets)

View file

@ -267,6 +267,7 @@ nlm_symfile_offsets (objfile, addr)
struct section_offsets *section_offsets; struct section_offsets *section_offsets;
int i; int i;
objfile->num_sections = SECT_OFF_MAX;
section_offsets = (struct section_offsets *) section_offsets = (struct section_offsets *)
obstack_alloc (&objfile -> psymbol_obstack, obstack_alloc (&objfile -> psymbol_obstack,
sizeof (struct section_offsets) + sizeof (struct section_offsets) +

View file

@ -92,9 +92,10 @@ add_to_objfile_sections (abfd, asect, objfile_p_char)
} }
/* Builds a section table for OBJFILE. /* Builds a section table for OBJFILE.
Returns 0 if OK, 1 on error. */ Returns 0 if OK, 1 on error (in which case bfd_error contains the
error). */
static int int
build_objfile_section_table (objfile) build_objfile_section_table (objfile)
struct objfile *objfile; struct objfile *objfile;
{ {
@ -356,6 +357,8 @@ free_objfile (objfile)
(t->to_detach) (NULL, 0); (t->to_detach) (NULL, 0);
} }
#endif #endif
/* I *think* all our callers call clear_symtab_users. If so, no need
to call this here. */
clear_pc_function_cache (); clear_pc_function_cache ();
/* The last thing we do is free the objfile struct itself for the /* The last thing we do is free the objfile struct itself for the

View file

@ -357,14 +357,13 @@ extern struct objfile *object_files;
/* Declarations for functions defined in objfiles.c */ /* Declarations for functions defined in objfiles.c */
extern struct objfile * extern struct objfile *allocate_objfile PARAMS ((bfd *, int));
allocate_objfile PARAMS ((bfd *, int));
extern void int build_objfile_section_table PARAMS ((struct objfile *));
unlink_objfile PARAMS ((struct objfile *));
extern void extern void unlink_objfile PARAMS ((struct objfile *));
free_objfile PARAMS ((struct objfile *));
extern void free_objfile PARAMS ((struct objfile *));
extern void extern void
free_all_objfiles PARAMS ((void)); free_all_objfiles PARAMS ((void));

View file

@ -488,10 +488,11 @@ pa_symfile_offsets (objfile, addr)
struct section_offsets *section_offsets; struct section_offsets *section_offsets;
int i; int i;
objfile->num_sections = SECT_OFF_MAX;
section_offsets = (struct section_offsets *) section_offsets = (struct section_offsets *)
obstack_alloc (&objfile -> psymbol_obstack, obstack_alloc (&objfile -> psymbol_obstack,
sizeof (struct section_offsets) + sizeof (struct section_offsets)
sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1)); + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
for (i = 0; i < SECT_OFF_MAX; i++) for (i = 0; i < SECT_OFF_MAX; i++)
ANOFFSET (section_offsets, i) = addr; ANOFFSET (section_offsets, i) = addr;
@ -499,10 +500,9 @@ pa_symfile_offsets (objfile, addr)
return section_offsets; return section_offsets;
} }
/* Register that we are able to handle PA object file formats. */ /* Register that we are able to handle SOM object file formats (does this
work for hp300, or just PA? I suspect the latter). */
/* This is probably a mistake. FIXME. Why can't the HP's use an ordinary
file format name with an -hppa suffix? */
static struct sym_fns pa_sym_fns = static struct sym_fns pa_sym_fns =
{ {
"som", /* sym_name: name or name prefix of BFD target type */ "som", /* sym_name: name or name prefix of BFD target type */

View file

@ -228,7 +228,12 @@ int icache;
starts. */ starts. */
serial_t remote_desc = NULL; serial_t remote_desc = NULL;
#define PBUFSIZ 1024 /* Having this larger than 400 causes us to be incompatible with m68k-stub.c
and i386-stub.c. Normally, no one would notice because it only matters
for writing large chunks of memory (e.g. in downloads). Also, this needs
to be more than 400 if required to hold the registers (see below, where
we round it up based on REGISTER_BYTES). */
#define PBUFSIZ 400
/* Maximum number of bytes to read/write at once. The value here /* Maximum number of bytes to read/write at once. The value here
is chosen to fill up a packet (the headers account for the 32). */ is chosen to fill up a packet (the headers account for the 32). */
@ -560,12 +565,6 @@ remote_wait (pid, status)
stuff. (Just what does "text" as seen by the stub stuff. (Just what does "text" as seen by the stub
mean, anyway?). */ mean, anyway?). */
/* FIXME: Why don't the various symfile_offsets routines
in the sym_fns vectors set this?
(no good reason -kingdon). */
if (symfile_objfile->num_sections == 0)
symfile_objfile->num_sections = SECT_OFF_MAX;
offs = ((struct section_offsets *) offs = ((struct section_offsets *)
alloca (sizeof (struct section_offsets) alloca (sizeof (struct section_offsets)
+ (symfile_objfile->num_sections + (symfile_objfile->num_sections
@ -798,9 +797,6 @@ remote_write_bytes (memaddr, myaddr, len)
int i; int i;
char *p; char *p;
if (len > PBUFSIZ / 2 - 20)
abort ();
sprintf (buf, "M%x,%x:", memaddr, len); sprintf (buf, "M%x,%x:", memaddr, len);
/* We send target system values byte by byte, in increasing byte addresses, /* We send target system values byte by byte, in increasing byte addresses,

View file

@ -32,6 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "language.h" #include "language.h"
#include "complaints.h" #include "complaints.h"
#include "demangle.h" #include "demangle.h"
#include "inferior.h" /* for write_pc */
#include <obstack.h> #include <obstack.h>
#include <assert.h> #include <assert.h>
@ -214,21 +215,6 @@ sort_symtab_syms (s)
} }
} }
void
sort_all_symtab_syms ()
{
register struct symtab *s;
register struct objfile *objfile;
for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
{
for (s = objfile -> symtabs; s != NULL; s = s -> next)
{
sort_symtab_syms (s);
}
}
}
/* Make a copy of the string at PTR with SIZE characters in the symbol obstack /* 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). (and add a null character at the end in the copy).
Returns the address of the copy. */ Returns the address of the copy. */
@ -317,6 +303,14 @@ init_entry_point_info (objfile)
} }
} }
/* Get current entry point address. */
CORE_ADDR
entry_point_address()
{
return symfile_objfile ? symfile_objfile->ei.entry_point : 0;
}
/* Remember the lowest-addressed loadable section we've seen. /* Remember the lowest-addressed loadable section we've seen.
This function is called via bfd_map_over_sections. */ This function is called via bfd_map_over_sections. */
@ -410,10 +404,10 @@ syms_from_objfile (objfile, addr, mainline, verbo)
else if (0 == bfd_get_section_name (objfile->obfd, lowest_sect) else if (0 == bfd_get_section_name (objfile->obfd, lowest_sect)
|| !STREQ (".text", || !STREQ (".text",
bfd_get_section_name (objfile->obfd, lowest_sect))) bfd_get_section_name (objfile->obfd, lowest_sect)))
warning ("Lowest section in %s is %s at 0x%x", warning ("Lowest section in %s is %s at 0x%lx",
objfile->name, objfile->name,
bfd_section_name (objfile->obfd, lowest_sect), bfd_section_name (objfile->obfd, lowest_sect),
bfd_section_vma (objfile->obfd, lowest_sect)); (unsigned long) bfd_section_vma (objfile->obfd, lowest_sect));
if (lowest_sect) if (lowest_sect)
addr -= bfd_section_vma (objfile->obfd, lowest_sect); addr -= bfd_section_vma (objfile->obfd, lowest_sect);
@ -426,9 +420,6 @@ syms_from_objfile (objfile, addr, mainline, verbo)
(*objfile -> sf -> sym_init) (objfile); (*objfile -> sf -> sym_init) (objfile);
clear_complaints (1, verbo); clear_complaints (1, verbo);
/* If objfile->sf->sym_offsets doesn't set this, we don't care
(currently). */
objfile->num_sections = 0; /* krp-FIXME: why zero? */
section_offsets = (*objfile -> sf -> sym_offsets) (objfile, addr); section_offsets = (*objfile -> sf -> sym_offsets) (objfile, addr);
objfile->section_offsets = section_offsets; objfile->section_offsets = section_offsets;
@ -468,8 +459,10 @@ syms_from_objfile (objfile, addr, mainline, verbo)
(*objfile -> sf -> sym_read) (objfile, section_offsets, mainline); (*objfile -> sf -> sym_read) (objfile, section_offsets, mainline);
/* Don't allow char * to have a typename (else would get caddr_t.) */ /* Don't allow char * to have a typename (else would get caddr_t).
/* Ditto void *. FIXME should do this for all the builtin types. */ Ditto void *. FIXME: Check whether this is now done by all the
symbol readers themselves (many of them now do), and if so remove
it from here. */
TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0; TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0;
TYPE_NAME (lookup_pointer_type (builtin_type_void)) = 0; TYPE_NAME (lookup_pointer_type (builtin_type_void)) = 0;
@ -871,9 +864,9 @@ generic_load (filename, from_tty)
/* Is this really necessary? I guess it gives the user something /* Is this really necessary? I guess it gives the user something
to look at during a long download. */ to look at during a long download. */
printf_filtered ("Loading section %s, size 0x%x vma 0x%x\n", printf_filtered ("Loading section %s, size 0x%lx vma 0x%lx\n",
bfd_get_section_name (loadfile_bfd, s), bfd_get_section_name (loadfile_bfd, s),
size, vma); (unsigned long) size, (unsigned long) vma);
bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size); bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size);
@ -967,7 +960,7 @@ add_symbol_file_command (args, from_tty)
text_addr = parse_and_eval_address (args); text_addr = parse_and_eval_address (args);
if (!query ("add symbol table from file \"%s\" at text_addr = %s?\n", if (!query ("add symbol table from file \"%s\" at text_addr = %s?\n",
name, local_hex_string (text_addr))) name, local_hex_string ((unsigned long)text_addr)))
error ("Not confirmed."); error ("Not confirmed.");
symbol_file_add (name, 0, text_addr, 0, mapped, readnow); symbol_file_add (name, 0, text_addr, 0, mapped, readnow);
@ -989,7 +982,6 @@ reread_symbols ()
This routine should then walk down each partial symbol table This routine should then walk down each partial symbol table
and see if the symbol table that it originates from has been changed */ and see if the symbol table that it originates from has been changed */
the_big_top:
for (objfile = object_files; objfile; objfile = objfile->next) { for (objfile = object_files; objfile; objfile = objfile->next) {
if (objfile->obfd) { if (objfile->obfd) {
#ifdef IBM6000_TARGET #ifdef IBM6000_TARGET
@ -1008,24 +1000,142 @@ the_big_top:
continue; continue;
} }
new_modtime = new_statbuf.st_mtime; new_modtime = new_statbuf.st_mtime;
if (new_modtime != objfile->mtime) { if (new_modtime != objfile->mtime)
{
struct cleanup *old_cleanups;
struct section_offsets *offsets;
int num_offsets;
int section_offsets_size;
printf_filtered ("`%s' has changed; re-reading symbols.\n", printf_filtered ("`%s' has changed; re-reading symbols.\n",
objfile->name); objfile->name);
/* FIXME, this should use a different command...that would only
affect this objfile's symbols, and would reset objfile->mtime. /* There are various functions like symbol_file_add,
(objfile->mtime = new_modtime;) symfile_bfd_open, syms_from_objfile, etc., which might
HOWEVER, that command isn't written yet -- so call symbol_file_ appear to do what we want. But they have various other
command, and restart the scan from the top, because it munges effects which we *don't* want. So we just do stuff
the object_files list. */ ourselves. We don't worry about mapped files (for one thing,
symbol_file_command (objfile->name, 0); any mapped file will be out of date). */
/* If we get an error, blow away this objfile (not sure if
that is the correct response for things like shared
libraries). */
old_cleanups = make_cleanup (free_objfile, objfile);
/* We need to do this whenever any symbols go away. */
make_cleanup (clear_symtab_users, 0);
/* Clean up any state BFD has sitting around. We don't need
to close the descriptor but BFD lacks a way of closing the
BFD without closing the descriptor. */
if (!bfd_close (objfile->obfd))
error ("Can't close BFD for %s.", objfile->name);
objfile->obfd = bfd_openr (objfile->name, gnutarget);
if (objfile->obfd == NULL)
error ("Can't open %s to read symbols.", objfile->name);
/* bfd_openr sets cacheable to true, which is what we want. */
if (!bfd_check_format (objfile->obfd, bfd_object))
error ("Can't read symbols from %s: %s.", objfile->name,
bfd_errmsg (bfd_error));
/* Save the offsets, we will nuke them with the rest of the
psymbol_obstack. */
num_offsets = objfile->num_sections;
section_offsets_size =
sizeof (struct section_offsets)
+ sizeof (objfile->section_offsets->offsets) * num_offsets;
offsets = (struct section_offsets *) alloca (section_offsets_size);
memcpy (offsets, objfile->section_offsets, section_offsets_size);
/* Nuke all the state that we will re-read. Much of the following
code which sets things to NULL really is necessary to tell
other parts of GDB that there is nothing currently there. */
/* FIXME: Do we have to free a whole linked list, or is this
enough? */
if (objfile->global_psymbols.list)
mfree (objfile->md, objfile->global_psymbols.list);
objfile->global_psymbols.list = NULL;
objfile->global_psymbols.size = 0;
if (objfile->static_psymbols.list)
mfree (objfile->md, objfile->static_psymbols.list);
objfile->static_psymbols.list = NULL;
objfile->static_psymbols.size = 0;
/* Free the obstacks for non-reusable objfiles */
obstack_free (&objfile -> psymbol_obstack, 0);
obstack_free (&objfile -> symbol_obstack, 0);
obstack_free (&objfile -> type_obstack, 0);
objfile->sections = NULL;
objfile->symtabs = NULL;
objfile->psymtabs = NULL;
objfile->free_psymtabs = NULL;
objfile->msymbols = NULL;
objfile->minimal_symbol_count= 0;
objfile->fundamental_types = NULL;
if (objfile -> sf != NULL)
{
(*objfile -> sf -> sym_finish) (objfile);
}
/* We never make this a mapped file. */
objfile -> md = NULL;
/* obstack_specify_allocation also initializes the obstack so
it is empty. */
obstack_specify_allocation (&objfile -> psymbol_obstack, 0, 0,
xmalloc, free);
obstack_specify_allocation (&objfile -> symbol_obstack, 0, 0,
xmalloc, free);
obstack_specify_allocation (&objfile -> type_obstack, 0, 0,
xmalloc, free);
if (build_objfile_section_table (objfile))
{
error ("Can't find the file sections in `%s': %s",
objfile -> name, bfd_errmsg (bfd_error));
}
/* We use the same section offsets as from last time. I'm not
sure whether that is always correct for shared libraries. */
objfile->section_offsets = (struct section_offsets *)
obstack_alloc (&objfile -> psymbol_obstack, section_offsets_size);
memcpy (objfile->section_offsets, offsets, section_offsets_size);
objfile->num_sections = num_offsets;
/* What the hell is sym_new_init for, anyway? The concept of
distinguishing between the main file and additional files
in this way seems rather dubious. */
if (objfile == symfile_objfile)
(*objfile->sf->sym_new_init) (objfile);
(*objfile->sf->sym_init) (objfile);
clear_complaints (1, 1);
/* The "mainline" parameter is a hideous hack; I think leaving it
zero is OK since dbxread.c also does what it needs to do if
objfile->global_psymbols.size is 0. */
(*objfile->sf->sym_read) (objfile, objfile->section_offsets, 0);
objfile -> flags |= OBJF_SYMS;
/* We're done reading the symbol file; finish off complaints. */
clear_complaints (0, 1);
/* Getting new symbols may change our opinion about what is
frameless. */
reinit_frame_cache ();
/* Discard cleanups as symbol reading was successful. */
discard_cleanups (old_cleanups);
/* If the mtime has changed between the time we set new_modtime
and now, we *want* this to be out of date, so don't call stat
again now. */
objfile->mtime = new_modtime;
reread_one = 1; reread_one = 1;
goto the_big_top; /* Start over. */
} }
} }
} }
if (reread_one) if (reread_one)
breakpoint_re_set (); clear_symtab_users ();
} }
@ -1043,7 +1153,7 @@ deduce_language_from_filename (filename)
return language_m2; return language_m2;
else if (STREQ(c,".c")) else if (STREQ(c,".c"))
return language_c; return language_c;
else if(STREQ(c,".cc") || STREQ(c,".C")) else if (STREQ (c,".cc") || STREQ (c,".C") || STREQ (c, ".cxx"))
return language_cplus; return language_cplus;
else if (STREQ (c,".ch") || STREQ (c,".c186") || STREQ (c,".c286")) else if (STREQ (c,".ch") || STREQ (c,".c186") || STREQ (c,".c286"))
return language_chill; return language_chill;
@ -1141,6 +1251,7 @@ clear_symtab_users ()
set_default_breakpoint (0, 0, 0, 0); set_default_breakpoint (0, 0, 0, 0);
current_source_symtab = 0; current_source_symtab = 0;
current_source_line = 0; current_source_line = 0;
clear_pc_function_cache ();
} }
/* clear_symtab_users_once: /* clear_symtab_users_once: