VS Code "step into" debugger configuration

Viewed 2934

When I debug my C++ project in VS Code and toggle a breakpoint, The "step into" option redirecting me to external files/libraries, but I want to step only into my code.

I tried to add "justMyCode": true option in launch.js file, but it says this property is not allowed.

What can I do to go only through source code?

2 Answers

One thing could be done for this issue. I actually tested my own test program:

std::vector<std::string> name;

std::cout << "Enter a name: ";
std::getline(std::cin, name);

nameList.push_back(name); // BREAKPOINT

When we select Step Into in the breakpoint execution, it redirects into the definition of the function where it's actually defined, it's not going to debug only for your file in this case.

Step Into Type:

Step Into Type Debugging

Rather, you must use Step Over since it doesn't tries to find the function definitions and you would able to debug your content straightforwardly.

Step Over Type:

Step Over Type Debugging

The Step Into will certainly redirect you into the function definition wherever it's defined, if you want to know the declaration and other things about the related function, it's good opportunity to use Step Into. But in case you just want to debug the line only and not considering to go in depth and don't want to get jumped into another file, you must use Step Over.

If you want to know more about Step Into and Step Over, you can go through this Stack Overflow thread. I've found this helpful too.

This is not a perfect answer,

Suppose you are debugging code this:

func_that_we_care ( func_that_we_dont_care( i)  );   <== step into this line

and you fall into 'func_that_we_dont_care', you can 'step out' there, then 'step into' again, eventually you will be able to step into 'func_that_we_care'.

Related