Ubuntu16.04 Vscode How to debug a C language program in a breakpoint

Source: Internet
Author: User

Personal blog Link: Ubuntu16.04 in vscode How to debug C language program breakpoints

Problem: Environment is Ubuntu16.04, how to use Vscode breakpoint to debug C language program.

Write code without debugging environment is unbearable, so toss a bit, finally succeeded. The process of tossing is this:

1, first install C + + extension, direct search the first is, or click this link to view its Help document for installation.

2, then open the current project directory, the left point debugging options, click Add Configuration, generated a Launch.json file, the contents are as follows:

{    // Use IntelliSense to learn about possible attributes.    // Hover to view descriptions of existing attributes.    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387    "version": "0.2.0",    "configurations": [    {        "name": "(gdb) Launch",        "type": "cppdbg",        "request": "launch",        "program": "${workspaceFolder}/LearnC/bin/a.out",        "args": [],        "stopAtEntry": false,        "cwd": "${workspaceFolder}",        "environment": [],        "externalConsole": true,        "MIMode": "gdb",        "setupCommands": [            {                "description": "Enable pretty-printing for gdb",                "text": "-enable-pretty-printing",                "ignoreFailures": true            }        ]    }]}

All content is the default generated configuration, I just modified the "program" line, specified as the compiled executable file. This will debug this file by default when debugging.

Related actions:

Select Add Configuration

Select C + + (GDB/LLDB)

3, edit the code, after completion, the first to compile, the command is as follows:

$ gcc -g -o /path/LearnC/bin/a.out [[SOURCE_FILE]]

The first path specifies the generated file, and Source_file indicates the path of the C language file if the file path specified by the program parameter is the previous one.

4, then open debugging, my shortcut is F5, opened, you can directly run to the breakpoint, the effect is as follows:

Ubuntu16.04 Vscode How to debug a C language program in a breakpoint

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.