From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26935 invoked by alias); 15 Dec 2002 03:59:15 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 26927 invoked from network); 15 Dec 2002 03:59:14 -0000 Received: from unknown (HELO crack.them.org) (65.125.64.184) by sources.redhat.com with SMTP; 15 Dec 2002 03:59:14 -0000 Received: from nevyn.them.org ([66.93.61.169] ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 18NRoO-0005gz-00; Sat, 14 Dec 2002 23:59:36 -0600 Received: from drow by nevyn.them.org with local (Exim 3.36 #1 (Debian)) id 18NPwp-0001LG-00; Sat, 14 Dec 2002 23:00:11 -0500 Date: Sat, 14 Dec 2002 19:59:00 -0000 From: Daniel Jacobowitz To: Jacques Le Normand Cc: gdb@sources.redhat.com Subject: Re: casting in gdb Message-ID: <20021215040010.GA4986@nevyn.them.org> Mail-Followup-To: Jacques Le Normand , gdb@sources.redhat.com References: <002201c2a3ed$02a1f3e0$0100a8c0@ehville> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <002201c2a3ed$02a1f3e0$0100a8c0@ehville> User-Agent: Mutt/1.5.1i X-SW-Source: 2002-12/txt/msg00210.txt.bz2 On Sat, Dec 14, 2002 at 10:49:46PM -0500, Jacques Le Normand wrote: > > > > That explains alot, thanks > Would you know how to tell g++ to keep all the methods, even when they're > not used? You can't; you've gotta add a dummy function which uses them, or explicitly instantiate them. > Say I have a map m, how would I get gdb to display m["foo"] ? > It > gives me the silly "function expects something else" error, which I can > understand since gdb won't cast from char* to string. I'm guessing I need > to > define my own subroutines. Pretty much. Some day you GDB may do this for you but it doesn't right now. > --Jacques > > ----- Original Message ----- > > From: "Daniel Jacobowitz" > > To: "Jacques Le Normand" > > Cc: "Daniel Berlin" ; > > Sent: Saturday, December 14, 2002 2:35 AM > > Subject: Re: casting in gdb > > > > > > > On Fri, Dec 13, 2002 at 02:43:17PM -0500, Jacques Le Normand wrote: > > > > here you go, thanks for lending a hand... > > > > > > > > [countchocula@chocoland countchocula]$ g++ -ggdb test.cpp -o test.o > > > > [countchocula@chocoland countchocula]$ gdb test.o > > > > GNU gdb Red Hat Linux (5.2.1-4) > > > > Copyright 2002 Free Software Foundation, Inc. > > > > GDB is free software, covered by the GNU General Public License, and > you > > are > > > > welcome to change it and/or distribute copies of it under certain > > > > conditions. > > > > Type "show copying" to see the conditions. > > > > There is absolutely no warranty for GDB. Type "show warranty" for > > details. > > > > This GDB was configured as "i386-redhat-linux"... > > > > (gdb) b 10 > > > > Breakpoint 1 at 0x80486f5: file test.cpp, line 10. > > > > (gdb) r > > > > Starting program: /home/countchocula/test.o > > > > > > > > Breakpoint 1, main () at test.cpp:10 > > > > 10 a.push_back(2); > > > > (gdb) p a[0] > > > > One of the arguments you tried to pass to operator[] could not be > > converted > > > > to w > > > > hat the function wants. > > > > (gdb) > > > > > > This one's pretty simple once you figure it out. The error message is > > > really bad; I'll hold on to this and try to improve it. > > > > > > Your program doesn't _use_ operator[]. So it doesn't get compiled into > > > the program, and GDB can't call it to figure out what to do. > > > > > > What happens if you add a call to the operator? > > > > > > [I noticed some other quirks; for instance, if your program only uses > > > the mutable version and GDB finds the const version first, it may get > > > confused...] > > > > > > -- > > > Daniel Jacobowitz > > > MontaVista Software Debian GNU/Linux Developer > > > > > > > -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer