Preventing GDB from stepping into a function (or file)

后端 未结 5 1576
心在旅途
心在旅途 2020-11-27 21:14

I have some C++ code like this that I\'m stepping through with GDB:

void foo(int num) { ... }

void main() {
  Baz baz;
  foo (baz.get());
}
<
5条回答
  •  执念已碎
    2020-11-27 21:53

    (I think this might be better suited as a comment rather than an answer, but I don't have enough reputation to add a comment yet.)

    So I've also been wanting to ignore STL, Boost, et al (collectively '3rd Party') files when debugging for a while. Yesterday I finally decided to look for a solution and it seems the nearest capability is the 'skip' command in GDB.

    I found the 'skip' ability in GDB to be helpful, but it's still a nuisance for me because my program uses a lot of STL and other "3rd Party" template code. In this case I have to mark a bunch of files as skip. After the 2nd time doing so I realized it would be more helpful to be able to skip an entire directory--and most helpful to skip a directory and all subdirectories. That way I can skip, for example, /usr since none of my code lives there and I typically have no interest in debugging through 3rd party code. So I extended the 'skip' command in gdb to support a new type 'dir'. I can now do this in gdb:

    skip dir /usr
    

    and then I'm never stopped in any of my 3rd party headers.

    Here's a webpage w/ this info + the patch if it helps anyone: info & patch to skip directories in GDB

提交回复
热议问题