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]

Re: [PATCH] Compare contents when evaluating an array watchpoint


Sure: breakpoint.c:984 (in insert_breakpoints), and breakpoint.c:5480 (in can_use_hardware_watchpoint).

Here's the relevant code from breakpoint.c:984:

/* Look at each value on the value chain. */
for (; v; v = v->next)
{
/* If it's a memory location, and GDB actually needed
its contents to evaluate the expression, then we
must watch it. */
if (VALUE_LVAL (v) == lval_memory
&& ! VALUE_LAZY (v))
{
struct type *vtype = check_typedef (VALUE_TYPE (v));

/* We only watch structs and arrays if user asked
for it explicitly, never if they just happen to
appear in the middle of some value chain. */
if (v == b->val_chain
|| (TYPE_CODE (vtype) != TYPE_CODE_STRUCT
&& TYPE_CODE (vtype) != TYPE_CODE_ARRAY))
{
CORE_ADDR addr;
int len, type;

addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
len = TYPE_LENGTH (VALUE_TYPE (v));
type = hw_write;
if (b->type == bp_read_watchpoint)
type = hw_read;
else if (b->type == bp_access_watchpoint)
type = hw_access;

val = target_insert_watchpoint (addr, len, type);

On Monday, October 7, 2002, at 10:26 AM, Eli Zaretskii wrote:

On Mon, 7 Oct 2002, Klee Dienes wrote:

My patch doesn't change the behavior
of the trigger phase at all --- this phase has always set the trigger
to watch the entire contents of the array.
IIRC, that's not true: what you call ``the trigger phase'' was watching
the address of the array, not its contents.  To watch the contents, you
needed to watch specific array elements.

In other words, "watch my_array" would break when the pointer to
the first element of my_array[] changed to point to a different memory
location.  If you want to watch array contents, you need to say
"watch my_array[0]", "watch my_array[1]", etc.

Of course, it's been a while since I looked at that code, so I might be
mistaken.  If so, could you please tell where's the code in the current
CVS sources which is watching the entire contents of the array?






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