* Patch for bug2457
@ 2008-05-14 18:27 Francois Chouinard
2008-05-14 21:59 ` Vladimir Prus
0 siblings, 1 reply; 2+ messages in thread
From: Francois Chouinard @ 2008-05-14 18:27 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 272 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gdb-bug2457.patch --]
[-- Type: text/x-diff; name=gdb-bug2457.patch, Size: 1334 bytes --]
### 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 */
+ }
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));
}
breakpoints_changed ();
breakpoint_modify_event (b->number);
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Patch for bug2457
2008-05-14 18:27 Patch for bug2457 Francois Chouinard
@ 2008-05-14 21:59 ` Vladimir Prus
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Prus @ 2008-05-14 21:59 UTC (permalink / raw)
To: gdb-patches
> 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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-14 18:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-14 18:27 Patch for bug2457 Francois Chouinard
2008-05-14 21:59 ` Vladimir Prus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox