* conditional breakpoint with (char* ) string condition
@ 2006-05-12 12:43 Fabio De Bona
2006-05-12 12:45 ` Eli Zaretskii
0 siblings, 1 reply; 14+ messages in thread
From: Fabio De Bona @ 2006-05-12 12:43 UTC (permalink / raw)
To: gdb
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-12 12:43 conditional breakpoint with (char* ) string condition Fabio De Bona
@ 2006-05-12 12:45 ` Eli Zaretskii
2006-05-12 13:53 ` Daniel Jacobowitz
0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2006-05-12 12:45 UTC (permalink / raw)
To: Fabio De Bona; +Cc: gdb
> Date: Fri, 12 May 2006 11:37:56 +0200
> From: Fabio De Bona <Auslieferator@gmx.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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-12 12:45 ` Eli Zaretskii
@ 2006-05-12 13:53 ` Daniel Jacobowitz
2006-05-12 16:09 ` Eli Zaretskii
0 siblings, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2006-05-12 13:53 UTC (permalink / raw)
To: Fabio De Bona, Eli Zaretskii; +Cc: gdb
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 <Auslieferator@gmx.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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-12 13:53 ` Daniel Jacobowitz
@ 2006-05-12 16:09 ` Eli Zaretskii
2006-05-12 16:21 ` Daniel Jacobowitz
0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2006-05-12 16:09 UTC (permalink / raw)
To: Fabio De Bona, gdb
> Date: Fri, 12 May 2006 08:45:27 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb@sources.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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-12 16:09 ` Eli Zaretskii
@ 2006-05-12 16:21 ` Daniel Jacobowitz
2006-05-12 18:00 ` PAUL GILLIAM
0 siblings, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2006-05-12 16:21 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Fabio De Bona, gdb
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 <drow@false.org>
> > Cc: gdb@sources.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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-12 16:21 ` Daniel Jacobowitz
@ 2006-05-12 18:00 ` PAUL GILLIAM
2006-05-12 18:59 ` Jim Blandy
2006-05-12 20:36 ` Eli Zaretskii
0 siblings, 2 replies; 14+ messages in thread
From: PAUL GILLIAM @ 2006-05-12 18:00 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Eli Zaretskii, Fabio De Bona, gdb
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 <drow@false.org>
> > > Cc: gdb@sources.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 #=-
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-12 18:00 ` PAUL GILLIAM
@ 2006-05-12 18:59 ` Jim Blandy
2006-05-15 17:55 ` Daniel Jacobowitz
2006-05-12 20:36 ` Eli Zaretskii
1 sibling, 1 reply; 14+ messages in thread
From: Jim Blandy @ 2006-05-12 18:59 UTC (permalink / raw)
To: pgilliam; +Cc: Daniel Jacobowitz, Eli Zaretskii, Fabio De Bona, gdb
PAUL GILLIAM <pgilliam@us.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 <drow@false.org>
>> > > Cc: gdb@sources.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?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-12 18:00 ` PAUL GILLIAM
2006-05-12 18:59 ` Jim Blandy
@ 2006-05-12 20:36 ` Eli Zaretskii
2006-05-13 11:24 ` PAUL GILLIAM
1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2006-05-12 20:36 UTC (permalink / raw)
To: pgilliam; +Cc: drow, Auslieferator, gdb
> From: PAUL GILLIAM <pgilliam@us.ibm.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, Fabio De Bona <Auslieferator@gmx.net>,
> gdb@sources.redhat.com
> Date: Fri, 12 May 2006 08:05:32 -0700
>
> How about strlen as well?
Where would it be useful?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-12 20:36 ` Eli Zaretskii
@ 2006-05-13 11:24 ` PAUL GILLIAM
0 siblings, 0 replies; 14+ messages in thread
From: PAUL GILLIAM @ 2006-05-13 11:24 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: drow, Auslieferator, gdb
On Fri, 2006-05-12 at 21:24 +0300, Eli Zaretskii wrote:
> > From: PAUL GILLIAM <pgilliam@us.ibm.com>
> > Cc: Eli Zaretskii <eliz@gnu.org>, Fabio De Bona <Auslieferator@gmx.net>,
> > gdb@sources.redhat.com
> > Date: Fri, 12 May 2006 08:05:32 -0700
> >
> > How about strlen as well?
>
> Where would it be useful?
Here is an admittedly contrived example. Say we had a target program
that was writing a 'progress meter' to stderr with the following code:
void progress_tick (buf)
{
void strcat (buf, ".");
fprintf (stderr, "\r%s", buf);
}
main ()
{
char progress[1024] = { 0 };
. . .
while ( ! done)
{
progress_tick (progress);
real_work ();
}
return 0;
}
Then in GDB you could do this:
start
b real_work if $_strlen(progress) >= 5
Yes, this example might not be 'real world', but strlen just seems to go
with strcmp.
-=# Paul #=-
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-12 18:59 ` Jim Blandy
@ 2006-05-15 17:55 ` Daniel Jacobowitz
2006-05-15 19:17 ` Jim Blandy
0 siblings, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2006-05-15 17:55 UTC (permalink / raw)
To: Jim Blandy; +Cc: pgilliam, Eli Zaretskii, Fabio De Bona, gdb
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-15 17:55 ` Daniel Jacobowitz
@ 2006-05-15 19:17 ` Jim Blandy
2006-05-15 19:51 ` Daniel Jacobowitz
0 siblings, 1 reply; 14+ messages in thread
From: Jim Blandy @ 2006-05-15 19:17 UTC (permalink / raw)
To: pgilliam; +Cc: Eli Zaretskii, Fabio De Bona, gdb
Daniel Jacobowitz <drow@false.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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-15 19:17 ` Jim Blandy
@ 2006-05-15 19:51 ` Daniel Jacobowitz
2006-05-15 22:44 ` Jim Blandy
0 siblings, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2006-05-15 19:51 UTC (permalink / raw)
To: Jim Blandy; +Cc: pgilliam, Eli Zaretskii, Fabio De Bona, gdb
On Mon, May 15, 2006 at 11:50:30AM -0700, Jim Blandy wrote:
>
> Daniel Jacobowitz <drow@false.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, I was serious about $gdb_...
> Hey, maybe we could just take over some prefix like $- that doesn't
> conflict with the user and register namespace at all.
Nice try :-)
(gdb) p 2
$1 = 2
(gdb) p $-1
$2 = 1
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-15 19:51 ` Daniel Jacobowitz
@ 2006-05-15 22:44 ` Jim Blandy
2006-05-16 12:39 ` Joel Brobecker
0 siblings, 1 reply; 14+ messages in thread
From: Jim Blandy @ 2006-05-15 22:44 UTC (permalink / raw)
To: pgilliam; +Cc: Eli Zaretskii, Fabio De Bona, gdb
Daniel Jacobowitz <drow@false.org> writes:
> On Mon, May 15, 2006 at 11:50:30AM -0700, Jim Blandy wrote:
>>
>> Daniel Jacobowitz <drow@false.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, I was serious about $gdb_...
Oh. Sorry. I thought you were mocking my suggestion.
I guess I feel like we're encroaching on the user's space no matter
what we do, so we might as well make it terse. And there are are $_
variables defined by GDB already, I think. But I'd be happy with '_'
or 'gdb_'.
>> Hey, maybe we could just take over some prefix like $- that doesn't
>> conflict with the user and register namespace at all.
>
> Nice try :-)
>
> (gdb) p 2
> $1 = 2
> (gdb) p $-1
> $2 = 1
Darn. I'd forgotten $ is a token all by itself.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: conditional breakpoint with (char* ) string condition
2006-05-15 22:44 ` Jim Blandy
@ 2006-05-16 12:39 ` Joel Brobecker
0 siblings, 0 replies; 14+ messages in thread
From: Joel Brobecker @ 2006-05-16 12:39 UTC (permalink / raw)
To: Jim Blandy; +Cc: pgilliam, Eli Zaretskii, Fabio De Bona, gdb
> I guess I feel like we're encroaching on the user's space no matter
> what we do, so we might as well make it terse. And there are are $_
> variables defined by GDB already, I think. But I'd be happy with '_'
> or 'gdb_'.
I prefer $gdb_ to $_. It's not so much more typing and I find it clearer.
--
Joel
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2006-05-16 3:32 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-12 12:43 conditional breakpoint with (char* ) string condition Fabio De Bona
2006-05-12 12:45 ` Eli Zaretskii
2006-05-12 13:53 ` Daniel Jacobowitz
2006-05-12 16:09 ` Eli Zaretskii
2006-05-12 16:21 ` Daniel Jacobowitz
2006-05-12 18:00 ` PAUL GILLIAM
2006-05-12 18:59 ` Jim Blandy
2006-05-15 17:55 ` Daniel Jacobowitz
2006-05-15 19:17 ` Jim Blandy
2006-05-15 19:51 ` Daniel Jacobowitz
2006-05-15 22:44 ` Jim Blandy
2006-05-16 12:39 ` Joel Brobecker
2006-05-12 20:36 ` Eli Zaretskii
2006-05-13 11:24 ` PAUL GILLIAM
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox