This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug breakpoints/9562] Incorrect handling of erroneous breakpoint conditions


------- 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]