From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28065 invoked by alias); 8 Jan 2007 15:55:37 -0000 Received: (qmail 28049 invoked by uid 22791); 8 Jan 2007 15:55:37 -0000 X-Spam-Check-By: sourceware.org Received: from wr-out-0506.google.com (HELO wr-out-0506.google.com) (64.233.184.229) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 08 Jan 2007 15:55:33 +0000 Received: by wr-out-0506.google.com with SMTP id 71so1135501wri for ; Mon, 08 Jan 2007 07:55:31 -0800 (PST) Received: by 10.90.113.18 with SMTP id l18mr2164740agc.1168271731468; Mon, 08 Jan 2007 07:55:31 -0800 (PST) Received: by 10.90.66.1 with HTTP; Mon, 8 Jan 2007 07:55:31 -0800 (PST) Message-ID: <366c6f340701080755p2fcc08caq9bdc1d4d9debdd5b@mail.gmail.com> Date: Mon, 08 Jan 2007 15:55:00 -0000 From: "Peng Yu" To: gdb@sourceware.org Subject: Debugging static variable in inlined member function 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-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00117.txt.bz2 Hi, I have the following program listed below this email. I can not print _a in the inlined version. But it is OK to print _a in the non-inlined version. Can you tell me how to debug the inlined version of _a? (gdb) s main () at main.cc:32 32 std::cout << a.a() << std::endl; (gdb) s A::a (this=0xbff21077) at main.cc:11 11 std::cout << "inline" << std::endl; (gdb) n inline 12 ++ _a; (gdb) p _a No symbol "_a" in current context. Thanks, Peng #include #define INLINE class A { public: A() { } #ifdef INLINE int a() { static int _a = 10; std::cout << "inline" << std::endl; ++ _a; return _a; } #else int a(); #endif private: }; #ifndef INLINE int A::a() { static int _a = 10; std::cout << "not inline" << std::endl; ++ _a; return _a; } #endif int main() { A a; std::cout << a.a() << std::endl; }