Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seeing only local variables debugging C++ in VSCode

I am using Visual Studio Code and when I debug (I am debugging C++ code compiled with Clang) I see only local variables. I do not see any global variables list.

How can I see all variables?

enter image description here

In this case I am inside a loop and I see only all the variables defined inside the loop, not the one defined outside.

like image 857
Nisba Avatar asked Apr 21 '18 13:04

Nisba


2 Answers

You will need to manually add global variables to a watch window.

  1. Set a breakpoint
  2. Start debugging (Debug -> Start Debugging or F5)
  3. Open a Watch window (Debug -> Windows -> Watch -> Watch 1)
  4. Type in the name of the variable manually
like image 80
Andrew L Avatar answered Sep 18 '22 14:09

Andrew L


In Visual Studio Code you can just go to the Watch pannel int the debug menu and click on + , then type the name of the variable you want to watch. Hope it helps !

like image 42
Baptiste Florentin Avatar answered Sep 19 '22 14:09

Baptiste Florentin