From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2985 invoked by alias); 31 Aug 2006 12:05:56 -0000 Received: (qmail 2977 invoked by uid 22791); 31 Aug 2006 12:05:55 -0000 X-Spam-Check-By: sourceware.org Received: from mailgw2.technion.ac.il (HELO mailgw2.technion.ac.il) (132.68.238.33) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 31 Aug 2006 12:05:53 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgw2.technion.ac.il (Postfix) with ESMTP id 87FDD3904AA for ; Thu, 31 Aug 2006 15:05:50 +0300 (IDT) Received: from mailgw2.technion.ac.il ([127.0.0.1]) by localhost (mailgw2.technion.ac.il [127.0.0.1]) (amavisd-new, port 10024) with LMTP id XjTlr7H0COOP for ; Thu, 31 Aug 2006 15:05:50 +0300 (IDT) Received: from techunix.technion.ac.il (techunix.technion.ac.il [132.68.1.28]) by mailgw2.technion.ac.il (Postfix) with ESMTP id 67EF93904A6 for ; Thu, 31 Aug 2006 15:05:50 +0300 (IDT) Received: from [127.0.0.1] (techunix.technion.ac.il [132.68.1.28]) by techunix.technion.ac.il (Postfix) with ESMTP id 2772E149E1; Thu, 31 Aug 2006 15:05:50 +0300 (IDT) (envelope-from mveksler@tx.technion.ac.il) Message-ID: <44F6D09D.9050306@tx.technion.ac.il> Date: Thu, 31 Aug 2006 12:05:00 -0000 From: Michael Veksler User-Agent: Thunderbird 1.5.0.5 (X11/20060726) MIME-Version: 1.0 To: Michael Veksler , gdb@sourceware.org Subject: Re: How to call operator<< functions? References: <44F5645F.4000301@tx.technion.ac.il> <20060830124640.GC19163@nevyn.them.org> <44F5EF97.3020906@tx.technion.ac.il> <20060830202352.GA2018@nevyn.them.org> <44F5F8ED.3090300@tx.technion.ac.il> <20060830205421.GA3261@nevyn.them.org> In-Reply-To: <20060830205421.GA3261@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-08/txt/msg00271.txt.bz2 Daniel Jacobowitz wrote: > On Wed, Aug 30, 2006 at 11:45:33PM +0300, Michael Veksler wrote: >> Great progress. The most annoying and common failures I have used to >> be seeing is no more. > > I will test and commit the patch (but not right this moment). > No hurry, I have managed for eight years, I can cope with it a bit more. >> The other annoying issues sorted by decreasing annoyance : >> - this->Print is not always found (I'll try to create a small >> test-case later). > > I think my other changes will help here, though I'm not sure. I doubt they will. I have produced a complete test case for that. See below. >> - std::cout related crashes > > Fred's pegged this one I suspect. This is a serious bug and we need to > fix it, but it will be a bit tricky. My following test case may be related to this. >> - print myCout << x --- won't work need to resort to >> print 'operator<<........'(myCout, x) > > I think that foo::operator<< is supported, but operator<<(foo&,...) > isn't. Or else something's wrong with the support. Well, it works without the std:: as the prefix of operator<<. I hoped that just using << (as in C++) would just work. ========== Here is the test case. => cat cout-gdb2.cpp #include using namespace std; extern int forceLink; struct A { virtual void Print(ostream &out) const = 0; }; struct B : public A { virtual void Print(ostream &out) const ; }; void B::Print(ostream &out) const { out << "Enter B::Print() this=" << this << endl; } ostream & operator<<(ostream & out, const A& data) { data.Print(out); } int main() { B x; const A & ref_x = x; ref_x.Print(cout); return forceLink; } => cat myCout.cpp #include using namespace std; ostream myCout(cout.rdbuf()); // A trick to force the linker put this object file into the executable int forceLink=0; => g++ -g cout-gdb.cpp myCout.cpp => gdb-6.5 -silent a.out Using host libthread_db library "/lib/tls/libthread_db.so.1". (gdb) b 30 Breakpoint 1 at 0x8048a62: file cout-gdb.cpp, line 30. (gdb) r Starting program: /home/veksler/a.out Enter B::Print() this=0xbfffec00 Breakpoint 1, main () at cout-gdb.cpp:30 30 return forceLink; (gdb) p myCout $1 = (gdb) p x.Print(myCout) Cannot resolve method B::Print to any overloaded instance (gdb) p x.Print $2 = &B::Print(std::ostream&) const (gdb) p $2(&x, myCout) Enter B::Print() this=0xbfffec00 $3 = void (gdb)