Post

Rust Debugging in VS Code

☞ Rust 설치는 여기 클릭

☞ Build

  • 프로젝트 생성 후, 별도 설정없이 ctrl+shift+b 를 누르면 아래와 같이 빌드를 선택해주면 빌드가 된다.

Desktop View

☞ Debugging

  • ctrl+shift+p 검색창에서 cargo를 치고 검색된 LLDB:… 를 선택하면 자동으로 debugging을 위한 json 형식의 텍스트가 생성된다.

Desktop View

  • 아래는 생성된 json 텍스트
  • .vscode/launch.json 파일에 내용 붙여넣기 (폴더/파일 없을 시 생성)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    
    {
     "version": "0.2.0",
     "configurations": [
         {
             "type": "lldb",
             "request": "launch",
             "name": "Debug executable 'test111'",
             "cargo": {
                 "args": [
                     "build",
                     "--bin=test111",
                     "--package=test111"
                 ],
                 "filter": {
                     "name": "test111",
                     "kind": "bin"
                 }
             },
             "args": [],
             "cwd": "${workspaceFolder}"
         },
         {
             "type": "lldb",
             "request": "launch",
             "name": "Debug unit tests in executable 'test111'",
             "cargo": {
                 "args": [
                     "test",
                     "--no-run",
                     "--bin=test111",
                     "--package=test111"
                 ],
                 "filter": {
                     "name": "test111",
                     "kind": "bin"
                 }
             },
             "args": [],
             "cwd": "${workspaceFolder}"
         }
     ]
    }
    
  • 작업 완료 후, F5 를 누르면 아래와 같이 사용 가능

Desktop View



기본적인 설치 및 개발환경 작업은 완료했으니…

This post is licensed under CC BY 4.0 by the author.