报错提示:
(gdb) file test
Reading symbols from /root/worker/test...done.
(gdb) b memcpy
Breakpoint 1 at 0x4004a0
(gdb) r
Starting program: /root/worker/test
Breakpoint 1, 0x00007ffff7df5fa0 in memcpy () from /lib64/ld-linux-x86-64.so.2
Missing separate debuginfos, use: debuginfo-install glibc-2.17-157.el7_3.5.x86_64
(gdb)
test.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char str[10];
memcpy(str,"hello",5);
printf("str = %s\n",str);
return 0;
}
原因:没有安装 debuginfo 的调试安装包,正常GDB调试时,如果你没有要跳入系统函数中执行,是不会报这个错误的,
本例中使用了memcpy函数,所以需要安装
glibc-debuginfo-2.17-157.el7_3.5.x86_64.rpm
glibc-debuginfo-common-2.17-157.el7_3.5.x86_64.rpm
地址:http://debuginfo.centos.org/7/x86_64/ centos的一些rpm包
安装后即可正常运行