From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6857 invoked by alias); 24 Oct 2007 12:36:06 -0000 Received: (qmail 6840 invoked by uid 22791); 24 Oct 2007 12:36:05 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 24 Oct 2007 12:36:02 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 1EE5E9833F; Wed, 24 Oct 2007 12:36:01 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 9E40E981F2; Wed, 24 Oct 2007 12:36:00 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.68) (envelope-from ) id 1IkfSp-0005fA-DD; Wed, 24 Oct 2007 08:35:59 -0400 Date: Wed, 24 Oct 2007 12:36:00 -0000 From: Daniel Jacobowitz To: Anitha Boyapati Cc: gdb@sourceware.org Subject: Re: conditional breakpoints for strings Message-ID: <20071024123559.GA21751@caradoc.them.org> Mail-Followup-To: Anitha Boyapati , gdb@sourceware.org References: <20071024115310.GA19251@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.15 (2007-04-09) 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/msg00196.txt.bz2 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. -- Daniel Jacobowitz CodeSourcery