This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How to call operator<< functions?
- From: Frederic RISS <frederic dot riss at st dot com>
- To: Michael Veksler <mveksler at techunix dot technion dot ac dot il>
- Cc: gdb at sourceware dot org
- Date: Wed, 30 Aug 2006 13:12:53 +0200
- Subject: Re: How to call operator<< functions?
- References: <44F5645F.4000301@tx.technion.ac.il>
On Wed, 2006-08-30 at 13:11 +0300, Michael Veksler wrote:
> Passing 'std::cout' seems impossible. Any attempt to pass std::cout
> crashes. To overcome this I define my own global
> ostream gecLog(cout.rdbuf());
> (or something similar) and recompile the code. This lets me pass gecLog
> instead of cout, and it _sometimes_ works:
Just to reply to this little part.
I've already encountered the issue with cout. In my case the _ZSt4cout
symbol was present in the debugged binary and (obviously) in libstdc++.
I _think_ that GDB resolved _ZSt4cout as if the symbol in the library
was used whereas the one in the executable was the right one. I can't
remember the reasons for this right now.
As a workaround, I passed '*(ostream*)<addr>' in place of std::cout. I
found <addr> using nm on my binary. This seemed to work if I remember
well. It's been a while though...
Hope this helps,
Fred.