1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

VSCodeでYJITをデバッグする

Last updated at Posted at 2022-07-29

ビルドの設定

../configure --prefix="${HOME}/.rbenv/versions/yjit" --disable-install-doc --enable-yjit=dev

--enable-yjit=dev じゃないとデバッグできないのかは未検証。

Cの設定

Settings (Workspace) > Extensions > Makefile Tools > Makefile > Make Directory: out-of-place ビルドのディレクトリを指定する

Rustの設定

Cargo.tomlの場所を自動で見つけられている気がするので何もしなくても良さそうだが、.vscode/settings.json に以下を足すと明示的にCargo.tomlを指定できる。

{
    "rust-analyzer.linkedProjects": ["/path/to/Cargo.toml"],
}

LLDBの設定

CにClangを使っていない場合でもRust側でlldbが必須になるので、Cも含めてLLDBでデバッグする必要がある。

  • apt install lldb とかでLLDBをいれる。
  • VSCodeにCodeLLDBという拡張をいれる。

Workspaceの設定

tasks.json の設定

${defaultBuildTask} を設定しておく。

.vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "make -C .yjit-arm64 -j8",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

launch.json の設定

.vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "name": "Run ruby",
            "request": "launch",
            "program": "${workspaceFolder}/.yjit-arm64/ruby",
            "args": ["--disable-gems", "--yjit-call-threshold=3", "/Users/k0kubun/tmp/a.rb"],
            "preLaunchTask": "${defaultBuildTask}"
        }
    ]
}

後からわかったことだが、tasks.jsonとpreLaunchTaskは省略しても動くぽい。

Optional: rust-analyzerに渡るfeatureを変更

.vscode/settings.json
{
    "rust-analyzer.cargo.features": [
        "disasm",
    ],
}

デバッグ実行

適当にブレークポイントを足した後、Run and Debugのところで緑の三角形 (Start Debugging) を押す。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?