GDB 调试跟踪系统函数报错解决方案

本文介绍在使用GDB调试包含memcpy函数的程序时遇到的报错问题及解决方法,详细解释了缺少debuginfo包导致的问题,并提供了具体安装方案。

报错提示:   

(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包

       安装后即可正常运行

      

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值