【问题标题】:debugging postgres (and external .so libraries) with kdbg (KDE Debugger in Lilnux)使用 kdbg(Linux 中的 KDE 调试器)调试 postgres(和外部 .so 库)
【发布时间】:2013-07-24 11:15:56
【问题描述】:

我想调试一个用户定义的函数(称为prepareTheOutputRecord,用 C/C++ 实现,它是 postgres 中用户定义函数的一部分。以下是我使用 gdb 实现此目的的方法:

  1. 函数prepareTheOutputRecord驻留在postgresql服务器lib目录下的libMyExtenstion.so文件中
  2. 我启动 psql shell,检索进程的 pid

    postgres=# SELECT pg_backend_pid();
    pg_backend_pid
    - - - - - - - - - - - - - - 
        4120
    (1 row)
    
  3. 使用附加的 pid 运行 gdb:

    gdb -p 4120
    
  4. 现在搜索 .so 文件,函数的具体调用方式:

    nm -as libMyExtenstion.so | grep prepareTheOputRecord 
    00000000002633fe t _ZN6libafd6LIBAFD22prepareTheOutputRecordEP20FunctionCallInfoData
    
  5. 在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
    
  6. 在 psql 中执行 SQL。在某个时刻,gdb 中的断点被命中:

    Breakpoint 1, prepareTheOutputRecord (this=0x1116410, fcinfo=0x7fff3a41e150)
    at ../Dir/file.cpp:1736
    1736        funcctx = SRF_PERCALL_SETUP();
    (gdb) 
    
  7. 继续调试代码。

我想在 kdbg 中做同样的事情。为此,我加载了 postgres 可执行文件,附加到进程,加载了 cpp 文件,在函数处用鼠标设置断点,继续执行 postgres 进程,但从未命中断点:(我重复了相同的 . so 文件(而不是 postgres 可执行文件)没有任何成功。我什至尝试将断点设置为_ZN6libafd6LIBAFD22prepareTheOutputRecordEP20FunctionCallInfoData(无需单击鼠标)但程序不会在 kdbg 中停止:(

【问题讨论】:

    标签: debugging gdb breakpoints kde kdbg


    【解决方案1】:

    我认为问题在于kdb 没有作为根(或 postgres)运行。由于权限错误,没有加载符号,因此没有显示断点(也不允许放置在函数处)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-26
      • 1970-01-01
      • 2013-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多