GitHub - microsoft/vscode-mock-debug: Starter sample for developing debug adapters for VSCode.
Starter sample for developing debug adapters for VSCode. - microsoft/vscode-mock-debug
https://github.com/microsoft/vscode-mock-debug
https://marketplace.visualstudio.com/items?itemName=tomblind.local-lua-debugger-vscode を使っていたのだが、
launch.json
の args
に \\
が入るとエラーで起動できない。
Windows で作業しているので、稀によくファイルパスの指定に \\
が入る。
DebugAdapter を作っていたら、直し方がわかった
escape_backslash · ousttrue/local-lua-debugger-vscode@0f3974b
Local Lua Debugger for VSCode. Contribute to ousttrue/local-lua-debugger-vscode development by creating an account on GitHub.
https://github.com/ousttrue/local-lua-debugger-vscode/commit/0f3974b73964b2e34f90a21de9757a57d6746eb4
PR
escape backslash in args by ousttrue · Pull Request #37 · tomblind/local-lua-debugger-vscode
Hello.
Backslash in args require escape.
// launch.json.
"args": [
"C:\\GLtfSampleModles\\2.0\\Cube\\glTF\\Cube.gltf",
],
This pull request escape backslash....
https://github.com/tomblind/local-lua-debugger-vscode/pull/37
Linux では動かんかったらしく、別の方法で修正してくれた。
👍 0.2.2
https://github.com/tomblind/local-lua-debugger-vscode/blob/master/CHANGELOG.md
自前で DebugAdapter
作ってみることにした。
GitHub - ousttrue/luada: Lua Debug Adapter
Lua Debug Adapter. Contribute to ousttrue/luada development by creating an account on GitHub.
https://github.com/ousttrue/luada
途中まで実装したのだが、
- luajit.exe + luada.lua
という構成よりは、
- luada.exe
の方が取り回しがよくて、それなら lua 成分をもっと減らして JSON-RPC 制御も c++
なり rust
なりにして
lua 埋め込み型の exe が作りやすそう。
元々、 スタンドアロンの lua インタプリタと組み合わせて使う lua スクリプトという方向性で実装していたのだが、
luajit-2.1.0-beta3
一辺倒になりつつあるので気分が変わってきたのであった。
これに関しては、今の構成でできるところまでやってみよう。
VSCode の Extension を作る
手順通りに初期化した。npm は最新版に更新したほうがよいぽい。
MockDebug
を読む。
というサンプルがある。
いくつかの機能をまとめて提供する必要がありそう。
- launch.json の設定
- DebugAdapter 本体
- DebugAdapter を起動する
実装してみる
Extension の activate
適当にイベントを登録して
activate
されることを確認
Launch
- activate で DebugAdapterDescriptorFactory を登録
- launch で createDebugAdapterDescriptor を実行する
src/extensions.ts
Debug Adapter の実装
Specification
Debug Adapter Protocol documentation and specification page.
https://microsoft.github.io/debug-adapter-protocol/specification
を見て粛々と実装する。
Output Event
vscode の DebugConsole に出力されるので早期に作ると print debug の助けになる。
Logger
- DebugAdapterProtocol のやりとりすべてを記録する機能をアダプター側で作るべし。無いとデバッグ困難に。
例
vscode-debugadapter-node/adapter/src/loggingDebugSession.ts at main · microsoft/vscode-debugadapter-node
Debug adapter protocol and implementation for VS Code. - microsoft/vscode-debugadapter-node
https://github.com/Microsoft/vscode-debugadapter-node/blob/main/adapter/src/loggingDebugSession.ts
VSIX に出力
Publishing Extensions
Learn how to publish Visual Studio Code extensions to the public Marketplace and share them with other developers.
https://code.visualstudio.com/api/working-with-extensions/publishing-extension
vsce を使う。
package.json に追加。
参考
https://github.com/actboy168/lua-debug
- vscode.DebugAdapterExecutable
https://github.com/tomblind/local-lua-debugger-vscode
- vscode.DebugAdapterServer
- TypeScript で vscode.DebugAdapterServer を new
- vscode と DebugAdapterServer が DAP で通信
- DebugAdapterServer が lua を spawn もしている