c - 为什么 gdb 不会在 strcpy 上中断?

标签 c gdb breakpoints

<分区>

请看下面的命令行。我设置了两个断点:一个在 strcpy 上,另一个在 printf 上。为什么它会跳过断点 1?

root@ninja:~/Desktop/Programs# gcc -g -o exp exp.c
root@ninja:~/Desktop/Programs# gdb -q exp
Reading symbols from /root/Desktop/Programs/exp...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 strcpy
Function "strcpy" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (strcpy) pending.
(gdb) break printf
Breakpoint 2 at 0x8048300
(gdb) run
Starting program: /root/Desktop/Programs/exp 

Breakpoint 2, 0xb7eabf54 in printf () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
(gdb) i r eip
eip            0xb7eabf54   0xb7eabf54 <printf+4>
(gdb) cont
Continuing.
Hello world!
[Inferior 1 (process 3726) exited with code 015]

最佳答案

第一个断点未决。

(gdb) break strcpy
Function "strcpy" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (strcpy) pending.                                                 <<here

尝试:(gdb) break 7

7 是行号。

关于c - 为什么 gdb 不会在 strcpy 上中断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37314566/

相关文章:

c++ - mysql_stmt_store_result() 上的 MySQL C API 崩溃

c - Eclipse + CDT : Possible to bind key with GDB user-defined command?

eclipse - 无法在 Eclipse 中进行调试

ios - 切换 View Controller 时我在 Xcode 中出错

C:从文件中获取以特定字符开头的随机字符串

mysql c api : inserting numbers without converting them to a string

x86 - 在实模式下通过 gdb 访问 $api 失败

css - 媒体查询样式不起作用

c++ - 为什么运行时库是编译器选项而不是链接器选项?

C:数组声明期间的内存状态