aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-10-08 12:11:18 -0600
committerTom Tromey <tom@tromey.com>2017-10-08 22:53:53 -0600
commitb9c04fb2681dd5706d2cafa5dcc6bdcd99016cf4 (patch)
tree504043c3c682060b43004685f24a842f79ee3c26 /gdb/symtab.h
parentb55ec8b676ed05d93ee49d6c79ae0403616c4fb0 (diff)
downloadgdb-b9c04fb2681dd5706d2cafa5dcc6bdcd99016cf4.zip
gdb-b9c04fb2681dd5706d2cafa5dcc6bdcd99016cf4.tar.gz
gdb-b9c04fb2681dd5706d2cafa5dcc6bdcd99016cf4.tar.bz2
Change search_symbols to return std::vector
This changes search_symbols to return a std::vector, replacing the previous linked list approach. This allows the removal of some cleanups, as well as the use of std::sort and std::unique, saving some code and extra allocations in sort_search_symbols_remove_dups. Regression tested by the buildbot. gdb/ChangeLog 2017-10-08 Tom Tromey <tom@tromey.com> * symtab.c (free_search_symbols, do_free_search_symbols_cleanup) (make_cleanup_free_search_symbols): Remove. (search_symbols): Return std::vector. (symbol_search::compare_search_syms): Now member of symbol_search. Change arguments. (sort_search_symbols_remove_dups): Change arguments. Rewrite. (symtab_symbol_info, rbreak_command): Update. * symtab.h (struct symbol_search) <next>: Remove. Add constructors. (symbol_search::operator<): New function. (symbol_search::operator==): New function. (search_symbols): Remove std::vector. (free_search_symbols, make_cleanup_free_search_symbols): Remove. (symbol_search::compare_search_syms): Declare.
Diffstat (limited to 'gdb/symtab.h')
-rw-r--r--gdb/symtab.h45
1 files changed, 36 insertions, 9 deletions
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 8b429a8..cd6dbae 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1561,10 +1561,37 @@ extern symbol *find_function_alias_target (bound_minimal_symbol msymbol);
/* Note: struct symbol_search, search_symbols, et.al. are declared here,
instead of making them local to symtab.c, for gdbtk's sake. */
-/* When using search_symbols, a list of the following structs is returned.
- Callers must free the search list using free_search_symbols! */
+/* When using search_symbols, a vector of the following structs is
+ returned. */
struct symbol_search
{
+ symbol_search (int block_, struct symbol *symbol_)
+ : block (block_),
+ symbol (symbol_)
+ {
+ msymbol.minsym = nullptr;
+ msymbol.objfile = nullptr;
+ }
+
+ symbol_search (int block_, struct minimal_symbol *minsym,
+ struct objfile *objfile)
+ : block (block_),
+ symbol (nullptr)
+ {
+ msymbol.minsym = minsym;
+ msymbol.objfile = objfile;
+ }
+
+ bool operator< (const symbol_search &other) const
+ {
+ return compare_search_syms (*this, other) < 0;
+ }
+
+ bool operator== (const symbol_search &other) const
+ {
+ return compare_search_syms (*this, other) == 0;
+ }
+
/* The block in which the match was found. Could be, for example,
STATIC_BLOCK or GLOBAL_BLOCK. */
int block;
@@ -1578,15 +1605,15 @@ struct symbol_search
which only minimal_symbols exist. */
struct bound_minimal_symbol msymbol;
- /* A link to the next match, or NULL for the end. */
- struct symbol_search *next;
+private:
+
+ static int compare_search_syms (const symbol_search &sym_a,
+ const symbol_search &sym_b);
};
-extern void search_symbols (const char *, enum search_domain, int,
- const char **, struct symbol_search **);
-extern void free_search_symbols (struct symbol_search *);
-extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search
- **);
+extern std::vector<symbol_search> search_symbols (const char *,
+ enum search_domain, int,
+ const char **);
/* The name of the ``main'' function.
FIXME: cagney/2001-03-20: Can't make main_name() const since some