仅在 tui 模式下出现 gdb 错误:“启动时程序退出”
只要我不进入 tui 模式,gdb 就可以正常工作。例如,我有以下 c 程序:
#include <stdio.h>
int mp(int x, int y) {
int res = 0;
for (x; x>0; --x) {
res += y;
}
return res;
}
int main() {
int result = mp(5, 3);
printf("%d\n", result);
return 0;
}
我使用 gcc -g main.c 构建程序,并使用 gdb .\a.exe 调用 gdb。在这种情况下,我可以使用 run
很好地调试程序。但是,一旦我使用 tui enable
进入 tui 模式并发出 run
命令,它就会抛出以下错误:
(gdb) run
Starting program: C:\Users\justus\Coding\programmieren-in-c\a.exe
During startup program exited with code 0xc0000142.
原因是什么以及如何修复它?
gdb --version
C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin\gdb.exe: warning: Couldn't determine a path for the index cache directory.
GNU gdb (GDB for MinGW-W64 x86_64, built by Brecht Sanders) 10.2
[...]
gdb works fine as long as I don't enter tui mode. For example I have the following c program:
#include <stdio.h>
int mp(int x, int y) {
int res = 0;
for (x; x>0; --x) {
res += y;
}
return res;
}
int main() {
int result = mp(5, 3);
printf("%d\n", result);
return 0;
}
I build the program with gcc -g main.c
and invoke gdb with gdb .\a.exe
. In this case I can debug the program fine using run
. But as soon as I enter tui mode with tui enable
and issuing the run
command, it throws the following error:
(gdb) run
Starting program: C:\Users\justus\Coding\programmieren-in-c\a.exe
During startup program exited with code 0xc0000142.
What is the cause and how do I fix it?
gdb --version
C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin\gdb.exe: warning: Couldn't determine a path for the index cache directory.
GNU gdb (GDB for MinGW-W64 x86_64, built by Brecht Sanders) 10.2
[...]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 GDB 上使用
set new-console on
命令将解决该问题。这将创建一个单独的控制台/终端窗口来显示程序输出。这将解决 GDB 的 TUI 模式下的问题。原因可能是 gdb 本身在 Windows 版本上的构建。(MinGW)
Using
set new-console on
command on GDB will fix the issue. This will create a separate console/terminal window to show the program output. This will fix the issue in the TUI mode of GDBThe cause is probably the build of gdb itself on the windows edition.(MinGW)