Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [Patch] Watchpoint condition fix
@ 2008-04-10 14:21 Marc Khouzam
  2008-04-16 22:15 ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Khouzam @ 2008-04-10 14:21 UTC (permalink / raw)
  To: gdb-patches

Repost to gdb-patches from gdb mailing list post:
http://sourceware.org/ml/gdb/2008-04/msg00078.html

Watchpoint conditions are broken because they
get deleted when a watchpoint gets re-inserted.
When watchpoints get re-inserted, the condition 
string should be always reparsed.

Ok?

2008-04-10  Marc Khouzam  <marc.khouzam@ericsson.com>

	* breakpoint.c (update_watchpoint): Always reparse
	condition.

Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.307
diff -u -r1.307 breakpoint.c
--- gdb/breakpoint.c    14 Mar 2008 18:57:43 -0000      1.307
+++ gdb/breakpoint.c    10 Apr 2008 12:25:32 -0000
@@ -986,7 +986,7 @@
            value_free (v);
        }
 
-      if (reparse && b->cond_string != NULL)
+      if (b->cond_string != NULL)
        {
          char *s = b->cond_string;
          if (b->loc->cond)



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch] Watchpoint condition fix
  2008-04-10 14:21 [Patch] Watchpoint condition fix Marc Khouzam
@ 2008-04-16 22:15 ` Joel Brobecker
  2008-04-17 18:48   ` Marc Khouzam
  0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2008-04-16 22:15 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: gdb-patches

> Watchpoint conditions are broken because they get deleted when a
> watchpoint gets re-inserted.  When watchpoints get re-inserted, the
> condition string should be always reparsed.

I agree with you and Vladimir.

> @@ -986,7 +986,7 @@
>             value_free (v);
>         }
>  
> -      if (reparse && b->cond_string != NULL)
> +      if (b->cond_string != NULL)

This part of the change is OK, but I would like to see a comment
explaining why we have to re-evaluate the condition regardless of
the value of reparse.  Vladimir's explaination on the gdb@ mailing
list pretty much covers it.

>         {
>           char *s = b->cond_string;
>           if (b->loc->cond)

Also, you can remove the block of code that checks b->loc->cond
and frees when non-NULL, since we've just re-created the bplocs
earlier and we know that their cond field is NULL. As a result,
the temporary variable "s" shouldn't be necessary either.

As an aside, but this is not your doing, I think we have a memory leak.
We appear to be doing an xfree of each bp_location of our watchpoint,
but instead we should call free_bp_location (). Vladimir, do you agree?
(I will take care of doing that if you agree)

Thank you,
-- 
Joel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [Patch] Watchpoint condition fix
  2008-04-16 22:15 ` Joel Brobecker
@ 2008-04-17 18:48   ` Marc Khouzam
  2008-04-17 21:09     ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Khouzam @ 2008-04-17 18:48 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches


> This part of the change is OK, but I would like to see a comment

Done

> Also, you can remove the block of code that checks b->loc->cond
> and frees when non-NULL, since we've just re-created the bplocs
> earlier and we know that their cond field is NULL. 

Done

> As a result,
> the temporary variable "s" shouldn't be necessary either.

I'm not sure about this one.  s is pointing to b->cond_string
and not b->loc->cond.  Is it really unecessary?

Here is the updated patch (having kept the temp var s)

Marc


2008-04-17  Marc Khouzam  <marc.khouzam@ericsson.com>

       * breakpoint.c (update_watchpoint): Always reparse
       condition.


Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.308
diff -u -r1.308 breakpoint.c
--- gdb/breakpoint.c    15 Apr 2008 14:32:12 -0000      1.308
+++ gdb/breakpoint.c    17 Apr 2008 17:40:13 -0000
@@ -994,14 +994,14 @@
            value_free (v);
        }
 
-      if (reparse && b->cond_string != NULL)
+      /* We just regenerated the list of breakpoint locations.
+       * The new location does not have its condition field set to anything
+       * and therefore, we must always reparse the cond_string, independently
+       * of the value of the reparse flag.
+       */
+      if (b->cond_string != NULL)
        {
          char *s = b->cond_string;
-         if (b->loc->cond)
-           {
-             xfree (b->loc->cond);
-             b->loc->cond = NULL;
-           }
          b->loc->cond = parse_exp_1 (&s, b->exp_valid_block, 0);
        }
     }


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch] Watchpoint condition fix
  2008-04-17 18:48   ` Marc Khouzam
@ 2008-04-17 21:09     ` Joel Brobecker
  2008-04-18 10:10       ` Marc Khouzam
  0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2008-04-17 21:09 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: gdb-patches

> > As a result, the temporary variable "s" shouldn't be necessary
> > either.
> 
> I'm not sure about this one.  s is pointing to b->cond_string
> and not b->loc->cond.  Is it really unecessary?

You are right to keep it, but not for the reason you explained.
I forgot that parse_exp_1 advances the string pointer that it is given.
So if we didn't keep the temporary variable, we would screw b->cond_string
(oops!).

> 2008-04-17  Marc Khouzam  <marc.khouzam@ericsson.com>
> 
>        * breakpoint.c (update_watchpoint): Always reparse
>        condition.

This is OK after having fixed a tiny little detail:

> -      if (reparse && b->cond_string != NULL)
> +      /* We just regenerated the list of breakpoint locations.
> +       * The new location does not have its condition field set to anything
> +       * and therefore, we must always reparse the cond_string, independently
> +       * of the value of the reparse flag.

Reformat the comment to avoid the '*' at the beginning of each line
and put the final '*/' at the end of the last line, not on a new line:

      /* We just regenerated the list of breakpoint locations.
         The new location does not have its condition field set to anything
         and therefore, we must always reparse the cond_string, independently
         of the value of the reparse flag.  */

Thank you,
-- 
Joel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [Patch] Watchpoint condition fix
  2008-04-17 21:09     ` Joel Brobecker
@ 2008-04-18 10:10       ` Marc Khouzam
  2008-04-19  1:39         ` Doug Evans
  2008-04-22 20:36         ` Joel Brobecker
  0 siblings, 2 replies; 8+ messages in thread
From: Marc Khouzam @ 2008-04-18 10:10 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches


> Reformat the comment to avoid the '*' at the beginning of each line
> and put the final '*/' at the end of the last line, not on a new line:

Forgot about that.  Eclipse does the comments in its own way.
I fixed it.

I committed the following:

2008-04-17  Marc Khouzam  <marc.khouzam@ericsson.com>

       * breakpoint.c (update_watchpoint): Always reparse
       condition.


Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.309
diff -u -r1.309 breakpoint.c
--- gdb/breakpoint.c    17 Apr 2008 22:43:17 -0000      1.309
+++ gdb/breakpoint.c    18 Apr 2008 00:35:22 -0000
@@ -994,14 +994,13 @@
            value_free (v);
        }
 
-      if (reparse && b->cond_string != NULL)
+      /* We just regenerated the list of breakpoint locations.
+         The new location does not have its condition field set to anything
+         and therefore, we must always reparse the cond_string, independently
+         of the value of the reparse flag.  */
+      if (b->cond_string != NULL)
        {
          char *s = b->cond_string;
-         if (b->loc->cond)
-           {
-             xfree (b->loc->cond);
-             b->loc->cond = NULL;
-           }
          b->loc->cond = parse_exp_1 (&s, b->exp_valid_block, 0);
        }
     }



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch] Watchpoint condition fix
  2008-04-18 10:10       ` Marc Khouzam
@ 2008-04-19  1:39         ` Doug Evans
  2008-04-19  1:58           ` Joel Brobecker
  2008-04-22 20:36         ` Joel Brobecker
  1 sibling, 1 reply; 8+ messages in thread
From: Doug Evans @ 2008-04-19  1:39 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: Joel Brobecker, gdb-patches

On Thu, Apr 17, 2008 at 5:41 PM, Marc Khouzam <marc.khouzam@ericsson.com> wrote:
>
>  > Reformat the comment to avoid the '*' at the beginning of each line
>  > and put the final '*/' at the end of the last line, not on a new line:
>
>  Forgot about that.  Eclipse does the comments in its own way.
>  I fixed it.
>
>  I committed the following:
>
>  2008-04-17  Marc Khouzam  <marc.khouzam@ericsson.com>
>
>        * breakpoint.c (update_watchpoint): Always reparse
>        condition.

Is this something that should go in the 6.8 branch?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch] Watchpoint condition fix
  2008-04-19  1:39         ` Doug Evans
@ 2008-04-19  1:58           ` Joel Brobecker
  0 siblings, 0 replies; 8+ messages in thread
From: Joel Brobecker @ 2008-04-19  1:58 UTC (permalink / raw)
  To: Doug Evans; +Cc: Marc Khouzam, gdb-patches

> >  2008-04-17  Marc Khouzam  <marc.khouzam@ericsson.com>
> >
> >        * breakpoint.c (update_watchpoint): Always reparse
> >        condition.
> 
> Is this something that should go in the 6.8 branch?

Looks like a good candidate to me. I'll put it in next week
unless someone objects.

-- 
Joel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch] Watchpoint condition fix
  2008-04-18 10:10       ` Marc Khouzam
  2008-04-19  1:39         ` Doug Evans
@ 2008-04-22 20:36         ` Joel Brobecker
  1 sibling, 0 replies; 8+ messages in thread
From: Joel Brobecker @ 2008-04-22 20:36 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: gdb-patches

> 2008-04-17  Marc Khouzam  <marc.khouzam@ericsson.com>
> 
>        * breakpoint.c (update_watchpoint): Always reparse
>        condition.

As suggested, I pushed this to the branch as well.

-- 
Joel


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-04-22 20:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-10 14:21 [Patch] Watchpoint condition fix Marc Khouzam
2008-04-16 22:15 ` Joel Brobecker
2008-04-17 18:48   ` Marc Khouzam
2008-04-17 21:09     ` Joel Brobecker
2008-04-18 10:10       ` Marc Khouzam
2008-04-19  1:39         ` Doug Evans
2008-04-19  1:58           ` Joel Brobecker
2008-04-22 20:36         ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox