skip to Main Content

Environment: Using Visual Studio Code with the Standard Microsoft C++ Debugging Extension. Using gdb as the underlying debugger.

For example: on the code below a step in on the commented line will jump to the standard string header.

Is there a way to avoid this?

#include <string>
#include <iostream>

int main()
{
    std::string a = "Example String"; /// < Step IN here 

    std::cout << a << std::endl; 
}

A more realistic example of why this is a problem:
In the case below I want to debug the a->methodToDebug()
but step in will send you to the source for the std::unique_ptr get method. You can still keep stepping in to get to your own code, but in more complicated code it becomes a pain.


#include <memory>

class A
{
public: 
    int methodToDebug() { 
        return -1 ;
    }
};

int main()
{
    auto a = std::make_unique<A>();

    auto s = a->methodToDebug(); // <<-- Step in here, goes to get().
}

2

Answers


  1. Chosen as BEST ANSWER

    It appears I can do this for recent versions of gdb(7.12.1 or higher) with the following in the .gdbinit file

    skip -gfi /usr/include/c++/*/*/*
    skip -gfi /usr/include/c++/*/*
    skip -gfi /usr/include/c++/*
    

  2. Turn on: Tools > Options > Debugging > General > [ ] Enable Just My Code.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search