postgresql gdb调试入门

  1. 背景

    默认已经安装postgresql以及gdb等工具

    默认已经初始化数据库以及启动数据库服务

  2. 找出postgres进程号

    ps -ef|grep postgres

    231101_jJov_2604075.png

    找到postgres进程号  1385

  3. 进入GDB调试

    [minmin@localhost  ~]$ gdb attach 1385

  4. 设置一个断点

    (gdb) b ExecResult

    Breakpoint 1 at 0x5bbdd0: file nodeResult.c, line 68.

  5. 再开启一个命令行窗口,连接数据库

    [minmin@localhost  ~]$ psql postgres

  6. 执行一条sql语句

    postgres=# select 1;

  7. 返回GDB窗口,输入 c 命令

    231902_7Asw_2604075.png

    停留在断点上

  8. 查看堆栈,输入bt

    232028_uVxV_2604075.png


转载于:https://my.oschina.net/u/2604075/blog/597202