我试图调试一个带有gdb的程序,当我设置断点并继续执行strcpy()函数时。我得到以下回复:

frinto@kali:~/Documents/theclang/programs/helloworld$ gcc -fno-builtin -m32 -g -o char_array char_array.c
frinto@kali:~/Documents/theclang/programs/helloworld$ ls
a.out  char_array  char_array.c  firstprog.c  helloworld.c
frinto@kali:~/Documents/theclang/programs/helloworld$ ./char_array
Hello, world!
frinto@kali:~/Documents/theclang/programs/helloworld$ gdb -q char_array
Reading symbols from char_array...done.
(gdb) list
1   #include <stdio.h>
2   #include <string.h>
3
4       int main() {
5           char str_a[20];
6
7           strcpy(str_a, "Hello, world!\n");
8           printf(str_a);
9       }
(gdb) break 6
Breakpoint 1 at 0x11c6: file char_array.c, line 6.
(gdb) break strcpy
Breakpoint 2 at 0x1040
(gdb) break 8
Breakpoint 3 at 0x11dc: file char_array.c, line 8.
(gdb) run
Starting program: /home/frinto/Documents/theclang/programs/helloworld/char_array

Breakpoint 1, main () at char_array.c:7
7           strcpy(str_a, "Hello, world!\n");
(gdb) cont
Continuing.

Breakpoint 2, strcpy_ifunc () at ../sysdeps/i386/i686/multiarch/strcpy.c:29
29  ../sysdeps/i386/i686/multiarch/strcpy.c: No such file or directory.
(gdb)

我在Kali 2.0上安装了:
libc6-dbglibc6-dbg:i386
如果这还不明显,我想删除此错误消息:
../sysdeps/i386/i686/multiarch/strcpy.c: No such file or directory

提前感谢您的帮助!

最佳答案

我要清除此错误消息:
这不是个错误。GDB告诉您您已经在strcpy_ifunc函数中停止了(参见IFUNCs是什么的this description),它是在../sysdeps/i386/i686/multiarch/strcpy.c源文件中定义的,并且GDB不知道如何在文件系统上找到该文件(因此无法显示strcpy_ifunc的源)。
解决这个问题的最好方法是告诉GDB在哪里找到这个源代码。见(gdb) help directory
当然,要让这个工作,您实际上需要GLIBC源代码。我不知道Kali是否将源代码打包到libc6-dbg:i386中,您可能需要安装一个单独的glibc-source包。

关于c - ../sysdeps/i386/i686/multiarch/strcpy.c:无此类文件或目录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54282586/

10-15 04:43