Window 当 运行 LLDB 中的 Rust OpenGL 程序在 Windows 时无法打开
Window doesn't open when running a Rust OpenGL program inside of LLDB on Windows
我在 Windows 上有一个最小的 Rust/OpenGL 应用程序。我正在使用 Visual Studio 代码、LLDB 和 Glutin(类似于 GLFW 的库)。
通过 cargo run
启动会打开一个空的 window,但是当通过 LLDB 启动时,不会打开 window。我已经在 LLDB 和 println!
中确认正在调用上下文创建函数并且正在执行主循环。换句话说,我已经验证了所有代码行都已到达。无论 运行 来自 VSCode 与否,这同样适用。
我正在使用 32 位 Rust 工具链,stable-i686-pc-windows-gnu
,因为 LLDB 不完全支持 64 位 Windows。除了这个问题,LLDB 似乎按预期工作。
下面是main.rs
,改编自Glutin readme。 (Glutin 是一个类似于 GLFW 的 Rust 库。)除了打开 window.
所需的必需品外,我已经删除了所有内容。
期望的行为:当程序从 LLDB 启动时,window 打开,与程序从 LLDB 外部启动时一样。
实际行为:当程序从 LLDB 启动时,window 不会打开。
问题:什么可以解释这种行为差异? IE。为什么 window 无法从 LLDB 从终端打开?
extern crate gl;
extern crate glutin;
fn main() {
let events_loop = glutin::EventsLoop::new();
let window = glutin::WindowBuilder::new();
let context = glutin::ContextBuilder::new();
// When running outside LLDB, this line causes the window to appear.
// The let binding is necessary because without it, the value will be dropped
// and the window will close before the loop starts.
let gl_window = glutin::GlWindow::new(window, context, &events_loop).unwrap();
// Normally, we'd make the window current here. But it's not necessary
// to reproduce the problem.
loop {
// This is where we'd swap the buffers and clear. But it's not necessary
// to reproduce the problem.
}
}
部分答案:作为解决方法,您可以将 LLDB附加到运行进程而不是正在从 LLDB 启动 进程。在 VSCode 中,您可以使用:Add Configuration -> LLDB: Attach by Name
执行此操作。通过此工作流,OpenGL window 打开时就像不涉及 LLDB 时一样。不幸的是,连接明显不符合人体工程学。
更新:我更喜欢用调试器启动而不是附加。我发现 Rust 的 MSVC x64 工具链以及 Microsoft 的 C/C++ 调试器非常适合这个用例。对我有用的步骤是:
- 如有必要,安装 MSVC 工具链:
rustup install stable-x86_64-pc-windows-msvc
- 将 MSVC 工具链设为默认:
rustup default stable-x86_64-pc-windows-msvc
- 更新铁锈:
rustup update
- 为 Visual Studio 代码安装 Microsoft's C/C++ extension。该扩展包括一个与 Rust 编译的 MSVC 二进制文件兼容的调试器。
- 向 Visual Studio 代码添加调试配置。我从添加默认配置开始,但不得不修改它。最终,这就是我在
.vs-code/launch.json
中的内容——请注意,字符串 rust-test
对项目来说是唯一的:
-
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/target/debug/rust-test.exe",
"args": [],
"symbolSearchPath": "${workspaceFolder}/target/debug/rust-test.pdb",
"stopAtEntry": false,
"cwd": "${workspaceFolder}/target/debug",
"environment": [],
"externalConsole": true
}
如果有人对 LLDB 问题有任何想法,我将不胜感激。虽然 MSVC 工具链暂时解决了我的问题,但可能还有其他人真正想使用 LLDB 并遇到这个问题。
我在 Windows 上有一个最小的 Rust/OpenGL 应用程序。我正在使用 Visual Studio 代码、LLDB 和 Glutin(类似于 GLFW 的库)。
通过 cargo run
启动会打开一个空的 window,但是当通过 LLDB 启动时,不会打开 window。我已经在 LLDB 和 println!
中确认正在调用上下文创建函数并且正在执行主循环。换句话说,我已经验证了所有代码行都已到达。无论 运行 来自 VSCode 与否,这同样适用。
我正在使用 32 位 Rust 工具链,stable-i686-pc-windows-gnu
,因为 LLDB 不完全支持 64 位 Windows。除了这个问题,LLDB 似乎按预期工作。
下面是main.rs
,改编自Glutin readme。 (Glutin 是一个类似于 GLFW 的 Rust 库。)除了打开 window.
期望的行为:当程序从 LLDB 启动时,window 打开,与程序从 LLDB 外部启动时一样。
实际行为:当程序从 LLDB 启动时,window 不会打开。
问题:什么可以解释这种行为差异? IE。为什么 window 无法从 LLDB 从终端打开?
extern crate gl;
extern crate glutin;
fn main() {
let events_loop = glutin::EventsLoop::new();
let window = glutin::WindowBuilder::new();
let context = glutin::ContextBuilder::new();
// When running outside LLDB, this line causes the window to appear.
// The let binding is necessary because without it, the value will be dropped
// and the window will close before the loop starts.
let gl_window = glutin::GlWindow::new(window, context, &events_loop).unwrap();
// Normally, we'd make the window current here. But it's not necessary
// to reproduce the problem.
loop {
// This is where we'd swap the buffers and clear. But it's not necessary
// to reproduce the problem.
}
}
部分答案:作为解决方法,您可以将 LLDB附加到运行进程而不是正在从 LLDB 启动 进程。在 VSCode 中,您可以使用:Add Configuration -> LLDB: Attach by Name
执行此操作。通过此工作流,OpenGL window 打开时就像不涉及 LLDB 时一样。不幸的是,连接明显不符合人体工程学。
更新:我更喜欢用调试器启动而不是附加。我发现 Rust 的 MSVC x64 工具链以及 Microsoft 的 C/C++ 调试器非常适合这个用例。对我有用的步骤是:
- 如有必要,安装 MSVC 工具链:
rustup install stable-x86_64-pc-windows-msvc
- 将 MSVC 工具链设为默认:
rustup default stable-x86_64-pc-windows-msvc
- 更新铁锈:
rustup update
- 为 Visual Studio 代码安装 Microsoft's C/C++ extension。该扩展包括一个与 Rust 编译的 MSVC 二进制文件兼容的调试器。
- 向 Visual Studio 代码添加调试配置。我从添加默认配置开始,但不得不修改它。最终,这就是我在
.vs-code/launch.json
中的内容——请注意,字符串rust-test
对项目来说是唯一的:
-
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/target/debug/rust-test.exe",
"args": [],
"symbolSearchPath": "${workspaceFolder}/target/debug/rust-test.pdb",
"stopAtEntry": false,
"cwd": "${workspaceFolder}/target/debug",
"environment": [],
"externalConsole": true
}
如果有人对 LLDB 问题有任何想法,我将不胜感激。虽然 MSVC 工具链暂时解决了我的问题,但可能还有其他人真正想使用 LLDB 并遇到这个问题。