Single stepping until exit from function gdb Single stepping until exit from function gdb multithreading multithreading

Single stepping until exit from function gdb


I don not see anywhere the -g flag. It informs compiler to emit debugging info, so you need to add it to compilation line, if you wish gdb to show you line numbers.


Try to update your gdb. It might be that your gcc version was too new. I got the same problem and fixed it after updated my gdb.


Well its 2021 so things are a bit different now. Typicly I find the -ggdb flag more useful. It isn't only more verbose, it also seems to be less error prone (but thats my opinion). You also need to make sure that you add the -ggdb flag to all the object files as well. To give some sort of reference, and a more solid way to get your project going if its not debugging as expected. Here is a snippet from a project I just built and debugged sucessfully in VSCode v1.62.1. It was compiled w/ GNU C++ Compiler g++ 10.3, debugged with GNU Debugger gdb v9.2, and built using the make command via GNU Make 4.2.1

# Here is an example from my current project that I debug on vscodeTARGET = A10ALL = fraction.o main.oGCC = g++FLAGS = -Wall -c${TARGET}: fraction.o main.o    ${GCC} -Wall -ggdb ${ALL} -o ${TARGET}main.o: main.cpp fraction.h    ${GCC} -Wall -ggdb -c main.cppfraction.o: fraction.cpp fraction.h    ${GCC} -Wall -ggdb -c fraction.cpp fraction.h