简体   繁体   中英

How can I set a breakpoint at a `panic` when debugging a Rust program with VS Code and the MSVC toolchain?

I can set a breakpoint manualy, and run with debugger, but I can't set a breakpoint at a panic of a Rust program. How can I set a breakpoint at a panic like I would an exception in C++?

I'm using Rust 1.29.0-nightly, VS Code 1.25.1 and the MSVC 2017 toolchain.

With the MSVC toolchain, you could use the Visual Studio debugger. In VSCode, you could install the "C/C++" extension to access it. Despite the name, the debugger supports Rust just fine.

Panics uses the same strategy as C++ exceptions when set to unwinding, so you could catch panics using the same exception breakpoints for C++.

(screenshot provided by OP)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM