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)