This is the mail archive of the gdb-patches@sourceware.org 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] Warn on constant value watchpoints


On Mon, Jun 09, 2008 at 08:14:14AM +0200, Jan Kratochvil wrote:
> @@ -5903,7 +5903,27 @@ watch_command_1 (char *arg, int accessfl
>    exp_end = arg;
>    exp_valid_block = innermost_block;
>    mark = value_mark ();
> -  fetch_watchpoint_value (exp, &val, NULL, NULL);
> +  fetch_watchpoint_value (exp, &val, &val_result, NULL);
> +
> +  /* VAL may be unset for unreachable final values.  */
> +  while (val_result != NULL)
> +    {
> +      if (VALUE_LVAL (val_result) == lval_memory
> +	  || VALUE_LVAL (val_result) == lval_register)
> +	break;
> +      val_result = value_next (val_result);
> +    }

val_result is the same as val, except possibly lazy.  value_next
(val_result) will always be NULL, won't it?  The chain goes the other
way - next from the oldest value (*val_chain argument, or the first
value after the saved mark).

If I'm right it seems like this patch will break "watch a + 1".

Also, I don't know how useful this feature is, but what happens with
"watch foo()"?

> +  if (val_result == NULL)
> +    {
> +      int len;
> +      
> +      len = exp_end - exp_start;
> +      while (len > 0 && isspace (exp_start[len - 1]))
> +	len--;
> +      error (_("Cannot watch constant value %.*s."), len, exp_start);
> +    }

If an intermediate value could not be read, val_result may be NULL.
So this will stop us watching such expressions before they become
readable.

> +If you watch for a change in a numerically entered address you need to
> +dereference it as the address itself is just a constant number which will never
> +change.  @value{GDBN} refuses to create a never invokable watchpoint:

never-changing?

-- 
Daniel Jacobowitz
CodeSourcery


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