From 14ca73f748af8e1ee673170bc1541711faea265c Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 29 Mar 2016 15:48:28 +0100 Subject: [PATCH] More O(N) elimination --- gdb/linespec.c | 10 +--------- gdb/symtab.c | 12 ++++++++---- gdb/symtab.h | 3 ++- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index 611017e2b98..69d7905a9f6 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3266,15 +3266,7 @@ collect_symtabs_from_filename (const char *file, NULL); cleanups = make_cleanup_htab_delete (collector.symtab_table); - /* Find that file's data. */ - ALL_SEARCH_PSPACES (search_scope->pspace, pspace) - { - if (pspace->executing_startup) - continue; - - set_current_program_space (pspace); - iterate_over_symtabs (file, add_symtabs_to_list, &collector); - } + iterate_over_symtabs (search_scope, file, add_symtabs_to_list, &collector); do_cleanups (cleanups); return collector.symtabs; diff --git a/gdb/symtab.c b/gdb/symtab.c index 5dd97cfdf6f..9d37dec6a7b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -457,11 +457,13 @@ iterate_over_some_symtabs (const char *name, DATA. If CALLBACK returns true, the search stops. */ void -iterate_over_symtabs (const char *name, +iterate_over_symtabs (struct sym_search_scope *search_scope, + const char *name, int (*callback) (struct symtab *symtab, void *data), void *data) { + struct program_space *pspace; struct objfile *objfile; char *real_path = NULL; struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); @@ -475,7 +477,7 @@ iterate_over_symtabs (const char *name, gdb_assert (IS_ABSOLUTE_PATH (real_path)); } - ALL_OBJFILES (objfile) + ALL_SEARCH_SCOPE_OBJFILES (search_scope, pspace, objfile) { if (iterate_over_some_symtabs (name, real_path, callback, data, objfile->compunit_symtabs, NULL)) @@ -488,7 +490,7 @@ iterate_over_symtabs (const char *name, /* Same search rules as above apply here, but now we look thru the psymtabs. */ - ALL_OBJFILES (objfile) + ALL_SEARCH_SCOPE_OBJFILES (search_scope, pspace, objfile) { if (objfile->sf && objfile->sf->qf->map_symtabs_matching_filename (objfile, @@ -523,8 +525,10 @@ struct symtab * lookup_symtab (const char *name) { struct symtab *result = NULL; + struct sym_search_scope search_scope = null_search_scope (); - iterate_over_symtabs (name, lookup_symtab_callback, &result); + search_scope.pspace = current_program_space; + iterate_over_symtabs (&search_scope, name, lookup_symtab_callback, &result); return result; } diff --git a/gdb/symtab.h b/gdb/symtab.h index 9f7550741a4..20c6b0214a3 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1638,7 +1638,8 @@ int iterate_over_some_symtabs (const char *name, struct compunit_symtab *first, struct compunit_symtab *after_last); -void iterate_over_symtabs (const char *name, +void iterate_over_symtabs (struct sym_search_scope *search_scope, + const char *name, int (*callback) (struct symtab *symtab, void *data), void *data); -- 2.47.2