[8/9] multiple locations

Mark Kettenis mark.kettenis@xs4all.nl
Sat Sep 8 13:17:00 GMT 2007


> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Sat, 8 Sep 2007 02:48:52 +0400
> 
> This patch allows a breakpoint to have several breakpoint locations.
> There's lot of mechanical changes -- from iteration over breakpoints
> to iteration over locations. Also, this splits breakpoint enable/disable
> state, changeable by user, from 'shlib_disabled' state, maintained by
> gdb and stored inside location. The breakpoint printing code is modified
> to print locations of breakpoint. OK?
> 
> - Volodya
> 
>    /* 1 */
>    annotate_field (0);
> -  ui_out_field_int (uiout, "number", b->number);
> +  if (part_of_multiple)
> +    {
> +      char buf[30];
> +      sprintf (buf, "%d.%d", b->number, loc_number);

Please don't use sprintf(); it's an evil function since it doesn't
check for buffer overflows.  And even when you can prove that the
buffer is large enough, it's better not to use it, to make auditing
the code easier.  So please use xsnprintf() (or snprintf() outside of
GDB).

Or if you want to address Eli's concerns, you could use xasprintf, but
make sure you xfree() the memory allocated by it.

Mark



More information about the Gdb-patches mailing list