aboutsummaryrefslogtreecommitdiff
path: root/gdb/value.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-04-03 20:20:01 -0600
committerTom Tromey <tom@tromey.com>2018-04-06 15:44:49 -0600
commita6535de1903d9caad8c10c1d81c51a29612456a6 (patch)
tree6dad69fd5bbd4b33f12f6bdf15287067e1282bd0 /gdb/value.c
parentb562120198d9fa2c191823508813daa3b62a3a37 (diff)
downloadgdb-a6535de1903d9caad8c10c1d81c51a29612456a6.zip
gdb-a6535de1903d9caad8c10c1d81c51a29612456a6.tar.gz
gdb-a6535de1903d9caad8c10c1d81c51a29612456a6.tar.bz2
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.
Diffstat (limited to 'gdb/value.c')
-rw-r--r--gdb/value.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/gdb/value.c b/gdb/value.c
index a84c196..004ff3b 100644
--- a/gdb/value.c
+++ b/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.