2009-06-16 Paul Pluzhnikov <ppluzhnikov@google.com>

* solib.c (symbol_add_stub): New FLAGS parameter.
	(solib_read_symbols): FROM_TTY -> FLAGS, call symbol_add_stub
	directly.
	(solib_add): Defer breakpoint_re_set until after all solibs.
	* bsd-uthread.c (bsd_uthread_solib_loaded): Adjust.
	* rs6000-nat.c (objfile_symbol_add): Adjust.
	* symfile.c (syms_from_objfile): Merge parameters into ADD_FLAGS.
	(new_symfile_objfile): Likewise.
	(symbol_file_add_with_addrs_or_offsets): Likewise.
	(symbol_file_add_from_bfd): Likewise.
	(symbol_file_add): Likewise.
	* symfile.h (enum symfile_add_flags): New. Adjust prototypes.
	* symfile-mem.c (symbol_file_add_from_memory): Adjust.
	* windows-nat.c (safe_symbol_file_add_stub): Adjust.
	* machoread.c (macho_oso_symfile, macho_symfile_read): Adjust.
This commit is contained in:
Paul Pluzhnikov 2009-06-16 18:49:25 +00:00
parent 19ef5c713c
commit 7eedccfa2a
10 changed files with 120 additions and 76 deletions

View File

@ -1,3 +1,21 @@
2009-06-16 Paul Pluzhnikov <ppluzhnikov@google.com>
* solib.c (symbol_add_stub): New FLAGS parameter.
(solib_read_symbols): FROM_TTY -> FLAGS, call symbol_add_stub
directly.
(solib_add): Defer breakpoint_re_set until after all solibs.
* bsd-uthread.c (bsd_uthread_solib_loaded): Adjust.
* rs6000-nat.c (objfile_symbol_add): Adjust.
* symfile.c (syms_from_objfile): Merge parameters into ADD_FLAGS.
(new_symfile_objfile): Likewise.
(symbol_file_add_with_addrs_or_offsets): Likewise.
(symbol_file_add_from_bfd): Likewise.
(symbol_file_add): Likewise.
* symfile.h (enum symfile_add_flags): New. Adjust prototypes.
* symfile-mem.c (symbol_file_add_from_memory): Adjust.
* windows-nat.c (safe_symbol_file_add_stub): Adjust.
* machoread.c (macho_oso_symfile, macho_symfile_read): Adjust.
2009-06-16 Keith Seitz <keiths@redhat.com> 2009-06-16 Keith Seitz <keiths@redhat.com>
* linespec.c (collect_methods): Delete. * linespec.c (collect_methods): Delete.

View File

@ -248,7 +248,7 @@ bsd_uthread_solib_loaded (struct so_list *so)
{ {
if (strncmp (so->so_original_name, *names, strlen (*names)) == 0) if (strncmp (so->so_original_name, *names, strlen (*names)) == 0)
{ {
solib_read_symbols (so, so->from_tty); solib_read_symbols (so, so->from_tty ? SYMFILE_VERBOSE : 0);
if (bsd_uthread_activate (so->objfile)) if (bsd_uthread_activate (so->objfile))
{ {

View File

@ -406,7 +406,7 @@ macho_oso_symfile (struct objfile *main_objfile)
bfd_close (member_bfd); bfd_close (member_bfd);
} }
else else
symbol_file_add_from_bfd (member_bfd, 0, addrs, 0, 0); symbol_file_add_from_bfd (member_bfd, 0, addrs, 0);
} }
else else
{ {
@ -429,7 +429,7 @@ macho_oso_symfile (struct objfile *main_objfile)
continue; continue;
} }
symbol_file_add_from_bfd (abfd, 0, addrs, 0, 0); symbol_file_add_from_bfd (abfd, 0, addrs, 0);
} }
xfree (oso->symbols); xfree (oso->symbols);
xfree (oso->offsets); xfree (oso->offsets);
@ -592,7 +592,7 @@ macho_symfile_read (struct objfile *objfile, int mainline)
oso_vector = NULL; oso_vector = NULL;
/* Now recurse: read dwarf from dsym. */ /* Now recurse: read dwarf from dsym. */
symbol_file_add_from_bfd (dsym_bfd, 0, NULL, 0, 0); symbol_file_add_from_bfd (dsym_bfd, 0, NULL, 0);
/* Don't try to read dwarf2 from main file or shared libraries. */ /* Don't try to read dwarf2 from main file or shared libraries. */
return; return;

View File

@ -691,8 +691,8 @@ objfile_symbol_add (void *arg)
{ {
struct objfile *obj = (struct objfile *) arg; struct objfile *obj = (struct objfile *) arg;
syms_from_objfile (obj, NULL, 0, 0, 0, 0); syms_from_objfile (obj, NULL, 0, 0, 0);
new_symfile_objfile (obj, 0, 0); new_symfile_objfile (obj, 0);
return 1; return 1;
} }

View File

@ -448,39 +448,37 @@ master_so_list (void)
return so_list_head; return so_list_head;
} }
static void
/* A small stub to get us past the arg-passing pinhole of catch_errors. */ symbol_add_stub (struct so_list *so, int flags)
static int
symbol_add_stub (void *arg)
{ {
struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
struct section_addr_info *sap; struct section_addr_info *sap;
/* Have we already loaded this shared object? */ /* Have we already loaded this shared object? */
ALL_OBJFILES (so->objfile) ALL_OBJFILES (so->objfile)
{ {
if (strcmp (so->objfile->name, so->so_name) == 0) if (strcmp (so->objfile->name, so->so_name) == 0)
return 1; return;
} }
sap = build_section_addr_info_from_section_table (so->sections, sap = build_section_addr_info_from_section_table (so->sections,
so->sections_end); so->sections_end);
so->objfile = symbol_file_add_from_bfd (so->abfd, so->from_tty, so->objfile = symbol_file_add_from_bfd (so->abfd, flags,
sap, 0, OBJF_SHARED | OBJF_KEEPBFD); sap, OBJF_SHARED | OBJF_KEEPBFD);
free_section_addr_info (sap); free_section_addr_info (sap);
return (1); return;
} }
/* Read in symbols for shared object SO. If FROM_TTY is non-zero, be /* Read in symbols for shared object SO. If SYMFILE_VERBOSE is set in FLAGS,
chatty about it. Return non-zero if any symbols were actually be chatty about it. Return non-zero if any symbols were actually
loaded. */ loaded. */
int int
solib_read_symbols (struct so_list *so, int from_tty) solib_read_symbols (struct so_list *so, int flags)
{ {
const int from_tty = flags & SYMFILE_VERBOSE;
if (so->symbols_loaded) if (so->symbols_loaded)
{ {
if (from_tty) if (from_tty)
@ -493,15 +491,21 @@ solib_read_symbols (struct so_list *so, int from_tty)
} }
else else
{ {
if (catch_errors (symbol_add_stub, so, volatile struct gdb_exception exception;
"Error while reading shared library symbols:\n", TRY_CATCH (exception, RETURN_MASK_ALL)
RETURN_MASK_ALL)) {
{ symbol_add_stub (so, flags);
if (from_tty && print_symbol_loading) }
printf_unfiltered (_("Loaded symbols for %s\n"), so->so_name); if (exception.reason != 0)
so->symbols_loaded = 1; {
return 1; exception_fprintf (gdb_stderr, exception,
} "Error while reading shared library symbols:\n");
return 0;
}
if (from_tty && print_symbol_loading)
printf_unfiltered (_("Loaded symbols for %s\n"), so->so_name);
so->symbols_loaded = 1;
return 1;
} }
return 0; return 0;
@ -736,6 +740,8 @@ solib_add (char *pattern, int from_tty, struct target_ops *target, int readsyms)
{ {
int any_matches = 0; int any_matches = 0;
int loaded_any_symbols = 0; int loaded_any_symbols = 0;
const int flags =
SYMFILE_DEFER_BP_RESET | (from_tty ? SYMFILE_VERBOSE : 0);
for (gdb = so_list_head; gdb; gdb = gdb->next) for (gdb = so_list_head; gdb; gdb = gdb->next)
if (! pattern || re_exec (gdb->so_name)) if (! pattern || re_exec (gdb->so_name))
@ -749,10 +755,13 @@ solib_add (char *pattern, int from_tty, struct target_ops *target, int readsyms)
(readsyms || libpthread_solib_p (gdb)); (readsyms || libpthread_solib_p (gdb));
any_matches = 1; any_matches = 1;
if (add_this_solib && solib_read_symbols (gdb, from_tty)) if (add_this_solib && solib_read_symbols (gdb, flags))
loaded_any_symbols = 1; loaded_any_symbols = 1;
} }
if (loaded_any_symbols)
breakpoint_re_set ();
if (from_tty && pattern && ! any_matches) if (from_tty && pattern && ! any_matches)
printf_unfiltered printf_unfiltered
("No loaded shared libraries match the pattern `%s'.\n", pattern); ("No loaded shared libraries match the pattern `%s'.\n", pattern);

View File

@ -372,7 +372,8 @@ spu_symbol_file_add_from_memory (int inferior_fd)
/* Open BFD representing SPE executable and read its symbols. */ /* Open BFD representing SPE executable and read its symbols. */
nbfd = spu_bfd_open (addr); nbfd = spu_bfd_open (addr);
if (nbfd) if (nbfd)
symbol_file_add_from_bfd (nbfd, 1, NULL, 1, 0); symbol_file_add_from_bfd (nbfd, SYMFILE_VERBOSE | SYMFILE_MAINLINE,
NULL, 0);
} }
@ -600,4 +601,3 @@ _initialize_spu_nat (void)
/* Register SPU target. */ /* Register SPU target. */
add_target (t); add_target (t);
} }

View File

@ -107,8 +107,8 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
++i; ++i;
} }
objf = symbol_file_add_from_bfd (nbfd, from_tty, objf = symbol_file_add_from_bfd (nbfd, from_tty ? SYMFILE_VERBOSE : 0,
sai, 0, OBJF_SHARED); sai, OBJF_SHARED);
/* This might change our ideas about frames already looked at. */ /* This might change our ideas about frames already looked at. */
reinit_frame_cache (); reinit_frame_cache ();

View File

@ -740,22 +740,20 @@ default_symfile_segments (bfd *abfd)
list any more; all we have is the section offset table.) If list any more; all we have is the section offset table.) If
OFFSETS is non-zero, ADDRS must be zero. OFFSETS is non-zero, ADDRS must be zero.
MAINLINE is nonzero if this is the main symbol file, or zero if ADD_FLAGS encodes verbosity level, whether this is main symbol or
it's an extra symbol file such as dynamically loaded code. an extra symbol file such as dynamically loaded code, and wether
breakpoint reset should be deferred. */
VERBO is nonzero if the caller has printed a verbose message about
the symbol reading (and complaints can be more terse about it). */
void void
syms_from_objfile (struct objfile *objfile, syms_from_objfile (struct objfile *objfile,
struct section_addr_info *addrs, struct section_addr_info *addrs,
struct section_offsets *offsets, struct section_offsets *offsets,
int num_offsets, int num_offsets,
int mainline, int add_flags)
int verbo)
{ {
struct section_addr_info *local_addr = NULL; struct section_addr_info *local_addr = NULL;
struct cleanup *old_chain; struct cleanup *old_chain;
const int mainline = add_flags & SYMFILE_MAINLINE;
gdb_assert (! (addrs && offsets)); gdb_assert (! (addrs && offsets));
@ -875,7 +873,7 @@ syms_from_objfile (struct objfile *objfile,
initial symbol reading for this file. */ initial symbol reading for this file. */
(*objfile->sf->sym_init) (objfile); (*objfile->sf->sym_init) (objfile);
clear_complaints (&symfile_complaints, 1, verbo); clear_complaints (&symfile_complaints, 1, add_flags & SYMFILE_VERBOSE);
if (addrs) if (addrs)
(*objfile->sf->sym_offsets) (objfile, addrs); (*objfile->sf->sym_offsets) (objfile, addrs);
@ -906,26 +904,26 @@ syms_from_objfile (struct objfile *objfile,
objfile. */ objfile. */
void void
new_symfile_objfile (struct objfile *objfile, int mainline, int verbo) new_symfile_objfile (struct objfile *objfile, int add_flags)
{ {
/* If this is the main symbol file we have to clean up all users of the /* If this is the main symbol file we have to clean up all users of the
old main symbol file. Otherwise it is sufficient to fixup all the old main symbol file. Otherwise it is sufficient to fixup all the
breakpoints that may have been redefined by this symbol file. */ breakpoints that may have been redefined by this symbol file. */
if (mainline) if (add_flags & SYMFILE_MAINLINE)
{ {
/* OK, make it the "real" symbol file. */ /* OK, make it the "real" symbol file. */
symfile_objfile = objfile; symfile_objfile = objfile;
clear_symtab_users (); clear_symtab_users ();
} }
else else if ((add_flags & SYMFILE_DEFER_BP_RESET) == 0)
{ {
breakpoint_re_set_objfile (objfile); breakpoint_re_set_objfile (objfile);
} }
/* We're done reading the symbol file; finish off complaints. */ /* We're done reading the symbol file; finish off complaints. */
clear_complaints (&symfile_complaints, 0, verbo); clear_complaints (&symfile_complaints, 0, add_flags & SYMFILE_VERBOSE);
} }
/* Process a symbol file, as either the main file or as a dynamically /* Process a symbol file, as either the main file or as a dynamically
@ -934,23 +932,23 @@ new_symfile_objfile (struct objfile *objfile, int mainline, int verbo)
ABFD is a BFD already open on the file, as from symfile_bfd_open. ABFD is a BFD already open on the file, as from symfile_bfd_open.
This BFD will be closed on error, and is always consumed by this function. This BFD will be closed on error, and is always consumed by this function.
FROM_TTY says how verbose to be. ADD_FLAGS encodes verbosity, whether this is main symbol file or
extra, such as dynamically loaded code, and what to do with breakpoins.
MAINLINE specifies whether this is the main symbol file, or whether
it's an extra symbol file such as dynamically loaded code.
ADDRS, OFFSETS, and NUM_OFFSETS are as described for ADDRS, OFFSETS, and NUM_OFFSETS are as described for
syms_from_objfile, above. ADDRS is ignored when MAINLINE is syms_from_objfile, above.
non-zero. ADDRS is ignored when SYMFILE_MAINLINE bit is set in ADD_FLAGS.
Upon success, returns a pointer to the objfile that was added. Upon success, returns a pointer to the objfile that was added.
Upon failure, jumps back to command level (never returns). */ Upon failure, jumps back to command level (never returns). */
static struct objfile * static struct objfile *
symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty, symbol_file_add_with_addrs_or_offsets (bfd *abfd,
int add_flags,
struct section_addr_info *addrs, struct section_addr_info *addrs,
struct section_offsets *offsets, struct section_offsets *offsets,
int num_offsets, int num_offsets,
int mainline, int flags) int flags)
{ {
struct objfile *objfile; struct objfile *objfile;
struct partial_symtab *psymtab; struct partial_symtab *psymtab;
@ -958,6 +956,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
struct section_addr_info *orig_addrs = NULL; struct section_addr_info *orig_addrs = NULL;
struct cleanup *my_cleanups; struct cleanup *my_cleanups;
const char *name = bfd_get_filename (abfd); const char *name = bfd_get_filename (abfd);
const int from_tty = add_flags & SYMFILE_VERBOSE;
my_cleanups = make_cleanup_bfd_close (abfd); my_cleanups = make_cleanup_bfd_close (abfd);
@ -965,7 +964,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
interactively wiping out any existing symbols. */ interactively wiping out any existing symbols. */
if ((have_full_symbols () || have_partial_symbols ()) if ((have_full_symbols () || have_partial_symbols ())
&& mainline && (add_flags & SYMFILE_MAINLINE)
&& from_tty && from_tty
&& !query (_("Load new symbol table from \"%s\"? "), name)) && !query (_("Load new symbol table from \"%s\"? "), name))
error (_("Not confirmed.")); error (_("Not confirmed."));
@ -997,7 +996,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
} }
} }
syms_from_objfile (objfile, addrs, offsets, num_offsets, syms_from_objfile (objfile, addrs, offsets, num_offsets,
mainline, from_tty); add_flags);
/* We now have at least a partial symbol table. Check to see if the /* We now have at least a partial symbol table. Check to see if the
user requested that all symbols be read on initial access via either user requested that all symbols be read on initial access via either
@ -1031,12 +1030,12 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
if (addrs != NULL) if (addrs != NULL)
{ {
objfile->separate_debug_objfile objfile->separate_debug_objfile
= symbol_file_add (debugfile, from_tty, orig_addrs, 0, flags); = symbol_file_add (debugfile, add_flags, orig_addrs, flags);
} }
else else
{ {
objfile->separate_debug_objfile objfile->separate_debug_objfile
= symbol_file_add (debugfile, from_tty, NULL, 0, flags); = symbol_file_add (debugfile, add_flags, NULL, flags);
} }
objfile->separate_debug_objfile->separate_debug_objfile_backlink objfile->separate_debug_objfile->separate_debug_objfile_backlink
= objfile; = objfile;
@ -1081,7 +1080,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
if (objfile->sf == NULL) if (objfile->sf == NULL)
return objfile; /* No symbols. */ return objfile; /* No symbols. */
new_symfile_objfile (objfile, mainline, from_tty); new_symfile_objfile (objfile, add_flags);
observer_notify_new_objfile (objfile); observer_notify_new_objfile (objfile);
@ -1096,13 +1095,12 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
See symbol_file_add_with_addrs_or_offsets's comments for See symbol_file_add_with_addrs_or_offsets's comments for
details. */ details. */
struct objfile * struct objfile *
symbol_file_add_from_bfd (bfd *abfd, int from_tty, symbol_file_add_from_bfd (bfd *abfd, int add_flags,
struct section_addr_info *addrs, struct section_addr_info *addrs,
int mainline, int flags) int flags)
{ {
return symbol_file_add_with_addrs_or_offsets (abfd, return symbol_file_add_with_addrs_or_offsets (abfd, add_flags, addrs, 0, 0,
from_tty, addrs, 0, 0, flags);
mainline, flags);
} }
@ -1110,11 +1108,11 @@ symbol_file_add_from_bfd (bfd *abfd, int from_tty,
loaded file. See symbol_file_add_with_addrs_or_offsets's comments loaded file. See symbol_file_add_with_addrs_or_offsets's comments
for details. */ for details. */
struct objfile * struct objfile *
symbol_file_add (char *name, int from_tty, struct section_addr_info *addrs, symbol_file_add (char *name, int add_flags, struct section_addr_info *addrs,
int mainline, int flags) int flags)
{ {
return symbol_file_add_from_bfd (symfile_bfd_open (name), from_tty, return symbol_file_add_from_bfd (symfile_bfd_open (name), add_flags, addrs,
addrs, mainline, flags); flags);
} }
@ -1135,7 +1133,8 @@ symbol_file_add_main (char *args, int from_tty)
static void static void
symbol_file_add_main_1 (char *args, int from_tty, int flags) symbol_file_add_main_1 (char *args, int from_tty, int flags)
{ {
symbol_file_add (args, from_tty, NULL, 1, flags); const int add_flags = SYMFILE_MAINLINE | (from_tty ? SYMFILE_VERBOSE : 0);
symbol_file_add (args, add_flags, NULL, flags);
/* Getting new symbols may change our opinion about /* Getting new symbols may change our opinion about
what is frameless. */ what is frameless. */
@ -2224,7 +2223,8 @@ add_symbol_file_command (char *args, int from_tty)
if (from_tty && (!query ("%s", ""))) if (from_tty && (!query ("%s", "")))
error (_("Not confirmed.")); error (_("Not confirmed."));
symbol_file_add (filename, from_tty, section_addrs, 0, flags); symbol_file_add (filename, from_tty ? SYMFILE_VERBOSE : 0,
section_addrs, flags);
/* Getting new symbols may change our opinion about what is /* Getting new symbols may change our opinion about what is
frameless. */ frameless. */
@ -2506,10 +2506,9 @@ reread_separate_symbols (struct objfile *objfile)
objfile->separate_debug_objfile objfile->separate_debug_objfile
= (symbol_file_add_with_addrs_or_offsets = (symbol_file_add_with_addrs_or_offsets
(symfile_bfd_open (debug_file), (symfile_bfd_open (debug_file),
info_verbose, /* from_tty: Don't override the default. */ info_verbose ? SYMFILE_VERBOSE : 0,
0, /* No addr table. */ 0, /* No addr table. */
objfile->section_offsets, objfile->num_sections, objfile->section_offsets, objfile->num_sections,
0, /* Not mainline. See comments about this above. */
objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW
| OBJF_USERLOADED))); | OBJF_USERLOADED)));
objfile->separate_debug_objfile->separate_debug_objfile_backlink objfile->separate_debug_objfile->separate_debug_objfile_backlink

View File

@ -210,18 +210,34 @@ extern int free_named_symtabs (char *);
extern void add_symtab_fns (struct sym_fns *); extern void add_symtab_fns (struct sym_fns *);
/* This enum encodes bit-flags passed as ADD_FLAGS parameter to
syms_from_objfile, symbol_file_add, etc. */
enum symfile_add_flags
{
/* Be chatty about what you are doing. */
SYMFILE_VERBOSE = 1 << 1,
/* This is the main symbol file (as opposed to symbol file for dynamically
loaded code). */
SYMFILE_MAINLINE = 1 << 2,
/* Do not call breakpoint_re_set when adding this symbol file. */
SYMFILE_DEFER_BP_RESET = 1 << 3
};
extern void syms_from_objfile (struct objfile *, extern void syms_from_objfile (struct objfile *,
struct section_addr_info *, struct section_addr_info *,
struct section_offsets *, int, int, int); struct section_offsets *, int, int);
extern void new_symfile_objfile (struct objfile *, int, int); extern void new_symfile_objfile (struct objfile *, int);
extern struct objfile *symbol_file_add (char *, int, extern struct objfile *symbol_file_add (char *, int,
struct section_addr_info *, int, int); struct section_addr_info *, int);
extern struct objfile *symbol_file_add_from_bfd (bfd *, int, extern struct objfile *symbol_file_add_from_bfd (bfd *, int,
struct section_addr_info *, struct section_addr_info *,
int, int); int);
/* Create a new section_addr_info, with room for NUM_SECTIONS. */ /* Create a new section_addr_info, with room for NUM_SECTIONS. */

View File

@ -556,7 +556,9 @@ static int
safe_symbol_file_add_stub (void *argv) safe_symbol_file_add_stub (void *argv)
{ {
#define p ((struct safe_symbol_file_add_args *) argv) #define p ((struct safe_symbol_file_add_args *) argv)
p->ret = symbol_file_add (p->name, p->from_tty, p->addrs, p->mainline, p->flags); const int add_flags = ((p->from_tty ? SYMFILE_VERBOSE : 0)
| (p->mainline ? SYMFILE_MAINLINE : 0));
p->ret = symbol_file_add (p->name, add_flags, p->addrs, p->flags);
return !!p->ret; return !!p->ret;
#undef p #undef p
} }