../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/crt1.c:没有这样的文件或目录

时间:2014-03-15 08:28:59

标签: gdb

我是程序世界的新手。我正在使用Dev-cpp 5.6.1学习C. 我的调试器有问题(GNU gdb(GDB)7.6.1)。当我调试任何程序时,调试器警告我

  

单步执行直到退出功能主,   没有行号信息。

  

__ mingw_CRTStartup()      at ../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/crt1.c:260   260 ../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/crt1.c:没有这样的文件或目录。

之前发生的问题。我通过重新安装Dev-Cpp(也重置旧配置)解决了这个问题。但过了一会儿,问题再次出现了。

示例代码:

#include <stdio.h>

int main(void)
{
    int a, b;
    printf("Please give me number 1: ");
    scanf("%d", &a);
    printf("Please give me number 2: ");
    scanf("%d", &b);
    printf("Sum = %d", a + b);
}

调试器警告我:

C:\Users\Nam\Dropbox\code>gdb sum.exe
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 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 "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from C:\Users\Nam\Dropbox\code\sum.exe...done.
(gdb) b main
Breakpoint 1 at 0x4016b3
(gdb) n
The program is not being run.
(gdb) r
Starting program: C:\Users\Nam\Dropbox\code/sum.exe
[New Thread 7148.0x1b6c]

Breakpoint 1, 0x004016b3 in main ()
(gdb) n
Single stepping until exit from function main,
which has no line number information.
Please give me number 1: 3
Please give me number 2: 4
Sum = 7__mingw_CRTStartup ()
    at ../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/crt1.c:260
260     ../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/crt1.c: No such file or di
rectory.
(gdb)

我不知道如何修复它。

任何人都可以帮助我:(。提前致谢

1 个答案:

答案 0 :(得分:0)

  

我无法知道如何修复它。

我认为没有必要修复它。您已收到此消息,因为您已从main()返回,现在您不在代码中,这是调用您的main()的mingw代码。我做了与你相同的测试,这是完成主要后的回溯:

10          printf("Sum = %d", a + b);
(gdb)
Sum = 311       }
(gdb) bt
#0  main () at t.c:11
(gdb) n
__mingw_CRTStartup () at ../mingw/crt1.c:250
250     ../mingw/crt1.c: No such file or directory.
(gdb) bt
#0  __mingw_CRTStartup () at ../mingw/crt1.c:250
#1  0x00401284 in mainCRTStartup () at ../mingw/crt1.c:264
(gdb) n
252     in ../mingw/crt1.c
(gdb) n
[Inferior 1 (process 1448) exited normally]
(gdb)

再次 - 您不必调试mingw启动代码。只需给出gdb命令&#34;继续&#34;这样它就可以完成你的过程。

我在这里找到了__mingw_CRTStartup的来源http://gitorious.org/mingw/mingw-runtime/source/be97f73714b4e267e5903fc9bdeb0f23fcc3ac8f:crt1.c#L200。您可以看一下mingw库从main返回后执行的步骤:

static void __attribute__((noreturn))
__mingw_CRTStartup (void)
{
int nRet;

 /* skipped some lines ... */

 nRet = main (_argc, _argv, environ);
/*
* Perform exit processing for the C library. This means
* flushing output and calling 'atexit' registered functions.
*/
_cexit ();
ExitProcess (nRet);
}

一些有用的链接:

1)https://stackoverflow.com/a/4988376/184968