# QGIS PythonコードのVSCodeデバッグ確認
###### tags: `OSGeo` `QGIS`
## 環境
* macOS arm64
* Homebrew
* QGIS 3.34.1 (LTR, ダウンロード版)
* VSCode
## 参考リンク
* macOS:
* [QGIS+VSCodeでのデバック環境構築 #Python - Qiita](https://qiita.com/yito/items/ac5a4c985105deef95b2)
* [Debugging QGIS 3.x python plugins on OSX using VS Code](https://gist.github.com/AsgerPetersen/9ea79ae4139f4977c31dd6ede2297f90)
* Windows:
* [VSCodeによるQGISプラグイン開発環境の構築 - nujust's blog](https://nujust.hatenablog.com/entry/2023/06/11/003337)
* [Debugging QGIS 3.x python plugins on Windows using VS Code](https://gist.github.com/thbaumann/73c873d4c49d8c1add8dc97359cebabe)
## デバッグ設定試行
### デバッガーにアタッチする方法
* `ptvsd` の `4.1.4`、`4.3.2` の `ptvsd` フォルダを `/Applications/QGIS.app/Contents/Resources/python` にコピーしても、いずれも以下のエラーが表示される。
* 
* QGISのpip3は `/Applications/QGIS.app/Contents/MacOS/bin` 内にあるものの、ここから実行する形で良い?
* `qgis mac pip` でググると、MIERUNEさんの以下の記事が引っかかったのでこちらを参考に
* [QGIS 3.32新機能 | MIERUNE](https://www.mierune.co.jp/blog/posts/ol8moevzd3?lang=ja)
* > #### Pythonコンソールからシェルコマンドを実行可能
> Pythonコンソールで入力領域(>>>)のコマンドの前に ! を付与することでシェルコマンドが実行できるようになりました。これによりpipコマンドが使えるようになり、QGISプロジェクト内でPythonパッケージを追加、削除ができるようになります。
> :
> M1/M2 Macの場合はIntel版で動いているため 初期PATHが /usr/bin:/bin:/usr/sbin:/sbin なのでご注意ください。
* 末尾記載のとおり、初期パスが `/usr/bin` になるようだったため、
```sh
>>> ! which pip3
/usr/bin/pip3
```
OSのターミナルより、QGISのpip3から直接 `debugpy` をインストール
```sh
cd /Applications/QGIS.app/Contents/MacOS/bin
./pip3 install debugpy
```
QGISの `/Applications/QGIS.app/Contents/Resources/python/site-packages` 内に `debugpy` がインストールされていることを確認
* 起動を試みるも、冒頭の以下のサイトの末尾の方のエラーが発生し、パッチを当ててもエラー解消せず、Python3.9がクラッシュ
[Debugging QGIS 3.x python plugins on OSX using VS Code](https://gist.github.com/AsgerPetersen/9ea79ae4139f4977c31dd6ede2297f90)
```
2024-04-27T20:10:55 WARNING Traceback (most recent call last):
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/debugpy/server/api.py", line 237, in listen
sock, _ = endpoints_listener.accept()
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/socket.py", line 293, in accept
fd, addr = self._accept()
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/sanak/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/debug_vs/__init__.py", line 136, in enable
t_, self.port = self.debugpy.listen((self.host, self.port))
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/debugpy/public_api.py", line 31, in wrapper
return wrapped(*args, **kwargs)
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/debugpy/server/api.py", line 143, in debug
log.reraise_exception("{0}() failed:", func.__name__, level="info")
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/debugpy/server/api.py", line 141, in debug
return func(address, settrace_kwargs, **kwargs)
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/debugpy/server/api.py", line 251, in listen
raise RuntimeError("timed out waiting for adapter to connect")
RuntimeError: timed out waiting for adapter to connect
```

ハマりそうだったため、環境を一旦クリア
* debug_vsプラグインをアンインストール
* `./pip3 uninstall debugpy`
* pythonフォルダから `ptvsd` フォルダを削除
#### 追記:
改めて確認したところ、以下の通りでした。
1. 以下のプラグインリポジトリのREADME.mdより、 `ptvsd` は不要
* https://github.com/lmotta/debug_vs_plugin
* > #### Changelog
> * 2023-08-05 Update to use 'debugpy' instead of 'ptvsd' (which is now depreced)
2. Gistにあるパッチで、Python3のパスをフルパスで指定する必要があった
* 上のクラッシュメッセージ内のパスがシステムのPython3(`/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Resources/Python.app/Contents/Python`)となっていて、以下の @rhinejoel さんコメント記載のとおり、Python3のフルパスを指定する必要があった。
* https://gist.github.com/AsgerPetersen/9ea79ae4139f4977c31dd6ede2297f90?permalink_comment_id=4904566#gistcomment-4904566
* 後ほど、動作確認の上、PRを投げようかと思います。=> 4/28に投げておきました。
* [Configure debugpy python path for Windows/macOS environments by sanak · Pull Request #18 · lmotta/debug_vs_plugin](https://github.com/lmotta/debug_vs_plugin/pull/18)
上記を修正後、 `.vscode/launch.json` に以下を指定することで、VSCodeでのデバッグ動作まで確認できました。
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}"
}
]
}
]
}
```
### デバッグ時にQGISのプロセスを指定してアタッチする方法
以下のWindows向けの記事で紹介されていた2つ目の方法
* [VSCodeによるQGISプラグイン開発環境の構築 - nujust's blog](https://nujust.hatenablog.com/entry/2023/06/11/003337)
* [デバッグ時にQGISのプロセスを指定してアタッチする方法](https://nujust.hatenablog.com/entry/2023/06/11/003337#%E3%83%87%E3%83%90%E3%83%83%E3%82%B0%E6%99%82%E3%81%ABQGIS%E3%81%AE%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%97%E3%81%A6%E3%82%A2%E3%82%BF%E3%83%83%E3%83%81%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95)
プラグインは既存のpgRoutingLayerプラグインを利用
* https://github.com/pgRouting/pgRoutingLayer
作業フォルダはホーム配下で、 QGISのプラグインフォルダ内にシンボリックリンクを作成
```sh
cd /Users/sanak/Library/Application\ Support/QGIS/QGIS3/profiles/default/python/plugins
ln -s (ホーム配下の作業フォルダ/pgRoutingLayer) pgRoutingLayer
```
`.vscode/launch.json` で以下を設定後、
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach QGIS",
"type": "debugpy",
"request": "attach",
"processId": "${command:pickProcess}",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${env:APPDATA}/QGIS/QGIS3/profiles/default/python/plugins/pgRoutingLayer"
}
],
"justMyCode": false
}
]
}
```
Pythonインタープリタで以下を選択し、
`/Applications/QGIS.app/Contents/MacOS/bin/python3`
起動済みのプロセスIDを指定したものの、アタッチ後以下のエラーが発生し、アタッチできない模様。
<details>
```
--- Starting attach to pid: 51794 ---
(lldb) process attach --pid 51794
Process 51794 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x00007ff816fa03ce libsystem_kernel.dylib`mach_msg2_trap + 10
libsystem_kernel.dylib`mach_msg2_trap:
-> 0x7ff816fa03ce <+10>: retq
0x7ff816fa03cf <+11>: nop
libsystem_kernel.dylib`macx_swapon:
0x7ff816fa03d0 <+0>: movq %rcx, %r10
0x7ff816fa03d3 <+3>: movl $0x1000030, %eax ; imm = 0x1000030
Target 0: (QGIS) stopped.
Executable module set to "/Applications/QGIS.app/Contents/MacOS/QGIS".
Architecture set to: x86_64-apple-macosx-.
(lldb) command script import "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py"
(lldb) load_lib_and_attach "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_x86_64.dylib" 0 "import codecs;import json;import sys;decode = lambda s: codecs.utf_8_decode(bytearray(s))[0] if s is not None else None;script_dir = decode([47, 85, 115, 101, 114, 115, 47, 115, 97, 110, 97, 107, 47, 46, 118, 115, 99, 111, 100, 101, 47, 101, 120, 116, 101, 110, 115, 105, 111, 110, 115, 47, 109, 115, 45, 112, 121, 116, 104, 111, 110, 46, 100, 101, 98, 117, 103, 112, 121, 45, 50, 48, 50, 52, 46, 52, 46, 48, 45, 100, 97, 114, 119, 105, 110, 45, 97, 114, 109, 54, 52, 47, 98, 117, 110, 100, 108, 101, 100, 47, 108, 105, 98, 115, 47, 100, 101, 98, 117, 103, 112, 121, 47, 97, 100, 97, 112, 116, 101, 114, 47, 46, 46, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 115, 101, 114, 118, 101, 114]);setup = json.loads(decode([123, 34, 109, 111, 100, 101, 34, 58, 32, 34, 99, 111, 110, 110, 101, 99, 116, 34, 44, 32, 34, 97, 100, 100, 114, 101, 115, 115, 34, 58, 32, 91, 34, 49, 50, 55, 46, 48, 46, 48, 46, 49, 34, 44, 32, 53, 56, 55, 53, 50, 93, 44, 32, 34, 119, 97, 105, 116, 95, 102, 111, 114, 95, 99, 108, 105, 101, 110, 116, 34, 58, 32, 102, 97, 108, 115, 101, 44, 32, 34, 108, 111, 103, 95, 116, 111, 34, 58, 32, 110, 117, 108, 108, 44, 32, 34, 97, 100, 97, 112, 116, 101, 114, 95, 97, 99, 99, 101, 115, 115, 95, 116, 111, 107, 101, 110, 34, 58, 32, 34, 98, 98, 51, 97, 99, 54, 101, 53, 101, 49, 55, 54, 48, 50, 53, 98, 101, 52, 52, 97, 54, 53, 101, 102, 102, 52, 49, 98, 55, 54, 50, 53, 50, 53, 99, 56, 102, 53, 54, 97, 100, 57, 52, 52, 57, 48, 98, 49, 54, 50, 49, 52, 50, 55, 97, 100, 57, 100, 56, 97, 99, 98, 55, 50, 34, 125]));sys.path.insert(0, script_dir);import attach_pid_injected;del sys.path[0];attach_pid_injected.attach(setup);" 0
/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_x86_64.dylib
success
import codecs;import json;import sys;decode = lambda s: codecs.utf_8_decode(bytearray(s))[0] if s is not None else None;script_dir = decode([47, 85, 115, 101, 114, 115, 47, 115, 97, 110, 97, 107, 47, 46, 118, 115, 99, 111, 100, 101, 47, 101, 120, 116, 101, 110, 115, 105, 111, 110, 115, 47, 109, 115, 45, 112, 121, 116, 104, 111, 110, 46, 100, 101, 98, 117, 103, 112, 121, 45, 50, 48, 50, 52, 46, 52, 46, 48, 45, 100, 97, 114, 119, 105, 110, 45, 97, 114, 109, 54, 52, 47, 98, 117, 110, 100, 108, 101, 100, 47, 108, 105, 98, 115, 47, 100, 101, 98, 117, 103, 112, 121, 47, 97, 100, 97, 112, 116, 101, 114, 47, 46, 46, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 115, 101, 114, 118, 101, 114]);setup = json.loads(decode([123, 34, 109, 111, 100, 101, 34, 58, 32, 34, 99, 111, 110, 110, 101, 99, 116, 34, 44, 32, 34, 97, 100, 100, 114, 101, 115, 115, 34, 58, 32, 91, 34, 49, 50, 55, 46, 48, 46, 48, 46, 49, 34, 44, 32, 53, 56, 55, 53, 50, 93, 44, 32, 34, 119, 97, 105, 116, 95, 102, 111, 114, 95, 99, 108, 105, 101, 110, 116, 34, 58, 32, 102, 97, 108, 115, 101, 44, 32, 34, 108, 111, 103, 95, 116, 111, 34, 58, 32, 110, 117, 108, 108, 44, 32, 34, 97, 100, 97, 112, 116, 101, 114, 95, 97, 99, 99, 101, 115, 115, 95, 116, 111, 107, 101, 110, 34, 58, 32, 34, 98, 98, 51, 97, 99, 54, 101, 53, 101, 49, 55, 54, 48, 50, 53, 98, 101, 52, 52, 97, 54, 53, 101, 102, 102, 52, 49, 98, 55, 54, 50, 53, 50, 53, 99, 56, 102, 53, 54, 97, 100, 57, 52, 52, 57, 48, 98, 49, 54, 50, 49, 52, 50, 55, 97, 100, 57, 100, 56, 97, 99, 98, 55, 50, 34, 125]));sys.path.insert(0, script_dir);import attach_pid_injected;del sys.path[0];attach_pid_injected.attach(setup);
success
(lldb) process detach
Process 51794 detached
(lldb) script import os; os._exit(1)
E+00008.591: Code injection into PID=51794 failed:
Traceback (most recent call last):
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 391, in attach_to_pid
add_code_to_python_process.run_python_code(
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py", line 534, in run_python_code_mac
subprocess.check_call(' '.join(cmd), shell=True, env=env)
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'lldb --no-lldbinit --script-language Python -o 'process attach --pid 51794' -o 'command script import "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py"' -o 'load_lib_and_attach "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_x86_64.dylib" 0 "import codecs;import json;import sys;decode = lambda s: codecs.utf_8_decode(bytearray(s))[0] if s is not None else None;script_dir = decode([47, 85, 115, 101, 114, 115, 47, 115, 97, 110, 97, 107, 47, 46, 118, 115, 99, 111, 100, 101, 47, 101, 120, 116, 101, 110, 115, 105, 111, 110, 115, 47, 109, 115, 45, 112, 121, 116, 104, 111, 110, 46, 100, 101, 98, 117, 103, 112, 121, 45, 50, 48, 50, 52, 46, 52, 46, 48, 45, 100, 97, 114, 119, 105, 110, 45, 97, 114, 109, 54, 52, 47, 98, 117, 110, 100, 108, 101, 100, 47, 108, 105, 98, 115, 47, 100, 101, 98, 117, 103, 112, 121, 47, 97, 100, 97, 112, 116, 101, 114, 47, 46, 46, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 115, 101, 114, 118, 101, 114]);setup = json.loads(decode([123, 34, 109, 111, 100, 101, 34, 58, 32, 34, 99, 111, 110, 110, 101, 99, 116, 34, 44, 32, 34, 97, 100, 100, 114, 101, 115, 115, 34, 58, 32, 91, 34, 49, 50, 55, 46, 48, 46, 48, 46, 49, 34, 44, 32, 53, 56, 55, 53, 50, 93, 44, 32, 34, 119, 97, 105, 116, 95, 102, 111, 114, 95, 99, 108, 105, 101, 110, 116, 34, 58, 32, 102, 97, 108, 115, 101, 44, 32, 34, 108, 111, 103, 95, 116, 111, 34, 58, 32, 110, 117, 108, 108, 44, 32, 34, 97, 100, 97, 112, 116, 101, 114, 95, 97, 99, 99, 101, 115, 115, 95, 116, 111, 107, 101, 110, 34, 58, 32, 34, 98, 98, 51, 97, 99, 54, 101, 53, 101, 49, 55, 54, 48, 50, 53, 98, 101, 52, 52, 97, 54, 53, 101, 102, 102, 52, 49, 98, 55, 54, 50, 53, 50, 53, 99, 56, 102, 53, 54, 97, 100, 57, 52, 52, 57, 48, 98, 49, 54, 50, 49, 52, 50, 55, 97, 100, 57, 100, 56, 97, 99, 98, 55, 50, 34, 125]));sys.path.insert(0, script_dir);import attach_pid_injected;del sys.path[0];attach_pid_injected.attach(setup);" 0' -o 'process detach' -o 'script import os; os._exit(1)'' returned non-zero exit status 1.
Stack where logged:
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/__main__.py", line 39, in <module>
cli.main()
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 398, in attach_to_pid
log.reraise_exception("Code injection into PID={0} failed:", pid)
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/common/log.py", line 222, in reraise_exception
_exception(format_string, *args, **kwargs)
Traceback (most recent call last):
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/__main__.py", line 39, in <module>
cli.main()
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 398, in attach_to_pid
log.reraise_exception("Code injection into PID={0} failed:", pid)
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 391, in attach_to_pid
add_code_to_python_process.run_python_code(
File "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py", line 534, in run_python_code_mac
subprocess.check_call(' '.join(cmd), shell=True, env=env)
File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'lldb --no-lldbinit --script-language Python -o 'process attach --pid 51794' -o 'command script import "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py"' -o 'load_lib_and_attach "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_x86_64.dylib" 0 "import codecs;import json;import sys;decode = lambda s: codecs.utf_8_decode(bytearray(s))[0] if s is not None else None;script_dir = decode([47, 85, 115, 101, 114, 115, 47, 115, 97, 110, 97, 107, 47, 46, 118, 115, 99, 111, 100, 101, 47, 101, 120, 116, 101, 110, 115, 105, 111, 110, 115, 47, 109, 115, 45, 112, 121, 116, 104, 111, 110, 46, 100, 101, 98, 117, 103, 112, 121, 45, 50, 48, 50, 52, 46, 52, 46, 48, 45, 100, 97, 114, 119, 105, 110, 45, 97, 114, 109, 54, 52, 47, 98, 117, 110, 100, 108, 101, 100, 47, 108, 105, 98, 115, 47, 100, 101, 98, 117, 103, 112, 121, 47, 97, 100, 97, 112, 116, 101, 114, 47, 46, 46, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 115, 101, 114, 118, 101, 114]);setup = json.loads(decode([123, 34, 109, 111, 100, 101, 34, 58, 32, 34, 99, 111, 110, 110, 101, 99, 116, 34, 44, 32, 34, 97, 100, 100, 114, 101, 115, 115, 34, 58, 32, 91, 34, 49, 50, 55, 46, 48, 46, 48, 46, 49, 34, 44, 32, 53, 56, 55, 53, 50, 93, 44, 32, 34, 119, 97, 105, 116, 95, 102, 111, 114, 95, 99, 108, 105, 101, 110, 116, 34, 58, 32, 102, 97, 108, 115, 101, 44, 32, 34, 108, 111, 103, 95, 116, 111, 34, 58, 32, 110, 117, 108, 108, 44, 32, 34, 97, 100, 97, 112, 116, 101, 114, 95, 97, 99, 99, 101, 115, 115, 95, 116, 111, 107, 101, 110, 34, 58, 32, 34, 98, 98, 51, 97, 99, 54, 101, 53, 101, 49, 55, 54, 48, 50, 53, 98, 101, 52, 52, 97, 54, 53, 101, 102, 102, 52, 49, 98, 55, 54, 50, 53, 50, 53, 99, 56, 102, 53, 54, 97, 100, 57, 52, 52, 57, 48, 98, 49, 54, 50, 49, 52, 50, 55, 97, 100, 57, 100, 56, 97, 99, 98, 55, 50, 34, 125]));sys.path.insert(0, script_dir);import attach_pid_injected;del sys.path[0];attach_pid_injected.attach(setup);" 0' -o 'process detach' -o 'script import os; os._exit(1)'' returned non-zero exit status 1.
Running: lldb --no-lldbinit --script-language Python -o 'process attach --pid 51794' -o 'command script import "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py"' -o 'load_lib_and_attach "/Users/sanak/.vscode/extensions/ms-python.debugpy-2024.4.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_x86_64.dylib" 0 "import codecs;import json;import sys;decode = lambda s: codecs.utf_8_decode(bytearray(s))[0] if s is not None else None;script_dir = decode([47, 85, 115, 101, 114, 115, 47, 115, 97, 110, 97, 107, 47, 46, 118, 115, 99, 111, 100, 101, 47, 101, 120, 116, 101, 110, 115, 105, 111, 110, 115, 47, 109, 115, 45, 112, 121, 116, 104, 111, 110, 46, 100, 101, 98, 117, 103, 112, 121, 45, 50, 48, 50, 52, 46, 52, 46, 48, 45, 100, 97, 114, 119, 105, 110, 45, 97, 114, 109, 54, 52, 47, 98, 117, 110, 100, 108, 101, 100, 47, 108, 105, 98, 115, 47, 100, 101, 98, 117, 103, 112, 121, 47, 97, 100, 97, 112, 116, 101, 114, 47, 46, 46, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 115, 101, 114, 118, 101, 114]);setup = json.loads(decode([123, 34, 109, 111, 100, 101, 34, 58, 32, 34, 99, 111, 110, 110, 101, 99, 116, 34, 44, 32, 34, 97, 100, 100, 114, 101, 115, 115, 34, 58, 32, 91, 34, 49, 50, 55, 46, 48, 46, 48, 46, 49, 34, 44, 32, 53, 56, 55, 53, 50, 93, 44, 32, 34, 119, 97, 105, 116, 95, 102, 111, 114, 95, 99, 108, 105, 101, 110, 116, 34, 58, 32, 102, 97, 108, 115, 101, 44, 32, 34, 108, 111, 103, 95, 116, 111, 34, 58, 32, 110, 117, 108, 108, 44, 32, 34, 97, 100, 97, 112, 116, 101, 114, 95, 97, 99, 99, 101, 115, 115, 95, 116, 111, 107, 101, 110, 34, 58, 32, 34, 98, 98, 51, 97, 99, 54, 101, 53, 101, 49, 55, 54, 48, 50, 53, 98, 101, 52, 52, 97, 54, 53, 101, 102, 102, 52, 49, 98, 55, 54, 50, 53, 50, 53, 99, 56, 102, 53, 54, 97, 100, 57, 52, 52, 57, 48, 98, 49, 54, 50, 49, 52, 50, 55, 97, 100, 57, 100, 56, 97, 99, 98, 55, 50, 34, 125]));sys.path.insert(0, script_dir);import attach_pid_injected;del sys.path[0];attach_pid_injected.attach(setup);" 0' -o 'process detach' -o 'script import os; os._exit(1)'
```
</details>