From: Daniel Jacobowitz <drow@false.org>
To: Michael Veksler <mveksler@techunix.technion.ac.il>
Cc: gdb@sourceware.org
Subject: Re: How to call operator<< functions?
Date: Wed, 30 Aug 2006 12:46:00 -0000 [thread overview]
Message-ID: <20060830124640.GC19163@nevyn.them.org> (raw)
In-Reply-To: <44F5645F.4000301@tx.technion.ac.il>
As a general note: the most useful thing to accompany any bug report is
a test case! :-) We can't fix them without tests.
On Wed, Aug 30, 2006 at 01:11:43PM +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:
Fred's response seems reasonable; that might be the problem, or it
might be something else. If you have a testcase, please post it.
> (gdb) p pd.Print(gecLog)
> Cannot resolve method (null)Print to any overloaded instance
Ditto. I've never seen this error before.
> --------------------------------------
> I wanted to do the same for operator<<:
> (gdb) p 'operator<<(std::ostream&, MyClass const&)'
> $17 = {ostream &(ostream &, const class MyClass
> &)} 0x8068a00 <operator<<(std::ostream&, MyClass const&)>
> (gdb) p $17(gecLog, *pd)
> Program received signal SIGSEGV, Segmentation fault.
> -----------------------
You can just use "print gecLog << *pd". Does that work better?
Anyway, I would have expected calling the operator to work.
With tests for these bugs we can make the next GDB release the
best ever for C++.
> Print(cerr). Sometimes, while debugging a piece of code, that a vital
> object has <<, but no DebugPrint, and *that* really frustrates me -
> especially when I loose a 60 minutes debugging session to a SIGSEGV.
You might want to use set unwindonsignal, then, as it suggests.
There's some risk associated, but it usually works. You can also
use "return" to get out of the called function, but make sure you tell
GDB not to pass the sigsegv when you continue.
--
Daniel Jacobowitz
CodeSourcery
next prev parent reply other threads:[~2006-08-30 12:46 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 ` Daniel Jacobowitz [this message]
2006-08-30 20:05 ` How to call operator<< functions? 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
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=20060830124640.GC19163@nevyn.them.org \
--to=drow@false.org \
--cc=gdb@sourceware.org \
--cc=mveksler@techunix.technion.ac.il \
/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