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

时间:2018-02-08 09:54:30

标签: 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;
}

我编译了它。

$ gcc -g -o a.exe a.c
$

效果很好。

$ ./a.exe 
Hello
$

并且,我试图在gdb中执行a.exe。但是,我得到了“启动程序正常退出。”

$ 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) 

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

1 个答案:

答案 0 :(得分:1)

看起来已经报告并修复了WSL bug

作为一种解决方法,您可以在调试之前set disable-randomization off,请参阅https://github.com/Microsoft/WSL/issues/2870#issuecomment-359664608。或者将WSL更新到最新版本。