* How to debug C++ functor in gdb?
@ 2006-10-29 21:01 Peng Yu
2006-10-29 23:20 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: Peng Yu @ 2006-10-29 21:01 UTC (permalink / raw)
To: gdb
Hi,
I have a test program using functor below.
I set a break point at the line indicated in the comment. Then I call
the following command in gdb. It failed. Is there any way that I can
call the functor _f?
(gdb) p _f(10)
Couldn't find method functor<function<int> >::_f
Thanks,
Peng
#include <functional>
template <typename F>
class functor {
public:
functor(const F &f) : _f(f) { }
typename F::result_type operator()(double x) const { return
_f(static_cast<int>(x)); }//set break point here in gdb
private:
F _f;
};
template <typename T>
struct function : public std::unary_function<T, double> {
double operator()(T x) const { return static_cast<double>(x); }
};
int main() {
functor<function<int> > g((function<int>()));
g(1.1);
}
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: How to debug C++ functor in gdb?
2006-10-29 21:01 How to debug C++ functor in gdb? Peng Yu
@ 2006-10-29 23:20 ` Andreas Schwab
2006-11-15 0:12 ` Peng Yu
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2006-10-29 23:20 UTC (permalink / raw)
To: Peng Yu; +Cc: gdb
"Peng Yu" <pengyu.ut@gmail.com> writes:
> I set a break point at the line indicated in the comment. Then I call
> the following command in gdb. It failed. Is there any way that I can
> call the functor _f?
>
> (gdb) p _f(10)
> Couldn't find method functor<function<int> >::_f
(gdb) p _f.'operator()'(10)
$1 = 10
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to debug C++ functor in gdb?
2006-10-29 23:20 ` Andreas Schwab
@ 2006-11-15 0:12 ` Peng Yu
2006-11-15 1:23 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: Peng Yu @ 2006-11-15 0:12 UTC (permalink / raw)
Cc: gdb
On 10/29/06, Andreas Schwab <schwab@suse.de> wrote:
> "Peng Yu" <pengyu.ut@gmail.com> writes:
>
> > I set a break point at the line indicated in the comment. Then I call
> > the following command in gdb. It failed. Is there any way that I can
> > call the functor _f?
> >
> > (gdb) p _f(10)
> > Couldn't find method functor<function<int> >::_f
>
> (gdb) p _f.'operator()'(10)
> $1 = 10
>
> Andreas.
Hi,
Is it syntax described in the manual somewhere?
Thanks,
Peng
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to debug C++ functor in gdb?
2006-11-15 0:12 ` Peng Yu
@ 2006-11-15 1:23 ` Andreas Schwab
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2006-11-15 1:23 UTC (permalink / raw)
To: Peng Yu; +Cc: gdb
"Peng Yu" <pengyu.ut@gmail.com> writes:
> On 10/29/06, Andreas Schwab <schwab@suse.de> wrote:
>> "Peng Yu" <pengyu.ut@gmail.com> writes:
>>
>> > I set a break point at the line indicated in the comment. Then I call
>> > the following command in gdb. It failed. Is there any way that I can
>> > call the functor _f?
>> >
>> > (gdb) p _f(10)
>> > Couldn't find method functor<function<int> >::_f
>>
>> (gdb) p _f.'operator()'(10)
>> $1 = 10
>>
>> Andreas.
>
> Hi,
>
> Is it syntax described in the manual somewhere?
operator() is normal C++ syntax.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-11-15 1:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-29 21:01 How to debug C++ functor in gdb? Peng Yu
2006-10-29 23:20 ` Andreas Schwab
2006-11-15 0:12 ` Peng Yu
2006-11-15 1:23 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox