【问题标题】:GDB in Cygwin is missing sigfe.s?Cygwin 中的 GDB 缺少 sigfe.s?
【发布时间】:2017-06-26 23:31:47
【问题描述】:

在完成一些学校的编程作业后,我决定开始做一些我想到的副业。我决定在 Windows 上安装 vim 并使用 Cygwin 正确链接它。我一开始安装了 gcc 和 gdb,试图看看是否一切正常。我制作了一个包含一些 printf 的快速 C 文件,因此我可以使用 gdb 进入它们。

我可以在 main 中设置断点,运行程序,得到第一个 printf,但是当我尝试进入下一行时,出现错误。

(gdb) step
_sigfe_puts () at sigfe.s:7019
7019    sigfe.s: No such file or directory.

我以为我没有正确安装 gdb,所以我重新安装了。我尝试使用 UltraGDB 看看它是否有帮助,但同样的事情发生了,这一次给了我一个更清晰的错误。

Can't find a source file at "C:/cygwin64/cygwin/src/cygwin/cygwin-2.8.0/cygwin-2.8.0-1.x86_64/build/x86_64-pc-cygwin/winsup/cygwin/sigfe.s" 
Locate the file or edit the source lookup path to include its location.

我怀疑它与权限有关,所以我尝试查找该目录,结果发现它确实不存在。 C:/cygwin64/ 没有 cygwin 文件夹,更不用说名为 src 的子文件夹等等。我确实发现在 cygwin64/usr 中有一个名为 x86_64-pc-cygwin 的文件夹,但它根本没有 winup 文件夹。

我不知道现在可以做些什么来解决这个错误,过去几天我一直很烦,并且没有找到任何解决方法。我假设 GDB 正在错误的位置寻找这个文件,但是如果我使用 Cygwin 安装程序可执行文件安装了 gdb,那么这不应该正常工作吗?任何帮助将不胜感激,谢谢。

完成测试运行但出现错误:

$ gdb ./test
GNU gdb (GDB) (Cygwin 7.10.1-1) 7.10.1
Copyright (C) 2015 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-pc-cygwin".
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 ./test...done.
(gdb) break main
Breakpoint 1 at 0x1004010ed: file test.c, line 6.
(gdb) run
Starting program: /home/User/test
[New Thread 13236.0x4c0]
[New Thread 13236.0x824]
[New Thread 13236.0x3078]
[New Thread 13236.0x374]

Breakpoint 1, main () at test.c:6
6         printf("Hello\n");
(gdb) step
_sigfe_puts () at sigfe.s:7019
7019    sigfe.s: No such file or directory.
(gdb)
7020    in sigfe.s
(gdb)
7023    in sigfe.s
(gdb)
_sigfe () at sigfe.s:19
19      in sigfe.s
(gdb)
20      in sigfe.s
(gdb)
21      in sigfe.s
.
.
.
(stops responding after various steps)

【问题讨论】:

  • sigfe.s 是 Cygwin 的 C 运行时库源代码的一部分,因此它通常不会出现在您的计算机上。您应该使用next 命令来跳过对printf 的函数调用,因为逐行遍历库代码并不是很有用。如果你真的想单步执行库代码,那么你要么需要下载它的源代码,要么使用stepi,它将逐个汇编指令执行代码汇编指令。有关这些命令的更多详细信息,请参阅:sourceware.org/gdb/onlinedocs/gdb/Continuing-and-Stepping.html
  • 抱歉,如果我开始调用我编写的一些函数,next 就没有用了。例如,在第一个 printf 之后调用函数 foo(),如果使用 next,它不会提供我需要的信息,例如 foo() 方法中的各个行。我需要知道该函数内部发生了什么,所以我确实需要 step,而不是库代码步进,而是我自己的代码。
  • 所以使用step 进入您编写并拥有源代码的函数,并使用next 跨过您未编写且没有源代码的库函数代码。
  • 虽然现在我可以进入我想要的功能,但它并没有逐行进行。我有一个;诠释 b; printf("Foo");并且步入该函数只会给我 printf("Foo") 而不是 int a。如果我在 windows 中安装 gdb 源代码并尝试在我的 bashrc 中设置别名,它会起作用吗?
  • int a;int b; 实际上不会导致在可执行文件中生成任何代码,因此您无法单步执行它们。

标签: gdb cygwin


【解决方案1】:

sigfe.s 是在 cygwin 构建期间动态创建的源文件。

它存在于构建树中:

$ find . -iname "*sigfe*"
./x86_64-unknown-cygwin/winsup/cygwin/sigfe.o
./x86_64-unknown-cygwin/winsup/cygwin/sigfe.s

它似乎是唯一具有这种特征的文件

$ find . -iname "*.s"
./x86_64-unknown-cygwin/winsup/cygwin/sigfe.s

理论上它应该包含在cygwin-debuginfo包中

$ cygcheck -l cygwin-debuginfo | grep -i "s$"
/usr/src/debug/cygwin-2.8.1-0.1/newlib/libc/machine/x86_64/memcpy.S
/usr/src/debug/cygwin-2.8.1-0.1/newlib/libc/machine/x86_64/memset.S
/usr/src/debug/cygwin-2.8.1-0.1/newlib/libc/machine/x86_64/setjmp.S

您可以在 cygwin 邮件列表中突出显示该问题。 https://cygwin.com/cygwin/lists.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-25
    • 2015-03-01
    • 1970-01-01
    • 2020-06-03
    • 2016-09-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多