I'm trying to debug a program written in c++ using gdb from vscode.
When the debugger calls the function ifstream()
from the header fstream
, it's unable to find the header file because gdb is looking for it on the directory /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/
, which doesn't exist and results in wrong code execution.
I've fixed this by using the command directory /usr/include/c++/10.2.0/
on gdb from the terminal, but this doesn't seem to fix the problem when I use gdb from vscode.
Thanks in advance.
Finally, I have solved this problem.
When gdb is executed, it looks for a configuration file called .gdbinit
on the user's home directory (Unix systems). To give gdb the right header's directory it's as easy as put the command source {your header's directory}
on the file previously mentioned.
If Visual Studio doesn't recognice c/c++ functions, just put the header's location on your settings.json file ("C_Cpp.default.includePath": ["your header's directory"]
.