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
|
@ -117,7 +117,8 @@ static std::vector<symtab_and_line> decode_location_default
|
|||
(struct breakpoint *b, const struct event_location *location,
|
||||
struct program_space *search_pspace);
|
||||
|
||||
static int can_use_hardware_watchpoint (struct value *);
|
||||
static int can_use_hardware_watchpoint
|
||||
(const std::vector<value_ref_ptr> &vals);
|
||||
|
||||
static void mention (struct breakpoint *);
|
||||
|
||||
|
@ -1777,7 +1778,8 @@ update_watchpoint (struct watchpoint *b, int reparse)
|
|||
else if (within_current_scope && b->exp)
|
||||
{
|
||||
int pc = 0;
|
||||
struct value *val_chain, *v, *result, *next;
|
||||
std::vector<value_ref_ptr> val_chain;
|
||||
struct value *v, *result, *next;
|
||||
struct program_space *frame_pspace;
|
||||
|
||||
fetch_subexp_value (b->exp.get (), &pc, &v, &result, &val_chain, 0);
|
||||
|
@ -1799,15 +1801,18 @@ update_watchpoint (struct watchpoint *b, int reparse)
|
|||
frame_pspace = get_frame_program_space (get_selected_frame (NULL));
|
||||
|
||||
/* Look at each value on the value chain. */
|
||||
for (v = val_chain; v; v = value_next (v))
|
||||
gdb_assert (!val_chain.empty ());
|
||||
for (const value_ref_ptr &iter : val_chain)
|
||||
{
|
||||
v = iter.get ();
|
||||
|
||||
/* If it's a memory location, and GDB actually needed
|
||||
its contents to evaluate the expression, then we
|
||||
must watch it. If the first value returned is
|
||||
still lazy, that means an error occurred reading it;
|
||||
watch it anyway in case it becomes readable. */
|
||||
if (VALUE_LVAL (v) == lval_memory
|
||||
&& (v == val_chain || ! value_lazy (v)))
|
||||
&& (v == val_chain[0] || ! value_lazy (v)))
|
||||
{
|
||||
struct type *vtype = check_typedef (value_type (v));
|
||||
|
||||
|
@ -1962,13 +1967,6 @@ update_watchpoint (struct watchpoint *b, int reparse)
|
|||
bl->loc_type = loc_type;
|
||||
}
|
||||
|
||||
for (v = val_chain; v; v = next)
|
||||
{
|
||||
next = value_next (v);
|
||||
if (v != b->val)
|
||||
value_decref (v);
|
||||
}
|
||||
|
||||
/* If a software watchpoint is not watching any memory, then the
|
||||
above left it without any location set up. But,
|
||||
bpstat_stop_status requires a location to be able to report
|
||||
|
@ -10875,15 +10873,17 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
|
|||
If the watchpoint cannot be handled in hardware return zero. */
|
||||
|
||||
static int
|
||||
can_use_hardware_watchpoint (struct value *v)
|
||||
can_use_hardware_watchpoint (const std::vector<value_ref_ptr> &vals)
|
||||
{
|
||||
int found_memory_cnt = 0;
|
||||
struct value *head = v;
|
||||
|
||||
/* Did the user specifically forbid us to use hardware watchpoints? */
|
||||
if (!can_use_hw_watchpoints)
|
||||
return 0;
|
||||
|
||||
gdb_assert (!vals.empty ());
|
||||
struct value *head = vals[0].get ();
|
||||
|
||||
/* Make sure that the value of the expression depends only upon
|
||||
memory contents, and values computed from them within GDB. If we
|
||||
find any register references or function calls, we can't use a
|
||||
|
@ -10903,8 +10903,10 @@ can_use_hardware_watchpoint (struct value *v)
|
|||
function calls are special in any way. So this function may not
|
||||
notice that an expression involving an inferior function call
|
||||
can't be watched with hardware watchpoints. FIXME. */
|
||||
for (; v; v = value_next (v))
|
||||
for (const value_ref_ptr &iter : vals)
|
||||
{
|
||||
struct value *v = iter.get ();
|
||||
|
||||
if (VALUE_LVAL (v) == lval_memory)
|
||||
{
|
||||
if (v != head && value_lazy (v))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue