LoginSignup
0
1

More than 1 year has passed since last update.

Visual Studio Codeを使ったデバッガ導入とデバッグ実行

Last updated at Posted at 2022-04-02

Ubuntu編

  • Ubuntuでデバッガを導入する。

##環境

  • Ubuntu 20.04LTS

##Visual Studio Codeのインストール

##デバッグオプション

  • デバッグオプションをつけてもう一度cmake を実行。

  •          $ cd ~/Downloads
             $ chmod 755 install_dependencies.txt
             $ ./install_dependencies.txt --full
             $ mkdir ~/sushi && cd ~/sushi # クローン先のディレクトリへ移動
             $ git clone https://gitlab.com/inkscape/inkscape
             $ cd inkscape
             $ git submodule update --init --recursive
             $ mkdir build && cd build
             $ cmake -DCMAKE_INSTALL_PREFIX=(prefixを指定) -DCMAKE_BUILD_TYPE=Debug .. # デバッグオプションをつける
             $ make 
             $ make install
        ```
    
    

mac編

  • macでデバッガを導入する。

##環境

  • macOS Catalina 10.15.7

##Visual Studio Codeのインストール

  • Ubuntu編と同様Visual Studio Codeのインストール、拡張機能の導入を行う。
  • 追加で拡張機能CodeLLDBを入れる
  • 以下のコマンドを実行
mkdir .vscode
touch .vscode/launch.json
touch .vscode/tasks.json
  • jsonファイルを編集
tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "clang++ build active file",
      "type": "shell",
      "command": "clang++",
      "args": ["${fileBasename}", "-o", "${fileBasenameNoExtension}.out", "-g"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

##デバッグオプション

  • デバッグオプションをつけてもう一度cmake を実行。

  •          $ cd ~/Downloads
             $ chmod 755 install_dependencies.txt
             $ ./install_dependencies.txt --full
             $ mkdir ~/sushi && cd ~/sushi # クローン先のディレクトリへ移動
             $ git clone https://gitlab.com/inkscape/inkscape
             $ cd inkscape
             $ git submodule update --init --recursive
             $ mkdir build && cd build
             $ cmake -DCMAKE_INSTALL_PREFIX=(prefixを指定) -DCMAKE_BUILD_TYPE=Debug .. # デバッグオプションをつける
             $ make 
             $ make install
        ```
    
    

#デバッグ

##VSCode上でデバッグ実行

  • VSCodeの虫のボタンをクリックしてデバッグモードに

    • VSCodeではデバッグシンボルをつけずにデバッグするとそもそもRun出来ない。
  • デバッグの際生成されるlaunch.jsonは以下のように設定する。

  • Ubuntu

  • 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) 起動",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/install/bin/inkscape",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "gdb の再フォーマットを有効にする",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
```

  • mac

  • 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": "Launch",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/install/bin/inkscape",
"args": ["-arg1", "-arg2"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "gdb の再フォーマットを有効にする",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
```

  • ブレークポイントを設定し、Runボタンでデバッグを実行できる。
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1