【发布时间】:2013-07-24 11:15:56
【问题描述】:
我想调试一个用户定义的函数(称为prepareTheOutputRecord,用 C/C++ 实现,它是 postgres 中用户定义函数的一部分。以下是我使用 gdb 实现此目的的方法:
- 函数
prepareTheOutputRecord驻留在postgresql服务器lib目录下的libMyExtenstion.so文件中 -
我启动 psql shell,检索进程的 pid
postgres=# SELECT pg_backend_pid(); pg_backend_pid - - - - - - - - - - - - - - 4120 (1 row) -
使用附加的 pid 运行 gdb:
gdb -p 4120 -
现在搜索 .so 文件,函数的具体调用方式:
nm -as libMyExtenstion.so | grep prepareTheOputRecord 00000000002633fe t _ZN6libafd6LIBAFD22prepareTheOutputRecordEP20FunctionCallInfoData -
在gdb中设置断点并运行程序:
(gdb) b _ZN6libafd6LIBAFD22prepareTheOutputRecordEP20FunctionCallInfoData Function "_ZN6libafd6LIBAFD22prepareTheOutputRecordEP20FunctionCallInfoData" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (_ZN6libafd6LIBAFD22prepareTheOutputRecordEP20FunctionCallInfoData) pending. (gdb) c -
在 psql 中执行 SQL。在某个时刻,gdb 中的断点被命中:
Breakpoint 1, prepareTheOutputRecord (this=0x1116410, fcinfo=0x7fff3a41e150) at ../Dir/file.cpp:1736 1736 funcctx = SRF_PERCALL_SETUP(); (gdb) 继续调试代码。
我想在 kdbg 中做同样的事情。为此,我加载了 postgres 可执行文件,附加到进程,加载了 cpp 文件,在函数处用鼠标设置断点,继续执行 postgres 进程,但从未命中断点:(我重复了相同的 . so 文件(而不是 postgres 可执行文件)没有任何成功。我什至尝试将断点设置为_ZN6libafd6LIBAFD22prepareTheOutputRecordEP20FunctionCallInfoData(无需单击鼠标)但程序不会在 kdbg 中停止:(
【问题讨论】:
标签: debugging gdb breakpoints kde kdbg