Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to know which lines of the source code were executed?

I am debugging a C/C++ code with Visual Studio. There is a loop called 10000 times and in one of the interactions, at the end of the loop, there is an error, as the program tries to access the N+1 value of an array of length N. I want to go back and debug the origin of the error and I wonder if somehow Visual Studio, in debugging mode, can highlight visually or tell me which lines of the source code were executed. Then it would be easier to find the error. Does anybody know if this is possible?

If this is not possible with VS, what other approaches could do this?

Thanks

EDIT: I also wonder if this could be done with any other IDE (Eclipse, Xcode, command line, etc)

like image 442
Open the way Avatar asked Nov 30 '22 18:11

Open the way


1 Answers

put a conditional breakpoint where the array access is happening. That way your program will break on the N+1th access and you'll have the complete stack trace to work with.

like image 51
Sridhar Iyer Avatar answered May 13 '23 06:05

Sridhar Iyer