Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set data breakpoints (i.e. watchpoints) on VSCode

I am no expert in VSCode, but I saw that since version 1.38 there is the possibility to add watchpoints (a breakpoint which breaks when a given memory area is modified, a feature that is supported by many debuggers), at least for C/C++, see here https://jaxenter.com/vs-code-1-38-161797.html and here https://github.com/microsoft/vscode/issues/58304. Now my version of VSCode is 1.48.2, and I still can't figure out how to do it, and I couldn't find a proper explanation either. If anyone can give an explanation on how to do it (or whether it is possible), for sure it will very beneficial for me and for the VSCode community.

like image 220
Paolo Crosetto Avatar asked Sep 01 '20 15:09

Paolo Crosetto


People also ask

How do you set a breakpoint in VS code?

Breakpoints. Breakpoints can be toggled by clicking on the editor margin or using F9 on the current line. Finer breakpoint control (enable/disable/reapply) can be done in the Run and Debug view's BREAKPOINTS section. Breakpoints in the editor margin are normally shown as red filled circles.

How do I add a data breakpoint in Visual Studio?

To set a data breakpoint: In a C++ project, start debugging, and wait until a breakpoint is reached. On the Debug menu, choose New Breakpoint > Data Breakpoint.

Where are Visual Studio breakpoints?

Visual Studio saves breakpoints in a XML file. To save the breakpoints, you just need to click on the “Export” button in breakpoint window as shown in the following figure. You can use the saved XML file for the future and you can pass the same to other developers.


1 Answers

I personally use the CodeLLDB extension for C++ debugging as I use LLDB. The way I create a variable watchpoint:

  • Put a regular break-point at where the variable is defined
  • Upon hitting the break-point, find the variable in the Variables pane, right click, and choose Break When Value Changes
like image 177
pooya13 Avatar answered Oct 19 '22 03:10

pooya13