How to avoid entering library's source files while debugging in Qt Creator with gdb?

前端 未结 4 957
走了就别回头了
走了就别回头了 2020-12-03 03:00

How can I configure Qt Creator and/or gdb so that while debugging my program using Qt libraries the debugger would avoid stepping into Qt\'s source files?

4条回答
  •  萌比男神i
    2020-12-03 03:41

    The feature you want (as described by rpg) is not available from GDB, and IMHO would be difficult to use if it were implemented.

    A similar, but simpler to use fstep feature is proposed for GDB. Given:

    foo((string("Hello") + string(" World!)).c_str());
    

    the fstep would skip all calls on the current line, except the last one (thus skipping string constructors, operator+(), and c_str(), and stepping only into foo).

    This hasn't been implemented either, but likely will be in a couple of month (it's very useful for C++ debugging).

    In the mean time, you can approximate the feature by setting a temporary breakpoint:

    (gdb) list
    1       #include 
    2       #include 
    3       using namespace std;
    4
    5       void foo(const char *s)
    6       {
    7         cout << s << endl;
    8       }
    9
    10      int main()
    11      {
    12        foo((string("Hello") + string(" World!")).c_str());
    13        return 0;
    14      }
    (gdb) b main
    Breakpoint 2 at 0x8048901: file t.cc, line 12.
    (gdb) run
    
    Breakpoint 1, main () at t.cc:12
    12        foo((string("Hello") + string(" World!")).c_str());
    (gdb) tb foo
    Breakpoint 3 at 0x80488ca: file t.cc, line 7.
    (gdb) c
    foo (s=0x804a1f4 "Hello World!") at t.cc:7
    7         cout << s << endl;
    (gdb) q
    

提交回复
热议问题