This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to call operator<< functions?


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]