Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* 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

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