microsoft / vscode-cpptools

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

Can't pause after press run with no breakpoint when debug with cpptool(but can stop at the begining) #5294

Open wpz1988 opened 4 years ago

wpz1988 commented 4 years ago

Source Code (main.c):

include

int main(void) { int cnt_1st = 0; int cnt_2nd = 0; while (1) { // sched_run_idle(); if (cnt_1st > 40000000) { cnt_1st = 0; cnt_2nd++; if (cnt_2nd > 100) { cnt_2nd = 0; printf("heart beat\n"); } } cnt_1st++; } return 0; } Bug Description: step1: Before pressing F5 I create a breakpoint in the line of " if (cnt_1st > 40000000)", step2: then press F5 then we can hit the breakpoint normally, image

step3: we can do all debug operations such as watch the value of parameter,and changed them by hand. image image

step4: once I cancel all breakpoints and press "run" , the debug progress will can't stop anymore, step5: even I create breakpoint again in any where of the codes, result is the same. image

and I found there are 3 threads in the left side of the vscode windows, all states are RUNING, when click stop in any thread , the thread is still running.

in the console side the heartbeat is keep printing.

launch.json { "version": "0.2.0", "configurations": [ { "name": "c/c++", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/a.exe", "args": [], "stopAtEntry": true, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "C:/MinGW/bin/gdb.exe", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "build" } ] } task.json: { "version": "2.0.0", "command": "build", "tasks": [ { "label": "build", "type": "shell", "command": "gcc", "args": [ "main.c", "-g" ] } ] }

wpz1988 commented 4 years ago

and by the way when debug python it works ok. with codes below: image

wpz1988 commented 4 years ago

I also try eclipse and code block with the mingw I installed, and it's no problem in step1~5. so I think it's a problem of vscode cpptool side. maybe the launch.json or task.json is wrong, or this is bug for the new cpptool extension.

wpz1988 commented 4 years ago

and I found there is same issue still open->link and here is my gdb log log.txt

Sunggekun commented 4 years ago

I think this issue is duplicate of #2771

justanotheranonymoususer commented 3 years ago

Any news with this? Any workaround perhaps? I try to debug a GUI application, and it just doesn't work - I can step at the beginning, but if I run the program, I can no longer pause it, and placing breakpoints don't work. This makes the debugger non-functional. Please, any help is appreciated.

oold commented 1 year ago

@justanotheranonymoususer The solution is to send a Ctrl+C to the console of the debuggee. At least that's how we're doing it in our fork of the Debug Engine and it's also what I've seen a lot of people suggest when debugging with GDB on Windows.

sewbacca commented 1 year ago

@justanotheranonymoususer The solution is to send a Ctrl+C to the console of the debuggee.

When I send it in the integrated terminal, I get two ^C^C and then it terminates the application. When I use the external terminal, it breaks, but after continuing it won't allow me to use the terminal anymore. It won't receive any keystrokes.