This is the mail archive of the
mailing list for the GDB project.
Re: conditional breakpoints for strings
- From: Anitha Boyapati <anithab at sankhya dot com>
- To: Daniel Jacobowitz <drow at false dot org>
- Cc: gdb at sourceware dot org
- Date: Wed, 24 Oct 2007 18:41:08 +0530 (IST)
- Subject: Re: conditional breakpoints for strings
On Wed, 24 Oct 2007, Daniel Jacobowitz wrote:
> On Wed, Oct 24, 2007 at 05:58:56PM +0530, Anitha Boyapati wrote:
> > Hi,
> > On Wed, 24 Oct 2007, Daniel Jacobowitz wrote:
> > > You probably want to use at least one temporary variable to do this
> > > sort of thing. GDB evaluates C++ expressions with user defined
> > I did it with (strcmp(...) == 0). It worked that way probably because
> > strcmp() takes care of memory alloc and type casting issues. I think this
> > is fine for me now. Thanks.
> If you expect the breakpoint to hit more than a few times, I still
> recommend a temporary variable.
> (gdb) set $str = "hello"
> (gdb) cond 1 strcmp (s.whatever, $str) == 0
> Otherwise you will call malloc at every breakpoint.
> > This is quite interesting. Maybe I would just look into its internals.
> > Generally speaking, why is this char*->string so hard ?
> Two parts. One is that GDB does not know how to construct new
> objects. The other is that figuring out which constructors or
> operators to call is complicated; do you convert std::string to
> char * or char * to std::string, for instance. The C++ language
> standard has pages and pages of rules for this sort of thing.
Thanks. That gives a basic idea.
@S A N K H Y A