Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep watching variables and their values in VS Code Debugging Session?

So I've been writing a program in C and debugging to solve the problems I had. After I solved those problems, I could not watch the values of the variables since debugging session just quits because there are no errors or breakpoints after I solved the problems occurred previously.

My editor is Visual Studio Code, running it on macOS, GCC.

like image 590
sunset. Avatar asked Jun 27 '26 04:06

sunset.


1 Answers

You should basicely put breakpoints at the end of your code, for example on the return line.

If you just want to know which values your variables have at the end of the execution, you can put printf("%x", your_variable); //DEBUG for the variables you want to see, and remove these lines when you finished debugging.

Moreover, if you're familiar with prompt commands, I recommand you to install gdb, this debugger is very powerful and easy to use ! Here is a little tutorial if you're interested ;)

like image 152
Benoit Bouckaert Avatar answered Jun 30 '26 02:06

Benoit Bouckaert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!