使用 gdb/gdbserver 远程调试共享库 [英] Debugging shared libraries remotely with gdb/gdbserver
问题描述
我的问题是关于使用 gdb/gdbserver 在嵌入式 arm 处理器上远程调试应用程序.
My question is about remote debugging an application on an embedded arm processor using gdb/gdbserver.
我可以调试应用程序本身,但应用程序会动态链接到实现内部通信协议的共享库.我希望能够在共享库函数中设置断点,因此尝试找出一些设备发现问题.
I can debug the application itself, but the application dynamically links to a shared library which implements an in house communications protocol. I want to be able to set breakpoints within the shared library functions so try to figure out some device discovery problems.
我确保库是用调试符号编译的,并由主机端的 gdb 加载,我可以列出库中的函数,甚至设置断点,但是一旦我尝试运行应用程序,我就会得到一个错误消息的影响:
I have made sure that the library is compiled with debug symbols and is loaded by gdb on the host side, I can list functions within the library and even set the breakpoints but as soon as I try to run the application I get an error message to the effect of:
<代码>无法插入断点 X.
访问内存地址时出错:输入/输出错误.
其中 X 是 gdb 中的断点编号,并且是一个远小到有效的地址.
我在目标和主机上都使用了新库,但是通过 nfs 挂载在目标上的 mount -o bind newlib oldlib
.
有没有人知道可能出什么问题?提前致谢.
where X is the breakpoint number in gdb and is an address far to small to be valid.
I am using the new library on both the target and the host machine, but via mount -o bind newlib oldlib
on the target from an nfs mount.
Does anyone have an idea about what could be wrong?
Thanks in advance.
推荐答案
疯狂猜测:您将共享库加载到主机 GDB
的地址不正确.
Wild guess: you loaded the shared library into host GDB
at incorrect address.
不是显式加载到 GDB,而是使用 "set stop-on-solib-event on"
,等待库加载(info shared
会告诉您当前加载的库列表),然后然后设置断点.
Instead of explicitly loading it into GDB, use "set stop-on-solib-event on"
, wait for the library to get loaded (info shared
will tell you current list of loaded libraries), and then set the breakpoints.
这篇关于使用 gdb/gdbserver 远程调试共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!