From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32153 invoked by alias); 24 Oct 2007 13:05:13 -0000 Received: (qmail 32099 invoked by uid 22791); 24 Oct 2007 13:05:07 -0000 X-Spam-Check-By: sourceware.org Received: from Unknown (HELO pdns.sankhya.co.in) (210.212.208.205) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 24 Oct 2007 13:05:05 +0000 Received: from sankhya.com (sankhya-external [192.168.1.2]) by pdns.sankhya.co.in (8.12.11/8.12.10) with ESMTP id l9OCKCo2005789; Wed, 24 Oct 2007 17:50:12 +0530 Received: from sankhya.com (localhost [127.0.0.1]) by sankhya.com (8.12.8/8.12.5) with ESMTP id l9ODB8IK010698; Wed, 24 Oct 2007 18:41:08 +0530 Received: from localhost (anithab@localhost) by sankhya.com (8.12.8/8.12.5/Submit) with ESMTP id l9ODB867010694; Wed, 24 Oct 2007 18:41:08 +0530 Date: Wed, 24 Oct 2007 13:05:00 -0000 From: Anitha Boyapati To: Daniel Jacobowitz cc: gdb@sourceware.org Subject: Re: conditional breakpoints for strings In-Reply-To: <20071024123559.GA21751@caradoc.them.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-10/txt/msg00197.txt.bz2 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