Remove free_value_chain
This patch changes value_release_to_mark and fetch_subexp_value to return a std::vector of value references, rather than relying on the "next" field that is contained in a struct value. This makes it simpler to reason about the returned values, and also allows for the removal of free_value_chain. gdb/ChangeLog 2018-04-06 Tom Tromey <tom@tromey.com> * value.h (fetch_subexp_value, value_release_to_mark): Update. (free_value_chain): Remove. * value.c (free_value_chain): Remove. (value_release_to_mark): Return a std::vector. * ppc-linux-nat.c (num_memory_accesses): Change "chain" to a std::vector. (check_condition): Update. * eval.c (fetch_subexp_value): Change "val_chain" to a std::vector. * breakpoint.c (update_watchpoint): Update. (can_use_hardware_watchpoint): Change "vals" to a std::vector.
This commit is contained in:
parent
b562120198
commit
a6535de190
6 changed files with 69 additions and 73 deletions
37
gdb/value.c
37
gdb/value.c
|
@ -1638,20 +1638,6 @@ value_free_to_mark (const struct value *mark)
|
|||
all_values = val;
|
||||
}
|
||||
|
||||
/* Frees all the elements in a chain of values. */
|
||||
|
||||
void
|
||||
free_value_chain (struct value *v)
|
||||
{
|
||||
struct value *next;
|
||||
|
||||
for (; v; v = next)
|
||||
{
|
||||
next = value_next (v);
|
||||
value_decref (v);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove VAL from the chain all_values
|
||||
so it will not be freed automatically. */
|
||||
|
||||
|
@ -1695,25 +1681,30 @@ release_value (struct value *val)
|
|||
return value_ref_ptr (val);
|
||||
}
|
||||
|
||||
/* Release all values up to mark */
|
||||
struct value *
|
||||
/* See value.h. */
|
||||
|
||||
std::vector<value_ref_ptr>
|
||||
value_release_to_mark (const struct value *mark)
|
||||
{
|
||||
struct value *val;
|
||||
std::vector<value_ref_ptr> result;
|
||||
struct value *next;
|
||||
|
||||
for (val = next = all_values; next; next = next->next)
|
||||
for (next = all_values; next; next = next->next)
|
||||
{
|
||||
next->released = 1;
|
||||
result.emplace_back (next);
|
||||
|
||||
if (next->next == mark)
|
||||
{
|
||||
all_values = next->next;
|
||||
struct value *save = next->next;
|
||||
next->next = NULL;
|
||||
return val;
|
||||
next = save;
|
||||
break;
|
||||
}
|
||||
next->released = 1;
|
||||
}
|
||||
all_values = 0;
|
||||
return val;
|
||||
|
||||
all_values = next;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Return a copy of the value ARG.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue