Have filter_results take a std::vector
This chagnes filter_results to take a std::vector, allowing the removal of some cleanups in its callers. ChangeLog 2018-04-05 Tom Tromey <tom@tromey.com> * linespec.c (filter_results): Use std::vector. (decode_line_2, decode_line_full): Update.
This commit is contained in:
parent
53a0f8a250
commit
f73c6ece78
2 changed files with 11 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2018-04-05 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* linespec.c (filter_results): Use std::vector.
|
||||||
|
(decode_line_2, decode_line_full): Update.
|
||||||
|
|
||||||
2018-04-05 Tom Tromey <tom@tromey.com>
|
2018-04-05 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* linespec.c (canonical_to_fullform): Return std::string.
|
* linespec.c (canonical_to_fullform): Return std::string.
|
||||||
|
|
|
@ -1402,12 +1402,9 @@ canonical_to_fullform (const struct linespec_canonical_name *canonical)
|
||||||
static void
|
static void
|
||||||
filter_results (struct linespec_state *self,
|
filter_results (struct linespec_state *self,
|
||||||
std::vector<symtab_and_line> *result,
|
std::vector<symtab_and_line> *result,
|
||||||
VEC (const_char_ptr) *filters)
|
const std::vector<const char *> &filters)
|
||||||
{
|
{
|
||||||
int i;
|
for (const char *name : filters)
|
||||||
const char *name;
|
|
||||||
|
|
||||||
for (i = 0; VEC_iterate (const_char_ptr, filters, i, name); ++i)
|
|
||||||
{
|
{
|
||||||
linespec_sals lsal;
|
linespec_sals lsal;
|
||||||
|
|
||||||
|
@ -1497,16 +1494,13 @@ decode_line_2 (struct linespec_state *self,
|
||||||
char *args;
|
char *args;
|
||||||
const char *prompt;
|
const char *prompt;
|
||||||
int i;
|
int i;
|
||||||
struct cleanup *old_chain;
|
std::vector<const char *> filters;
|
||||||
VEC (const_char_ptr) *filters = NULL;
|
|
||||||
std::vector<struct decode_line_2_item> items;
|
std::vector<struct decode_line_2_item> items;
|
||||||
|
|
||||||
gdb_assert (select_mode != multiple_symbols_all);
|
gdb_assert (select_mode != multiple_symbols_all);
|
||||||
gdb_assert (self->canonical != NULL);
|
gdb_assert (self->canonical != NULL);
|
||||||
gdb_assert (!result->empty ());
|
gdb_assert (!result->empty ());
|
||||||
|
|
||||||
old_chain = make_cleanup (VEC_cleanup (const_char_ptr), &filters);
|
|
||||||
|
|
||||||
/* Prepare ITEMS array. */
|
/* Prepare ITEMS array. */
|
||||||
for (i = 0; i < result->size (); ++i)
|
for (i = 0; i < result->size (); ++i)
|
||||||
{
|
{
|
||||||
|
@ -1553,7 +1547,6 @@ decode_line_2 (struct linespec_state *self,
|
||||||
|
|
||||||
if (select_mode == multiple_symbols_all || items.size () == 1)
|
if (select_mode == multiple_symbols_all || items.size () == 1)
|
||||||
{
|
{
|
||||||
do_cleanups (old_chain);
|
|
||||||
convert_results_to_lsals (self, result);
|
convert_results_to_lsals (self, result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1587,7 +1580,6 @@ decode_line_2 (struct linespec_state *self,
|
||||||
multiple_symbols_all behavior even with the 'ask'
|
multiple_symbols_all behavior even with the 'ask'
|
||||||
setting; and he can get separate breakpoints by entering
|
setting; and he can get separate breakpoints by entering
|
||||||
"2-57" at the query. */
|
"2-57" at the query. */
|
||||||
do_cleanups (old_chain);
|
|
||||||
convert_results_to_lsals (self, result);
|
convert_results_to_lsals (self, result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1601,7 +1593,7 @@ decode_line_2 (struct linespec_state *self,
|
||||||
|
|
||||||
if (!item->selected)
|
if (!item->selected)
|
||||||
{
|
{
|
||||||
VEC_safe_push (const_char_ptr, filters, item->fullform.c_str ());
|
filters.push_back (item->fullform.c_str ());
|
||||||
item->selected = 1;
|
item->selected = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1613,7 +1605,6 @@ decode_line_2 (struct linespec_state *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_results (self, result, filters);
|
filter_results (self, result, filters);
|
||||||
do_cleanups (old_chain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3225,7 +3216,7 @@ decode_line_full (const struct event_location *location, int flags,
|
||||||
const char *filter)
|
const char *filter)
|
||||||
{
|
{
|
||||||
struct cleanup *cleanups;
|
struct cleanup *cleanups;
|
||||||
VEC (const_char_ptr) *filters = NULL;
|
std::vector<const char *> filters;
|
||||||
linespec_parser parser;
|
linespec_parser parser;
|
||||||
struct linespec_state *state;
|
struct linespec_state *state;
|
||||||
|
|
||||||
|
@ -3277,8 +3268,7 @@ decode_line_full (const struct event_location *location, int flags,
|
||||||
{
|
{
|
||||||
if (filter != NULL)
|
if (filter != NULL)
|
||||||
{
|
{
|
||||||
make_cleanup (VEC_cleanup (const_char_ptr), &filters);
|
filters.push_back (filter);
|
||||||
VEC_safe_push (const_char_ptr, filters, filter);
|
|
||||||
filter_results (state, &result, filters);
|
filter_results (state, &result, filters);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue