This is the mail archive of the gdb@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]

Re: conditional breakpoints for strings


Hi,

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.

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

-- 
Regards,
Anitha B
@S A N K H Y A


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