This is the mail archive of the gdb-patches@sourceware.cygnus.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]

Re: Problems with hardware watchpoint on ia32.


Eli Zaretskii wrote:
> 
> Problem no.2: Read watchpoints break when they shouldn't.

Accepted and checked in.		--michael
 
> Example (slightly modified test program posted by H.J. Lu):
> 
> $ cat wp.c
> int a1;
> int a2;
> int a3;
> int a4;
> int a5;
> int a6;
> 
> unsigned long long ulla1 = 0;
> double da2 = 0;
> 
> int main (void)
> {
>   a2 = 12;
>   a3 = 13;
>   a4 = 14;
>   a5 = 15;
>   a6 = 16;
>   a1 = 11;
>   a2 = a4;
> 
>   ulla1 = 0x00000000ffffffffLL;
>   da2 = 12;
>   ulla1 = 0xffffffff00000000LL;
> 
>   return 0;
> }
> 
> $ gcc -g -o wp wp.c
> $ gdb wp
> (gdb) watch a5
> Hardware watchpoint 2: a5
> (gdb) rwatch a5
> Hardware read watchpoint 3: a5
> (gdb) run
> Starting program g:/gdbsnap/gdb-0222/gdb/wp
> Hardware watchpoint 2: a5
> 
> Old value = 0
> New value = 15
> Hardware read watchpoint 3: a5
> 
> Value = 15
> main () at wp.c: 16
> 16      a5 = 15;
> (gdb)
> 
> Now, it might seem like a strange idea to put two watchpoints on the
> same variable, but it is a very useful feature when each watchpoint
> has a different condition.
> 
> Here's the patch:
> 
> 2000-03-08  Eli Zaretskii  <eliz@is.elta.co.il>
> 
>         * breakpoint.c (bpstat_stop_status): Don't stop if a read
>         watchpoint appears to break, but the watched value changed.
> 
> --- gdb/breakpoint.c~2  Wed Mar  8 19:20:28 2000
> +++ gdb/breakpoint.c    Wed Mar  8 20:02:20 2000
> @@ -2620,6 +2620,17 @@ bpstat_stop_status (pc, not_a_breakpoint
>               /* Stop.  */
>               break;
>             case WP_VALUE_CHANGED:
> +             if (b->type == bp_read_watchpoint)
> +               {
> +                 /* Don't stop: read watchpoints shouldn't fire if
> +                    the value has changed.  This is for targets which
> +                    cannot set read-only watchpoints.  */
> +                 bs->print_it = print_it_noop;
> +                 bs->stop = 0;
> +                 continue;
> +               }
> +             ++(b->hit_count);
> +             break;
>             case WP_VALUE_NOT_CHANGED:
>               /* Stop.  */
>               ++(b->hit_count);

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