This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

watchpoint count wrong, think-o


Hello,

I think there's a bug in how GDB counts the number of watchpoint resources needed:

When first creating a hardware watchpoint, the function:

static int
can_use_hardware_watchpoint (struct value *v)

Iterates through the values needed to compute the expression to determine how many of those values live in memory and hence how many need to be watched. That total number of watched elements is used when determining if there enough watch resources. E.g., ``a + b'' would be two watch elements ``a'' and ``b''. (the value passed down to that Z? packet.)

However, when GDB goes a re-count on that same watchpoint (as part of computing the watchpoint resources already used), the function:

hw_watchpoint_used_count (enum bptype type, int *other_type_used)

is used and it does the far simpler computation of just counting up the number of watchpoints (and not watchpoint elements). Hence, ``a + b'' gets re-counted as just one watchpoint element.

Anyone agree? I guess I get to prove this some how :-/

As for fixing it.

- should the number of elements needed be cached in the breakpoint structure, or
- re-computed each time

I think a cache is safe since I can't see how the number of elements would change. It would also avoid any overhead in re-calling TARGET_REGION_OK_FOR_HW_WATCHPOINT().

Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]