Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Condition breakpoint "strcmp(c-string, "char7")==0" is invalid in debug using VSCode C++ gdb debuger #8515

Closed
2994186010 opened this issue Dec 10, 2021 Discussed in #8509 · 4 comments
Labels
bug debugger fixed Check the Milestone for the release in which the fix is or will be available.
Milestone

Comments

@2994186010
Copy link

Discussed in #8509

Originally posted by 2994186010 December 9, 2021
My example code(testStr.cpp) is as following.

#include <iostream>
#include <string>
#include <cstring>
 
using namespace std;
 
int main() {
  char str1[15] = "char";
  string str2 = "string";
  char temp[5];
 
  for(int i=0; i<15; i++) {
    memset(temp, 0, sizeof(temp));
    sprintf(temp, "%d", i);
    strcat(str1, temp);
    cout << str1 << endl;
    str2 = str2 + temp;
    cout << str2 << endl;
  
    strcpy(str1, "char");
    str2 = "string";
  }
 
  return 0;
}

The executed commands is as following.

g++ /path/testStr.cpp -o /path/testStr
gdb /path/str
b 16 if strcmp(str1, "char4")==0
r

It is clear that the above gdb debug process is in the linux shell.
The running program suspend when str1 is char4. The detail is as the following picture.
gdbincmd

I set one same condition breakpoint "strcmp(str1, "char4")==0" in the 16th in testStr.cpp in VSCode IDE. The execution result of the program in VSCode is different from the above gdb debug result. The same breakpoint in VSCode seems to be invalid. The program doesn't suspend when str1 is char4 and finishes all the code lines. The detail is as following.
debuginVSCode

@WardenGnaw
Copy link
Member

Issue seems to be that the debug adapter is not escaping the double quotes when sending the condition to the debugger.

1: (676) <-1014-break-insert -f -c "strcmp(str1, "char4")==0" main.cpp:20
1: (685) ->1014^error,msg="Problem parsing arguments: break-insert -f -c \"strcmp(str1, \"char4\")==0\" main.cpp:20"

@WardenGnaw WardenGnaw added the fixed Check the Milestone for the release in which the fix is or will be available. label Jan 18, 2022
@WardenGnaw
Copy link
Member

Fixed in microsoft/MIEngine#1249

@sean-mcmanus
Copy link
Collaborator

@WardenGnaw
Copy link
Member

Yes

@sean-mcmanus sean-mcmanus added this to the 1.8.2 milestone Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug debugger fixed Check the Milestone for the release in which the fix is or will be available.
Projects
None yet
Development

No branches or pull requests

3 participants