当前位置: 首页 > article >正文

CLION+gdbserver远程调试postgresql源码

CLION+gdbserver远程调试postgresql源码

编译postgresql

创建目录:

# root下执行
mkdir -p /data/postgres/11.11
chown -R postgres:postgres /data

编译:

#以postgres账号登录
tar zxvf postgresql-11.11.tar.gz
cd postgresql-11.11
./configure --prefix=/data/postgres/11.11 --enable-debug --enable-cassert --enable-depend CFLAGS="-O0"
make world
make check #可不执行
make install-world

如果要调试,需要开启debug选项。

–enable-debug:向gcc传递-g参数

CFLAGS=“-O0”:向gcc传递 -O0参数

make world成功会出现:

PostgreSQL, contrib, and documentation successfully made. Ready to install.

make install-world成功会出现:

PostgreSQL, contrib, and documentation installation complete.

初始化数据库

/data/postgres/11.11/bin/initdb -D /data/postgres/11.11/data

输出:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /data/postgres/11.11/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Asia/Shanghai
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /data/postgres/11.11/bin/pg_ctl -D /data/postgres/11.11/data -l logfile start

设置环境变量

vi .bash_profile

export PGDATA=/data/postgres/11.11/data
export PATH=/data/postgres/11.11/bin:$PATH

安装gdb

参考文章CLION+gdbserver远程调试C项目

启动postgresql

在postgresql的入口下断点,main函数入口src/backend/main/main.c

这样就不能使用pg_ctl启动pg,需要直接启动postgres。

gdbserver :1234 postgres

输出:

Process postgres created; pid = 58113
Listening on port 1234

客户端clion设置远程调试

在这里插入图片描述

注意设置这里的路径映射,否则调试的时候无法在断点处停留下来。

在这里插入图片描述

点击debug进行调试,发现已经在指定的断点处停下来。

在这里插入图片描述

参考文档:

https://www.jetbrains.com/help/clion/remote-debug.html#remote-config


http://www.kler.cn/news/292534.html

相关文章:

  • 前端Vue框架,本地数据库nedb
  • python 打包tkinter图标问题
  • fastadmin 文件上传七牛云
  • html中,想添加一段文字,使用什么标签最合理?
  • nginx的基本使用示例(负载均衡,虚拟主机,动静分离)的详细配置过程
  • 2024挖漏洞给报酬的网站汇总,兼职副业3天收益2k
  • 路灯线路电气安全存在的问题与防护措施
  • ARM基础知识
  • 使用C++编写接口调用PyTorch模型,并生成DLL供.NET使用
  • pytest 常用的辅助函数和工具函数
  • springboot 实现策略模式通过id进入不同的服务类service
  • C++ 设计模式——解释器模式
  • 免费OCR 文字识别工具
  • 【机器学习】神经网络、隐藏层的基本概念、如何选择隐藏层数量以及胶囊网络对神经网络的影响
  • PowerShell脚本编写:自动化Windows开发工作流程实例介绍
  • 2024年全国大学生数学建模C题解题思路
  • 第 2 章:AJAX 的使用
  • C++:类型转换
  • 12、Flink 解决流上的确定性最佳实践
  • 使用视图方式操作MySQL数据表
  • Java笔试面试题AI答之JDBC(1)
  • C语言-数据结构 无向图普里姆Prim算法(邻接矩阵存储)
  • selenium连接远程chrome浏览器
  • MIT线性代数
  • 【java】将Map的value类型定义为Object
  • 第十五题:三数之和
  • rancher搭建k8s及jenkins自动化部署
  • 骨传导耳机哪款好?精选五款热门骨传导耳机分享让你避免踩雷
  • 对HashMap的理解
  • 使用本地预训练模型可视化卷积每一部分