在Linux环境下使用vscode配置C++调试环境

在Linux环境下使用vscode配置C++调试环境

起因

在课程CMU15445 LAB0 的编写以及debug过程中充斥着assert以及printf这种不优雅的debug方式,因此决定直接进行工业革命!使用debug程序。本次选用的debug程序是lldb,使用vscode的图形化debug模式,体验非常好。

环境

  • vmware player 虚拟机
  • Ubuntu 20.04
  • vscode
  • lldb
  • vscode c++插件
  • 成品结果

搭建流程

  • 安装vscode, vmware player, ubuntu 20.04
  • 安装vscode C/C++ extension pack
  • 安装vscode插件 Codelldb
  • 配置debug文件,我的debug配置文件如下
    {
        // 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": [
            {
                "type": "lldb",
                "request": "launch",
                "name": "Debug",
                "program": "${workspaceFolder}/bustub-private/build/test/buffer_pool_manager_instance_test",
                "args": [],
                "cwd": "${workspaceFolder}"
            }
        ]
    }
    
  • 每次更改debug对象就只需要更改 program 中对应程序的路径即可。

总结

用好工具,用好工具也是一项非常重要的技能。

posted @ 2022-09-19 21:23  Alyjay  阅读(1749)  评论(6编辑  收藏  举报