Is it possible to watch variables at runtime?

前端 未结 2 1617
刺人心
刺人心 2021-02-05 12:54

I know the basics of debugging, and I know I can add watches to a variable that stop the program\'s execution on a given condition. But I didn\'t want to stop the program every

2条回答
  •  一整个雨季
    2021-02-05 13:50

    When your program has stopped on a breakpoint click the icon at the far right of the debugger menu (see image below). You can type in methods or variable names into this window and see what they would be.

    You can type any expression you like (as long as it is within the scope of where you broke your code) and input any hard-coded values or objects all without re-running your project.

    To add a variable to your watch list

    Start by putting a break point in the class where you'd want to watch a specific variable. Run the code and once it hits your breakpoint from the Variables window frame you should see all of the variables that are accessible. Simply choose the one you'd want to watch and then right click and choose "Add to watches" from the drop-down.

    Keep debugging and you should see the variable from the Watches window frame update when appropriate based on your code.

提交回复
热议问题