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);
prev parent 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