Vscode A breakpoint is not hit when debugging after a C + + compilation Build

Source: Internet
Author: User

1 //Test.cpp2#include <stdio.h>3 intG_var =0;4 voidPrint_line (Char*str)5 {6     if(str! =NULL)7printf"%s\r\n", str);8     Else9printf"NULL string\r\n");Ten } One intMain (intargcChar**argv) A { -     intL_var =1; -Print_line ("Hello world!"); theprintf"G_var =%d, L_var =%d.\r\n", G_var, L_var); -     return 0; -}
View Code

Launch.json

1 {2         "version":"0.2.0",3         "configurations": [4             {5                 "name":"(GDB) Launch",6                 "type":"cppdbg",7                 "Request":"Launch",8                 " Program":"${workspaceroot}/test.exe",9                 "args": [],Ten                 "Stopatentry":false, One                 "CWD":"${workspaceroot}", A                 "Environment": [], -                 "Externalconsole":true, -                 "Mimode":"gdb", the                 "Midebuggerpath":"C:\\mingw\\bin\\gdb.exe", -                 "Setupcommands": [ -                     { -                         "Description":"Enable pretty-printing for GDB", +                         "text":"-enable-pretty-printing", -                         "Ignorefailures":true +                     } A                 ] at             } -         ] -}
View Code

Tasks.json

1 {2     // Seehttps://go.microsoft.com/fwlink/?LinkId=7335583     //For the documentation about the Tasks.json format4     "version":"2.0.0",5     "Tasks": [6         {7             "TaskName":"Test",8             "type":"Shell",9             "Command":"g++",Ten             "args": ["- G","${file}","- o","${workspaceroot}/test.exe"] One         } A     ] -}
View Code

After the compilation succeeds, the breakpoint is set in the source code, but it cannot be killed.

Later review the official C + + compiled debug documentation and try, in the Launch.json file

"Setupcommands": [
{
"description": "Enable pretty-printing for GdB",
"Text": "-enable-pretty-printing",
"Ignorefailures": True
}
]

After adding

"Prelaunchtask": "Test" configuration, debugging can be normal to stop the breakpoint. Note: Don't forget to add a comma after the "setupcommands" with the brackets '] '.

Vscode A breakpoint is not hit when debugging after a C + + compilation Build

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.