How to skip over unnecessary functions/files while debugging VSCode in Linux/g++/gdb

Viewed 309

I have the following code (Main.cpp) in VSCode on ubuntu and debugging using gdb:

#include <iostream>
#include <string>

std::string return_string(){//Line 4
        std::string abc = "abc";
        return(abc);
}
    
int main(){//Line 9
        std::string abc = return_string();//Line 10
        std::cout<<abc<<std::endl;//Line 11
        return 0;
}

With breakpoint hit on Line 10, hitting F10 in the hopes of getting to Line 11 instead takes me inside basic_string.h file that is a C++ file not part of my project. Is there a way to not enter into such native C/C++ files? I have looked at:

How to prevent GDB from stepping into every single function

but that seems to talk about working with gdb raw and suggests specifying the skip command (https://sourceware.org/gdb/onlinedocs/gdb/Skipping-Over-Functions-and-Files.html) inside gdb. I, however, run the debugger via VSCode interface that provides an encapsulation layer over gdb without having the user to use raw gdb commands -- F10 steps over, F11 steps into and so on.

Is there a way to prevent certain files from being entered into while debugging via stepping through the code while compiling and linking itself? Currently, my makefile issues the following commands for compiling and linking:

(compiling) g++ -fno-common -fPIC -fno-strict-aliasing -fexceptions -fopenmp -c -g -std=c++14 -MMD -MP -MF "build/Debug/GNU-Linux/_ext/1/Main.o.d" -o build/Debug/GNU-Linux/_ext/1/Main.o ../src/Main.cpp 
(linking) g++ -fno-common -fPIC -fno-strict-aliasing -fexceptions -fopenmp -o dist/Debug/GNU-Linux/linux build/Debug/GNU-Linux/_ext/1/Main.o -lm -lpthread -ldl
0 Answers
Related