This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GDB "step" not stopping for some inline functions


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]