In Ubuntu 16.04, how does one debug the C language program with a breakpoint?

Source: Internet
Author: User

In Ubuntu 16.04, how does one debug the C language program with a breakpoint?

Problem: The environment is Ubuntu16.04. How to Use Vscode breakpoint to debug C language programs.

Writing code without a debugging environment is intolerable, so I finally succeeded. The tossing process is as follows:

1. First install the C/C ++ extension. Search for the first extension directly. Or click this link to view its help documentation for installation.

2. Open the current project directory, click debug options on the left, and click Add configuration to generate a launch. json file with the following content:

{
// Use intelliisense 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 ",
"Deployments ":[
{
"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 generated by default. I only modified the "program" line and specified it as an executable file after compilation. In this way, this file is debugged by default during debugging.

Related Operations:

Select add configuration

Select C ++ (GDB/LLDB)

3. Edit the code. Compile the code first. The command is as follows:

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

The first path specifies the generated file. It must be the file path specified by the previous program parameter. SOURCE_FILE indicates the C language file path.

4. Enable debugging. My shortcut key is F5. After opening it, You can directly run it at the breakpoint. The effect is as follows:

Ubuntu 14.04 install Visual Studio Code https://www.bkjia.com/Linux/2016-03/129052.htm
Developing TypeScript https://www.bkjia.com/Linux/2015-07/119456.htm with Visual Studio Code
Visual Studio Code simple trial experience https://www.bkjia.com/Linux/2015-05/116887.htm
Visual Studio Code trial experience https://www.bkjia.com/Linux/2015-07/120378.htm
Visual Studio debugging tips share https://www.bkjia.com/Linux/2017-11/148700.htm
Configure the VTK Development Environment on Ubuntu-Based on Visual Studio Code and GCC https://www.bkjia.com/Linux/2017-09/147169.htm
Compile and debug C \ C ++ https://www.bkjia.com/Linux/2017-09/147171.htm with Visual Studio Code in Ubuntu
Ubuntu 14.04 how to install Visual studio Code https://www.bkjia.com/Linux/2016-07/132886.htm
Visual Studio Code 1.18 release (how to install Ubuntu) https://www.bkjia.com/Linux/2017-11/148946.htm

Visual Studio details: click here
Visual Studio: click here

This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151602.htm

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.