From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15990 invoked by alias); 29 Oct 2006 21:01:41 -0000 Received: (qmail 15979 invoked by uid 22791); 29 Oct 2006 21:01:41 -0000 X-Spam-Check-By: sourceware.org Received: from nf-out-0910.google.com (HELO nf-out-0910.google.com) (64.233.182.184) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 29 Oct 2006 21:01:39 +0000 Received: by nf-out-0910.google.com with SMTP id o25so2698625nfa for ; Sun, 29 Oct 2006 13:01:34 -0800 (PST) Received: by 10.48.254.1 with SMTP id b1mr4175260nfi; Sun, 29 Oct 2006 13:01:34 -0800 (PST) Received: by 10.49.61.8 with HTTP; Sun, 29 Oct 2006 13:01:34 -0800 (PST) Message-ID: <366c6f340610291301p523de441r6b691975822a9131@mail.gmail.com> Date: Sun, 29 Oct 2006 21:01:00 -0000 From: "Peng Yu" To: gdb@sourceware.org Subject: How to debug C++ functor in gdb? MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00283.txt.bz2 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 >::_f Thanks, Peng #include template class functor { public: functor(const F &f) : _f(f) { } typename F::result_type operator()(double x) const { return _f(static_cast(x)); }//set break point here in gdb private: F _f; }; template struct function : public std::unary_function { double operator()(T x) const { return static_cast(x); } }; int main() { functor > g((function())); g(1.1); }