Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution that vscode can't hit the breakpoint

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report