From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14414 invoked by alias); 26 Nov 2013 17:46:25 -0000 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 Received: (qmail 14400 invoked by uid 89); 26 Nov 2013 17:46:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: fencepost.gnu.org Received: from Unknown (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 26 Nov 2013 17:45:48 +0000 Received: from 173-9-45-73-newengland.hfc.comcastbusiness.net ([173.9.45.73]:36323 helo=[10.1.37.145]) by fencepost.gnu.org with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1VlMhg-0003ee-Ad for gdb@sourceware.org; Tue, 26 Nov 2013 12:45:40 -0500 Message-ID: <1385487939.30213.417.camel@pdsdesk> Subject: GDB "step" not stopping for some inline functions From: Paul Smith Reply-To: psmith@gnu.org To: gdb@sourceware.org Date: Tue, 26 Nov 2013 17:46:00 -0000 Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00098.txt.bz2 Hi all. I'm using GCC 4.8.2 + GDB 7.6.1 (with Python 2.7.6), on a GNU/Linux x86_64 system. I've also tried this with GCC 4.8.1 + GDB 7.6 (with Python 2.7.5) with the same problem. If I try to step into a certain inline function then instead of stopping inside the function, the program runs to completion (or to the next breakpoint)! I don't seem to have this problem for other inline or non-inline functions. It may not be limited to this one inline function; I haven't tried them all. But I've tried some others and they've worked fine. If I use "n" instead of "s", it correctly steps over the inline function call and stops after it completes. Also if I use "si" instead it will properly step one instruction and if I do that until I get into the inline function (for example I move to the opening brace of the inline function), then I can start stepping normally again. For example here's a GDB invocation on a gtest unit test program: $ gdb ./BaseTest/LogTest.gtest GNU gdb (GDB) 7.6.1 ... This GDB was configured as "x86_64-unknown-linux-gnu". ... Reading symbols from /home/workspaces/psmith/ws3/BaseTest/LogTest.gtest...done. (gdb) br LogTest.cpp:90 Breakpoint 1 at 0x4493fc: file /home/workspaces/psmith/ws3/BaseTest/test/LogTest.cpp, line 90. (gdb) run Starting program: /home/workspaces/psmith/ws3/./BaseTest/LogTest.gtest [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Running main() from gtest_main.cc [==========] Running 3 tests from 1 test case. [----------] Global test environment set-up. [----------] 3 tests from LogTest [ RUN ] LogTest.TestSimpleMessage [ OK ] LogTest.TestSimpleMessage (0 ms) [ RUN ] LogTest.TestSimpleMessageTwo Breakpoint 1, LogTest_TestSimpleMessageTwo_Test::TestBody (this=0x71cba0) at /home/workspaces/psmith/ws3/BaseTest/test/LogTest.cpp:90 90 Log::debug("%s\n", MESSAGE); (gdb) s [ OK ] LogTest.TestSimpleMessageTwo (1442 ms) [ RUN ] LogTest.TestBogusAssert [ OK ] LogTest.TestBogusAssert (1 ms) [----------] 3 tests from LogTest (1443 ms total) [----------] Global test environment tear-down [==========] 3 tests from 1 test case ran. (1443 ms total) [ PASSED ] 3 tests. [Inferior 1 (process 2384) exited normally] Ouch! Same thing if I set a breakpoint earlier, then use next to get to the Log::debug() line, then run "s"; it doesn't stop. The inline function is nothing magical; it looks like this: class Log { static int activeMask; inline static void debug(const char* text, ...) __attribute__((format(printf, 1, 2))); ... }; inline void Log::debug(const char* txt, ...) { int mask = LogDebug; if ((activeMask & mask) == 0) { return; } va_list args; va_start(args, txt); vlog(mask, txt, args); va_end(args); } I'm compiling with these flags: -std=c++11 -fPIC -fno-omit-frame-pointer -g (no optimization). Maybe it's the varargs stuff in the inline function that's causing problems? Does anyone else see anything like this, or have any thoughts? I can try to extract it out into a smaller test case if necessary.