List Info

Thread: conditional breakpoint with (char* ) string condition




conditional breakpoint with (char* ) string condition
user name
2006-05-12 09:37:56
Hi everyone,
I would like to set a conditional breakpoint with a
condition that 
depends on the value of
a char* string, i.e. something like

b gui/R.cpp:190 if cmd=="train" (doesn't work
of course)

resp.

b gui/R.cpp:190 if strcmp(cmd,"train")

is there a possibility to do this *without* changing the
code (like 
setting a boolean or so in the source).

Regards

Fabio
conditional breakpoint with (char* ) string condition
user name
2006-05-12 11:21:16
> Date: Fri, 12 May 2006 11:37:56 +0200
> From: Fabio De Bona <Auslieferatorgmx.net>
> 
> b gui/R.cpp:190 if cmd=="train" (doesn't
work of course)

But this should:

  b gui/R.cpp:190 if cmd[0]=='t' && cmd[1]=='r'
&& cmd[2]=='a' && cmd[3]=='i'

etc., you get the point.
conditional breakpoint with (char* ) string condition
user name
2006-05-12 12:45:27
On Fri, May 12, 2006 at 11:37:56AM +0200, Fabio De Bona
wrote:
> Hi everyone,
> I would like to set a conditional breakpoint with a
condition that 
> depends on the value of
> a char* string, i.e. something like
> 
> b gui/R.cpp:190 if cmd=="train" (doesn't
work of course)
> 
> resp.
> 
> b gui/R.cpp:190 if strcmp(cmd,"train")

This should actually work - although it's a bit slow to
implement.

On Fri, May 12, 2006 at 02:21:16PM +0300, Eli Zaretskii
wrote:
> > Date: Fri, 12 May 2006 11:37:56 +0200
> > From: Fabio De Bona <Auslieferatorgmx.net>
> > 
> > b gui/R.cpp:190 if cmd=="train"
(doesn't work of course)
> 
> But this should:
> 
>   b gui/R.cpp:190 if cmd[0]=='t' &&
cmd[1]=='r' && cmd[2]=='a' &&
cmd[3]=='i'
> 
> etc., you get the point.

I wonder.  Should we add some common builtin functions to
GDB?

  b gui/R.cpp:190 if $gdb_strcmp (cmd, "train")

[This might be quite a lot of work, since right now parsing
"train"
will cause us to malloc() in the program.]

-- 
Daniel Jacobowitz
CodeSourcery
conditional breakpoint with (char* ) string condition
user name
2006-05-12 13:49:49
> Date: Fri, 12 May 2006 08:45:27 -0400
> From: Daniel Jacobowitz <drowfalse.org>
> Cc: gdbsources.redhat.com
> 
> I wonder.  Should we add some common builtin functions
to GDB?
> 
>   b gui/R.cpp:190 if $gdb_strcmp (cmd,
"train")

It would be nice, I think.  `streq' might be a better name,
though.
conditional breakpoint with (char* ) string condition
user name
2006-05-12 13:54:20
On Fri, May 12, 2006 at 04:49:49PM +0300, Eli Zaretskii
wrote:
> > Date: Fri, 12 May 2006 08:45:27 -0400
> > From: Daniel Jacobowitz <drowfalse.org>
> > Cc: gdbsources.redhat.com
> > 
> > I wonder.  Should we add some common builtin
functions to GDB?
> > 
> >   b gui/R.cpp:190 if $gdb_strcmp (cmd,
"train")
> 
> It would be nice, I think.  `streq' might be a better
name, though.

Well, I'd rather have strcmp, but I agree that I botched it
- I was
going for something with the same semantics as C strcmp 

-- 
Daniel Jacobowitz
CodeSourcery
conditional breakpoint with (char* ) string condition
user name
2006-05-12 15:05:32
On Fri, 2006-05-12 at 09:54 -0400, Daniel Jacobowitz wrote:
> On Fri, May 12, 2006 at 04:49:49PM +0300, Eli Zaretskii
wrote:
> > > Date: Fri, 12 May 2006 08:45:27 -0400
> > > From: Daniel Jacobowitz <drowfalse.org>
> > > Cc: gdbsources.redhat.com
> > > 
> > > I wonder.  Should we add some common builtin
functions to GDB?
> > > 
> > >   b gui/R.cpp:190 if $gdb_strcmp (cmd,
"train")
> > 
> > It would be nice, I think.  `streq' might be a
better name, though.
> 
> Well, I'd rather have strcmp, but I agree that I
botched it - I was
> going for something with the same semantics as C strcmp

> 

IMHO, this is something that has been 'missing' from GDB
from day 1.
Building in some common functions into GDB would be a big
win.

How about strlen as well?

-=# Paul #=-

conditional breakpoint with (char* ) string condition
user name
2006-05-12 18:00:16
PAUL GILLIAM <pgilliamus.ibm.com> writes:
> On Fri, 2006-05-12 at 09:54 -0400, Daniel Jacobowitz
wrote:
>> On Fri, May 12, 2006 at 04:49:49PM +0300, Eli
Zaretskii wrote:
>> > > Date: Fri, 12 May 2006 08:45:27 -0400
>> > > From: Daniel Jacobowitz <drowfalse.org>
>> > > Cc: gdbsources.redhat.com
>> > > 
>> > > I wonder.  Should we add some common
builtin functions to GDB?
>> > > 
>> > >   b gui/R.cpp:190 if $gdb_strcmp (cmd,
"train")
>> > 
>> > It would be nice, I think.  `streq' might be
a better name, though.
>> 
>> Well, I'd rather have strcmp, but I agree that I
botched it - I was
>> going for something with the same semantics as C
strcmp 
>> 
>
> IMHO, this is something that has been 'missing' from
GDB from day 1.
> Building in some common functions into GDB would be a
big win.
>
> How about strlen as well?

I'm definitely in favor of $strcmp and $strlen.

Should we establish a convention of starting GDB-provided
convenience
variable names with _, to avoid conflicting with script
variables?
Thus, $_strcmp and $_strlen?
conditional breakpoint with (char* ) string condition
user name
2006-05-12 18:24:02
> From: PAUL GILLIAM <pgilliamus.ibm.com>
> Cc: Eli Zaretskii <elizgnu.org>, Fabio De Bona
<Auslieferatorgmx.net>,
>         gdbsources.redhat.com
> Date: Fri, 12 May 2006 08:05:32 -0700
> 
> How about strlen as well?

Where would it be useful?
conditional breakpoint with (char* ) string condition
user name
2006-05-15 14:58:43
On Fri, May 12, 2006 at 11:00:16AM -0700, Jim Blandy wrote:
> Should we establish a convention of starting
GDB-provided convenience
> variable names with _, to avoid conflicting with script
variables?
> Thus, $_strcmp and $_strlen?

Or should they have a $gdb_ prefix?  Or $_gdb_?

-- 
Daniel Jacobowitz
CodeSourcery
conditional breakpoint with (char* ) string condition
user name
2006-05-15 18:50:30
Daniel Jacobowitz <drowfalse.org> writes:
> On Fri, May 12, 2006 at 11:00:16AM -0700, Jim Blandy
wrote:
>> Should we establish a convention of starting
GDB-provided convenience
>> variable names with _, to avoid conflicting with
script variables?
>> Thus, $_strcmp and $_strlen?
>
> Or should they have a $gdb_ prefix?  Or $_gdb_?

Or
$this_is_a_gdb_variable_20060515_GNU_prvt_ISO_IEC_9989:1999_
?  
(There must be some way to get a UUID and 'http' in
there...)

Hey, maybe we could just take over some prefix like $- that
doesn't
conflict with the user and register namespace at all.
[1-10] [11-13]

about | contact  Other archives ( Real Estate discussion Medical topics )