Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The solution that vscode can't hit the breakpoint

Shulou Source: shulou.com Published: 2022-06-02 17:41:14 10月04日 Update

Editor to share with you vscode can not hit the breakpoint solution, I believe that most people do not understand, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

How to solve the problem that vscode cannot hit the breakpoint?

The solution that the breakpoint cannot be hit during debugging after vscode C++ is compiled and generated.

/ / test.cpp#include int g_var = 0 else printf print_line (char * str) {if (str! = NULL) printf ("% s\ r\ n", str); else printf ("null string\ r\ n");} int main (int argc, char * * void) {int l_var = 1; print_line ("hello world!") Printf ("g_var =% d, l_var =% d.\ r\ n", g_var, l_var); return 0;}

Launch.json

{"version": "0.2.0", "configurations": [{"name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceRoot} / test.exe", "args": [] "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "C:\ MinGW\ bin\\ gdb.exe" "setupCommands": [{"description": "Enable pretty-printing for gdb", "text": "- enable-pretty-printing", "ignoreFailures": true}]}]}

Tasks.json

{/ / See https://go.microsoft.com/fwlink/?LinkId=733558 / / for the documentation about the tasks.json format "version": "2.0.0", "tasks": [{"taskName": "test", "type": "shell", "command": "command +", "args": ["- g", "${file}" "- o", "${workspaceRoot} / test.exe"]}]}

After the compilation is successful, the breakpoint is set in the source code, but the breakpoint cannot be hit.

Later, check the official C++ compilation and debugging documentation and try, in the launch.json file

"setupCommands": [{"description": "Enable pretty-printing for gdb", "text": "- enable-pretty-printing", "ignoreFailures": true}]

Add after

"preLaunchTask": "test" configuration, you can break the point normally when debugging.

Note: don't forget to add a comma after the square bracket']'of "setupCommands".

The above is all the content of the article "vscode can't hit the breakpoint". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Breakpoints articles compilations methods content caches success not much methods most official documents documents more source code knowledge industry information information channels commas Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Tech Info MySQL OPPO Reno MariaDB