• VS Code + clang + lldb


    https://github.com/microsoft/vscode-cpptools/issues/5415

    1. Install the following packages via apt

    sudo apt install clang-10 llvm-10-dev liblldb-10-dev

    2. Create soft links for executable files so things can work as expected

    sudo ln -s /usr/bin/clang-10 /usr/bin/clang
    sudo ln -s /usr/bin/clang++-10 /usr/bin/clang++
    sudo ln -s /usr/bin/lldb-10 /usr/bin/lldb
    # This one is a bit strange but VSCode only looks for the name `lldb-server-10.0.0` but not `lldb-server-10`
    sudo ln -s /usr/bin/lldb-server-10 /usr/bin/lldb-server-10.0.0

    3. Build the lldb-mi executable from source

    git clone https://github.com/lldb-tools/lldb-mi.git
    cd lldb-mi
    cmake .
    cmake --build .
    sudo cp src/lldb-mi /usr/bin/

    These should be it. And here's my launch.json. Basically just the default one from clang++ preset and changed nothing if I remember it correctly.

    {
        // 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": "clang-10 - Build and debug active file",
                "type": "cppdbg",
                "request": "launch",
                "program": "${workspaceFolder}/build/hello-world",
                "args": [],
                "stopAtEntry": true,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": false,
                "MIMode": "lldb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ],
                "miDebuggerPath": "/usr/bin/lldb-mi"
            }
        ]
    }

    https://blog.csdn.net/tanmx219/article/details/86681167

    cmake_minimum_required( VERSION 2.6.3 )
    set(CMAKE_SYSTEM_NAME Linux )
    set(CMAKE_BUILD_TYPE DEBUG)
    
    SET (CMAKE_C_COMPILER             "/usr/bin/clang")
    SET (CMAKE_C_FLAGS                "-Wall -std=c99")
    SET (CMAKE_C_FLAGS_DEBUG          "-O0 -g")
    SET (CMAKE_C_FLAGS_MINSIZEREL     "-Os -DNDEBUG")
    SET (CMAKE_C_FLAGS_RELEASE        "-O3 -DNDEBUG")
    SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
     
    SET (CMAKE_CXX_COMPILER             "/usr/bin/clang++")
    SET (CMAKE_CXX_FLAGS                "-Wall")
    SET (CMAKE_CXX_FLAGS_DEBUG          "-O0 -g")
    SET (CMAKE_CXX_FLAGS_MINSIZEREL     "-Os -DNDEBUG")
    SET (CMAKE_CXX_FLAGS_RELEASE        "-O3 -DNDEBUG")
    SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
     
    SET (CMAKE_AR      "/usr/bin/llvm-ar-10")
    SET (CMAKE_LINKER  "/usr/bin/llvm-ld-10")
    SET (CMAKE_NM      "/usr/bin/llvm-nm-10")
    SET (CMAKE_OBJDUMP "/usr/bin/llvm-objdump-10")
    SET (CMAKE_RANLIB  "/usr/bin/llvm-ranlib-10")
    cmake_minimum_required(VERSION 3.7.1)
     
    project(hello-world)
     
    find_package(LLVM REQUIRED CONFIG)
     
    set(SOURCE_FILES main.c)
     
    message(STATUS "This is BINARY dir " ${PROJECT_BINARY_DIR})
    message(STATUS "This is SOURCE dir " ${PROJECT_SOURCE_DIR})
    message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
    message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
     
    # Set your project compile flags.
    # E.g. if using the C++ header files
    # you will need to enable C++11 support
    # for your compiler.
     
    include_directories(${LLVM_INCLUDE_DIRS})
    add_definitions(${LLVM_DEFINITIONS})
     
    # Now build our tools
    add_executable(hello-world ${SOURCE_FILES})
     
     
    # Find the libraries that correspond to the LLVM components
    # that we wish to use
    llvm_map_components_to_libnames(llvm_libs support core irreader)
     
    # Link against LLVM libraries
    target_link_libraries(hello-world ${llvm_libs})
    cmake  -DCMAKE_TOOLCHAIN_FILE=./linux.toolchain.cmake -Bbuild -GNinja
    ninja -Cbuild -v
  • 相关阅读:
    SpringCloudAlibaba
    wechat kill
    使用vscode调试 pomelo
    Terry的学习笔记ASP.NET MVC 4 HELLO WORLD 分析编辑页面添加搜索页面
    Terry的学习笔记ASP.NET MVC 4 HELLO WORLD添加视图(View)
    Terry的学习笔记ASP.NET MVC 4 简介
    正则表达式总结
    自己编写的 objectDataSource 配合 GridView 实现分页
    Terry的学习笔记ASP.NET MVC 4 HELLO WORLD 从控制器访问模型中的数据
    Terry的学习笔记ASP.NET MVC 4 HELLO WORLD添加控制器(Controller)
  • 原文地址:https://www.cnblogs.com/sinferwu/p/15353427.html
Copyright © 2020-2023  润新知