From: Michael Veksler <mveksler@techunix.technion.ac.il>
To: Michael Veksler <mveksler@techunix.technion.ac.il>, gdb@sourceware.org
Subject: Re: How to call operator<< functions?
Date: Thu, 31 Aug 2006 12:05:00 -0000 [thread overview]
Message-ID: <44F6D09D.9050306@tx.technion.ac.il> (raw)
In-Reply-To: <20060830205421.GA3261@nevyn.them.org>
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 <iostream>
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 <iostream>
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 = <incomplete type>
(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)
prev parent reply other threads:[~2006-08-31 12:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-30 10:11 Michael Veksler
2006-08-30 11:13 ` Frederic RISS
2006-08-30 13:30 ` Frederic RISS
2006-08-30 13:40 ` Breakpoint Handling in GDB Veenu Verma (AS/EAB)
2006-08-30 13:43 ` Daniel Jacobowitz
2006-08-30 20:30 ` Michael Snyder
2006-08-31 11:34 ` Get versioned minsyms from dynamic symtab (Was: Re: How to call operator<< functions?) Frederic RISS
2006-08-31 12:09 ` Michael Veksler
2006-08-31 12:26 ` Frederic RISS
2006-08-31 13:02 ` Michael Veksler
2006-08-31 13:23 ` Frederic RISS
2006-08-31 16:48 ` Frederic RISS
2006-08-31 16:57 ` Daniel Jacobowitz
2006-08-31 17:41 ` Frédéric Riss
2006-08-31 17:45 ` Daniel Jacobowitz
2006-08-31 19:48 ` Michael Veksler
2006-08-31 19:52 ` Daniel Jacobowitz
2006-08-30 12:46 ` How to call operator<< functions? Daniel Jacobowitz
2006-08-30 20:05 ` Michael Veksler
2006-08-30 20:24 ` Daniel Jacobowitz
2006-08-30 20:45 ` Michael Veksler
2006-08-30 20:54 ` Daniel Jacobowitz
2006-08-31 12:05 ` Michael Veksler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44F6D09D.9050306@tx.technion.ac.il \
--to=mveksler@techunix.technion.ac.il \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox