diff options
| author | zy <[email protected]> | 2023-09-15 01:47:25 +0000 |
|---|---|---|
| committer | zy <[email protected]> | 2023-09-15 01:47:25 +0000 |
| commit | 586d03d6a04fc269d3ddf5058a163bd3562d148c (patch) | |
| tree | e400fd05e5805db728225711236c730fa3420c95 | |
| parent | 5ee551eb5b8daef6504d0ec03b2b55655374a8f6 (diff) | |
rust-analyzer 使用 rust-gdb 调试, 这样可以跳转到 C 的断点调试了.
- 一个缺点: c 代码中变量有时会识别成 rust 的可空类型, 个别时候得手动加个打印
| -rw-r--r-- | .vscode/launch.json | 22 | ||||
| -rw-r--r-- | .vscode/settings.json | 20 |
2 files changed, 41 insertions, 1 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json index a40ce61..aea19ca 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,7 +4,27 @@ // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ - + { + "name": "Debug Rust with C", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/target/debug/my_rust_program", + "args": [], + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "build", + "postDebugTask": "clean" + }, { "name": "(gdb) 启动", "type": "cppdbg", diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0ddc0fc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,20 @@ +{ + "rust-analyzer.debug.engine": "ms-vscode.cpptools", + "rust-analyzer.debug.engineSettings": { + "cppdbg": { + "miDebuggerPath": "/usr/local/cargo/bin/rust-gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb | 整齐打印", + "text": "-enable-pretty-printing", + "ignoreFailures": false + }, + { + "description": "将反汇编风格设置为 Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ], + } + } +}
\ No newline at end of file |
