Created
November 19, 2022 01:29
-
-
Save Mart-Bogdan/7d19218837b419d53cc0c415879ea847 to your computer and use it in GitHub Desktop.
Rust snippet to attach VS Code debugger to current running process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// can be used to attach to existing running app. | |
// If you need to run app from shell, for example, passing in stdin or command line args, or whatever else. | |
#[allow(unused)] | |
fn attch_vs_code() { | |
use std::time::Duration; | |
let url = format!( | |
"vscode://vadimcn.vscode-lldb/launch/config?{{'request':'attach','pid':{}}}", | |
std::process::id() | |
); | |
_ = std::process::Command::new("code.cmd") | |
.arg("--open-url") | |
.arg(url) | |
.output() | |
.unwrap(); | |
std::thread::sleep(Duration::from_millis(1000)); // Wait for debugger to attach | |
} | |
//attch_vs_code(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment