Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <vladimir@codesourcery.com>
To: gdb-patches@sources.redhat.com
Subject: Re: Patch for bug2457
Date: Wed, 14 May 2008 21:59:00 -0000	[thread overview]
Message-ID: <g0farm$su5$1@ger.gmane.org> (raw)
In-Reply-To: <578d90ee0805141109y1b768c67jc64828923162cea9@mail.gmail.com>

> Hi,
> 
> Here's a simple patch for bug2457 (Incorrect handling of erroneous
> breakpoint conditions).
> 
> It just postpones the update of the breakpoint condition until it has
> been parsed successfully.
> 
> If there is a parsing error, the condition is set to NULL.
> 
> Best Regards,
> /fc
> gdb-bug2457.patch
>   ### Eclipse Workspace Patch 1.0 
> #P gdb 
> Index: breakpoint.c 
> =================================================================== 
> RCS file: /cvs/src/src/gdb/breakpoint.c,v 
> retrieving revision 1.321 
> diff -u -r1.321 breakpoint.c 
> --- breakpoint.c        4 May 2008 19:38:59 -0000       1.321 
> +++ breakpoint.c        14 May 2008 17:32:06 -0000 
> @@ -596,11 +596,13 @@ 
>               } 
>           } 
>         if (b->cond_string != NULL) 
> -         xfree (b->cond_string); 
> +         { 
> +           xfree (b->cond_string); 
> +           b->cond_string = NULL;      /* Keep in sync */ 
> +         } 

Is this actually what we want? If we want the breakpoint condition to be
unchanged on error, then we should not clear b->cond_string here.

>   
>         if (*p == 0) 
>           { 
> -           b->cond_string = NULL; 
>             if (from_tty) 
>               printf_filtered (_("Breakpoint %d now unconditional.\n"), bnum); 
>           } 
> @@ -609,7 +611,6 @@ 
>             arg = p; 
>             /* I don't know if it matters whether this is the string the user 
>                typed in or the decompiled expression.  */ 
> -           b->cond_string = savestring (arg, strlen (arg)); 
>             b->condition_not_parsed = 0; 
>             for (loc = b->loc; loc; loc = loc->next) 
>               { 
> @@ -619,6 +620,9 @@ 
>                 if (*arg) 
>                   error (_("Junk at end of expression")); 
>               } 
> +           /* If we get here, the condition was parsed successfully and 
> +           no exception was thrown. See bug 2457. */ 
> +           b->cond_string = savestring (p, strlen (p)); 

Presumably, if an exception is thrown, then we should undo the changes to breakpoint
location's 'cond' fields that we did above? Alternatively, we can:

1. Re-evaluate new condition string at all locations, and store the results in
a vector
2. If successfull, store new expressions in loc->cond, foreach loc.
3. Update b->cond_string

That would be actually "strong exception safety" in C++ terms.

There are some technical issues with the patch:
1. There should be a changelog entry
2. Comments should be meaningful on their own, so I think "See bug 2457" is not
good -- there should be explanation that we want exception-safety.
3. Comment like "Keep in sync" also does not say anything.

Thanks,
Volodya


>           } 
>         breakpoints_changed (); 
>         breakpoint_modify_event (b->number); 


      reply	other threads:[~2008-05-14 18:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-14 18:27 Francois Chouinard
2008-05-14 21:59 ` Vladimir Prus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='g0farm$su5$1@ger.gmane.org' \
    --to=vladimir@codesourcery.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox