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:

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

> operators by calling the operators, and it evaluates strings by
> calling malloc in the program.  I believe there are three function
> calls in s == "hello" - one for malloc(6), one for char * to string
> conversion, and one to operator==.
> 
> I see that it's GDB segfaulting, not your program.  If this still
> happens with a newer version of GDB, we could look into it.  But
> I get:
> 
> Error in testing breakpoint condition:
> Invalid cast.
> 
> GDB probably doesn't support the char* -> string constructor.  That's
> one of the parts of C++ that's very hard to support in the debugger.
> 
> 

This is quite interesting. Maybe I would just look into its internals.
Generally speaking, why is this char*->string so hard ? 

-- 
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]