microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

[cppvsdbg] The condition for a breakpoint failed to execute if expression is a string #5676

Open carrigiljavia opened 4 years ago

carrigiljavia commented 4 years ago

Type: Debugger

Setup a valid conditional breakpoint and got an exception or debugger stops every time in the breakpoint set. The expected result is to stop just once. Condition is valid, evaluated in debug console.

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
    string text ;
    for (const string& word : msg)
    {
        cout << word << " ";
        text = word; //breakpoint here expression: text=="from"
        if (word=="from")
        {
            cout << " -> ";
        }
    }
    cout << endl;
}

Version: 1.46.1 (system setup) Electron: 7.3.1 Chrome: 78.0.3904.130 Node.js: 12.8.1 V8: 7.8.279.23-electron.0 OS: Windows_NT x64 10.0.18363

WardenGnaw commented 4 years ago

Duplicate of https://github.com/microsoft/vscode-cpptools/issues/2297

carrigiljavia commented 4 years ago

Retested with version https://github.com/microsoft/vscode-cpptools/releases/tag/0.29.0-insiders and this does not fix the error. Modifying conditional breakpoints while debugging does not work due to VSCode change #2297 2020-07-05_11-36-07

drtingli commented 3 years ago

Observed too in "Version: 1.54.3 Commit: 2b9aebd5354a3629c3aba0a5f5df49f43d6689f8 Date: 2021-03-15T10:55:45.459Z Electron: 11.3.0 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0 OS: Windows_NT x64 10.0.19041"

ToBoMi commented 1 year ago

Observed in

Version: 1.74.2 (user setup)
Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161
Date: 2022-12-20T10:29:14.590Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19044
Sandboxed: No

Conditional breakpoint using a comparison without a string, but with a number works. (Example variableInt > 15 works)

edit: Doesn't work means, the conditional breakpoint is hit every time. Even if the string in the condition is different from the string value of the variable.

LongyuanCode commented 1 year ago

Observed in August 2023 (version 1.82) Windows 10, WSL2 Ubuntu20.04

chanmaoganda commented 8 months ago

Obversed in February 2024 Windows 11, WSL2 Ubuntu 20.04

chanmaoganda commented 8 months ago

found a resolution that using cmake and codelldb helps cmake 3.16, gcc 9.4.0-x86-64 gnu using tasks.json and launch.json to debug in lldb