Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to skip stepping into files in GDB

📅 2018-Jul-03 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

Visual Studio C++ debugger has a feature called Just My Code which helps you to step over external code, like that in STL, and only step through the code of your own project. GDB does not have this feature at the time of this writing.

However, GDB has a skip -gfile feature that can be used in a similar way. You pass this command a glob pattern of files to ignore during stepping.

For example, to skip stepping into the source files of STL implementations on my system I use:

skip -gfile /usr/include/c++/5/bits/*

This works because the STL implementation files on my system are located at the above path.

Note that this feature requires GDB 7.12 or later.

Reference: GDB Skipping over files and functions

Tried with: GDB 8.1 and Ubuntu 16.04