您好,我刚刚在声明一个简单的二维数组时发现了一个非常奇怪的调试器行为。看起来它无法在库中打开文件cygwin.S。
无法打开文件:../../../../../ src / gcc-4.8.1 / libgcc / config / i386 / cygwin.S
在../../../../../ src / gcc-4.8.1 / libgcc / config / i386 / cygwin.S:169
没有调试的执行工作正常。有一个代码示例:
#include <stdio.h>
#include <stdlib.h>
int main()
{
const int strNumTries = 15;
const int strLength = 98;
char strName[strLength][strNumTries];
printf("Hello world!\n");
return 0;
}
调试器使用'步骤'方法停止char数组声明。那可能是什么问题呢?
答案 0 :(得分:2)
我怀疑你看到的是这样的事情:
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 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 untitled...done.
(gdb) br main
Breakpoint 1 at 0x4005f1: file untitled.c, line 6.
(gdb) r
Starting program: /home/xxxx/untitled
.
.
.
Breakpoint 1, main () at untitled.c:6
6 const int strNumTries = 15;
(gdb) s
7 const int strLength = 98;
(gdb)
8 char strName[strLength][strNumTries];
(gdb)
10 printf("Hello world!\n");
(gdb)
_IO_puts (str=0x400794 "Hello world!") at ioputs.c:34
34 ioputs.c: No such file or directory.
(gdb)
36 in ioputs.c
(gdb)
strlen () at ../sysdeps/x86_64/strlen.S:66
66 ../sysdeps/x86_64/strlen.S: No such file or directory.
(gdb)
67 in ../sysdeps/x86_64/strlen.S
(gdb)
68 in ../sysdeps/x86_64/strlen.S
最后一行重复多次,然后再转到任何其他子功能。
这不是错误,而是对printf()
以下是唯一与数组声明有关的gdb输出:
8 char strName[strLength][strNumTries];
答案 1 :(得分:2)
当我尝试在vscode中使用gdb进行调试时,收到此错误。 Vscode不提供重定向输入,尤其是对于C。所以我在使用freopen()。一切正常,直到进入数组的声明部分。
int arr[n]
所以我用一个指针替换了它并动态分配了内存。
int *arr=(int *) malloc(sizeof(int)*n);
这可行。
我认为gdb无法处理那些arr [variable]声明。但是我可能完全错了。希望这会有所帮助。
答案 2 :(得分:0)
不确定这是否会对您的情况有所帮助,但是......
我从GDB得到了完全相同的错误,并且GDB承认它已经失败并且遇到了问题(请参阅下面的GDB列表)。我可以使用GCC / gFortran 6.4和7.1 100%(在Win下运行C :: B,使用MingW)重现这一点。
当然,我还没有安装过cygwin,我只使用了MingW64编译器的seh和sjlj变体。另外,我没有,也从来没有任何GDB抱怨的目录(例如“/../src/gcc-7.1.0/”)所以它没有任何意义......问题只出现了在我的数千s / r的lib上添加了一个表面上相似的s / r之后(没有人抱怨过这个)。
...长话短说,问题结果是“堆栈空间不足”,因为我已经声明了一些大尺寸的(自动)数组。更改数组大小(更小)或将自动数组更改为Allocatable数组(前者在堆栈上,后者在堆上)修复了问题。
...所以,GDB似乎有一个错误,它的抱怨与实际错误无关。
----为了完整性,这是我的GDB列表的相关部分:
[debug][New Thread 740.0x9fc]
[debug]172 ../../../../../src/gcc-7.1.0/libgcc/config/i386/cygwin.S: No such file or directory.
[debug]Thread 1 received signal SIGSEGV, Segmentation fault.
[debug]__chkstk_ms () at ../../../../../src/gcc-7.1.0/libgcc/config/i386/cygwin.S:172
[debug]>>>>>>cb_gdb:
[debug]> info frame
[debug]Stack level 0, frame at 0x136f00:
[debug] eip = 0x664974bb in __chkstk_ms (../../../../../src/gcc-7.1.0/libgcc/config/i386/cygwin.S:172); saved eip = 0x664958b3
[debug] called by frame at 0x136f14
[debug] source language asm.
[debug] Arglist at 0x136ef8, args:
[debug] Locals at 0x136ef8, Previous frame's sp is 0x136f00
[debug] Saved registers:
[debug] eax at 0x136ef4, ecx at 0x136ef8, eip at 0x136efc
[debug]>>>>>>cb_gdb:
Cannot open file: ../../../../../src/gcc-7.1.0/libgcc/config/i386/cygwin.S
At ../../../../../src/gcc-7.1.0/libgcc/config/i386/cygwin.S:172
[debug]> info locals
[debug]No locals.
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No symbol table info available.
[debug]>>>>>>cb_gdb:
[debug]> bt 30
[debug]../../../../src/gdb-7.11.1/gdb/dwarf2loc.c:364: internal-error: dwarf_expr_frame_base: Assertion `framefunc != NULL' failed.
[debug]A problem internal to GDB has been detected,
[debug]further debugging may prove unreliable.
[debug]This is a bug, please report it. For instructions, see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]This application has requested the Runtime to terminate it in an unusual way.
[debug]Please contact the application's support team for more information.
[debug]#0 __chkstk_ms () at ../../../../../src/gcc-7.1.0/libgcc/config/i386/cygwin.S:172
[debug]#1 0x664958b3 in fadcern_sixtrack_xl (
Debugger finished with status 1