gdb在启动期间显示程序正常退出。在WSL中(Windows上的Bash,Linux的Windows子系统)

gdb在启动期间显示程序正常退出。在WSL中(Windows上的Bash,Linux的Windows子系统),gdb,windows-subsystem-for-linux,Gdb,Windows Subsystem For Linux,我正在使用WSL(Windows上的Bash=Linux的Windows子系统)。 我写了一个简单的代码,a.c #include <stdio.h> int main(int argc, char *argv[]) { printf("Hello\n"); return 0; } 它工作得很好 $ ./a.exe Hello $ 并且,我尝试在gdb中执行a.exe。然而,我得到了“启动期间程序正常退出” $gdb./a.exe GNU gdb(Ubuntu

我正在使用WSL(Windows上的Bash=Linux的Windows子系统)。 我写了一个简单的代码,a.c

#include <stdio.h>

int main(int argc, char *argv[]) {
    printf("Hello\n");
    return 0;
}
它工作得很好

$ ./a.exe 
Hello
$
并且,我尝试在gdb中执行a.exe。然而,我得到了“启动期间程序正常退出”

$gdb./a.exe
GNU gdb(Ubuntu 7.11.1-0ubuntu1~16.5)7.11.1
版权所有(C)2016免费软件基金会。
许可证GPLv3+:GNU GPL版本3或更高版本
这是自由软件:您可以自由更改和重新发布它。
在法律允许的范围内,不存在任何担保。键入“显示复制”
和“显示保修”了解详细信息。
此GDB配置为“x86_64-linux-gnu”。
键入“显示配置”以获取配置详细信息。
有关错误报告说明,请参阅:
.
在线查找GDB手册和其他文档资源,网址为:
.
要获得帮助,请键入“帮助”。
键入“apropos word”以搜索与“word”相关的命令。。。
从./a.exe读取符号…完成。
(gdb)r
启动程序:/home/softgear/a.exe
启动期间,程序正常退出。
(gdb)

如何在WSL中使用gdb?请帮帮我。

看起来这已经报告并修复了

作为一种解决方法,您可以在调试之前
关闭禁用随机化
,请参阅。或者将WSL更新为最新版本。

解决方法有效。(我在/etc/gdb/gdbinit文件中添加了
set disable randomization off
)。
$ ./a.exe 
Hello
$
$ gdb ./a.exe
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.exe...done.
(gdb) r
Starting program: /home/softgear/a.exe 
During startup program exited normally.
(gdb)