This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug breakpoints/9562] Incorrect handling of erroneous breakpoint conditions
- From: "fchouinard at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: 7 Jan 2009 16:20:30 -0000
- Subject: [Bug breakpoints/9562] Incorrect handling of erroneous breakpoint conditions
- References: <20080513215801.9562.fchouinard@gmail.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From fchouinard at gmail dot com 2009-01-07 16:20 -------
Created an attachment (id=3644)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=3644&action=view)
Patch for invalid breakpoint condition handling
Hi,
This is a rather old version (May 08) of the patch and the line numbers are
almost certainly wrong. (I a still using an old GDB so maybe this isn't even a
problem anymore.)
Anyway, the patch is trivial and here's the gist of it:
file: breakpoint.c
function static void condition_command (char *arg, int from_tty)
...
/* Remove any existing condition */
if (b->cond_string != NULL)
{
xfree (b->cond_string);
b->cond_string = NULL; /* Keep in sync */
}
if (*p == 0)
{
/* b->cond_string = NULL; -- already taken care of */
if (from_tty)
printf_filtered (_("Breakpoint %d now unconditional.\n"), bnum);
}
else
{
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)); -- wait for a
successful parsing before setting the condition */
b->condition_not_parsed = 0;
for (loc = b->loc; loc; loc = loc->next)
{
arg = p;
loc->cond =
parse_exp_1 (&arg, block_for_pc (loc->address), 0);
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 ();
observer_notify_breakpoint_modified (b->number);
...
Some notes:
You will notice that I presume it is better to clear a breakpoint condition
than to set it to garbage. Maybe this is not GDB's preferred way to handle that
type of situation.
This is enforced by clearing the condition string pointer when the condition
string itself is cleared. The breakpoint condition will be set only after the
new condition string is successfully parsed. (As mentioned earlier, it hardly
gets more trivial than this :-)
Best Regards,
/fc
--
http://sourceware.org/bugzilla/show_bug.cgi?id=9562
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.