Information*/알면도움됨

CMakeLists.txt 로 Visual Studio Code Debugging 하기

ch4rli3kop 2021. 8. 4. 18:59
반응형

CMakeLists.txt 로 Visual Studio Code Debugging 하기

Visual Studio Code Extension 중 다음 세 가지 설치하기

설치 후, ctrl+shift+p로 Command Palette 실행

CMake: Configure -> CMake: Build -> CMake: Debug로 진행하는데, build 과정에서 CMakeLists.txt 파일을 선택하는 과정이 있음.

루트 디렉토리에 해당 파일이 있으면 자동으로 넘어가지만, 종종 위치가 다른 경우도 있으므로 사용자가 직접 파일의 위치를 지정해주면 됨.

그거로도 지정이 안된다 싶으면, 직접 .vscode 디렉토리에 settings.json 파일을 생성하고 다음 내용을 집어넣으면 됨.

{
    "cmake.sourceDirectory": "${workspaceFolder}/src"
}

What The Fuzz 디버깅

위와 다르게 VSCode 디렉토리 경로를 src로 다시 열어서 CMake: Configure -> CMake: Build -> CMake: Debug를 진행함

다음과 같이 launch.json 파일을 생성하여 진행함


{
    // 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}/build/wtf",
            "args": ["master", "--max_len", "1028", "--runs", "100000", "--target", "${fileDirname}/../../targets/hevd" ,"--address", "tcp://localhost:31337"],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}
반응형