繁体   English   中英

从gdb调用dlopen

[英]call dlopen from gdb

我想从gdb加载共享库(.so),我发现了以下命令:

(gdb) call dlopen("path/to/lib.so",..)

但这不起作用,我将程序与-ldl链接。

我得到的错误是:

No symbol "dlopen" in current context

我错过了什么 ?

我找到了解决该主题一半的命令。 我将解释:首先,您应该将共享库加载到进程中:

(gdb) set environment LD_PRELOAD /usr/lib/libdl.so

之后,我们定义要调试的文件

(gdb) file pgm

为了进行测试,我们在main处设置了断点

(gdb) break main

现在,我们运行程序

(gdb) run

我们称之为dlopen

(gdb) call dlopen("/path/to/lib.so",2)

到现在为止都可以,但是当我输入最后一条命令时,我有:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7de7f09 in ?? () from /lib64/ld-linux-x86-64.so.2
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function 
(_gdb_expr) will be abandoned.
When the function is done executing, GDB will silently stop.

当我修改“ unwindonsignal to(on / off)”时,什么都没有改变

这次我忘记了什么?

有用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM