Make breakpoint pending on future shared library load

在使用GDB设置断点的时候,有时候会 GDBh 会提示 "Make breakpoint pending on future shared library load".

一种情形是设置使用dlopen打开的动态库里的断点。

下面通过一个例子说明。

#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

int main() {

  void *handle = dlopen("/usr/lib/x86_64-linux-gnu/libm.so.7", RTLD_LAZY);
  if (!handle) {
    printf("dlopen error: %s\n", dlerror());
    return 1;
  }

  double (*sin)(double);
  sin = dlsym(handle, "sin");

  char *error = dlerror();
  if (error != NULL) {
    printf("dlsym error: %s\n", error);
    return 1;
  }

  printf("sin(0.5) = %f\n", sin(0.5));

  dlclose(handle);

  return 0;
}
~                   

编译出二进制文件。用GDB设置断点到sin:

(gdb) b sin
Function "sin" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (sin) pending.
(gdb) r
Starting program: ..
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, __sin_fma (x=0.5) at ../sysdeps/ieee754/dbl-64/s_sin.c:201
201	../sysdeps/ieee754/dbl-64/s_sin.c: No such file or directory.
(gdb) bt
#0  __sin_fma (x=0.5) at ../sysdeps/ieee754/dbl-64/s_sin.c:201
#1  0x0000555555555278 in main () at 2.c:22
(gdb) 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值