vscode 调试oceanbase源码

【 使用环境 】
开发环境 , 16G内存,至强CPU 6核 12线程,ubuntu18.04
【 OB or 其他组件 】
oceanbase 源码
【 使用版本 】
4.0
【问题描述】
希望能用vscode 调试 oceanbase源码,成为oceanbase的贡献者
【复现路径】
1. 执行git命名从github下载源码
2. 进入oceanbase 执行 sh build.sh debug --init -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
3. 进入build_debug 目录执行 make -j 8
4. 打开vscode
5. 配置launch.json。“program”: “/opensource/cpp-source/oceanbase/build_debug/src/observer/observer”
6. 配置c_cpp_properties.json。 “compileCommands”: “${workspaceFolder}/build_debug/compile_commands.json”
7. debug启动 src/observice/main.cpp
【问题现象及影响】
在main.cpp 进入除了 observice目录下的源码,其他目录的源码都打不开

在执行到435,FileDirectoryUtils::create_full_path(CONF_DIR) 执行失败,无任何错误退出程序

【附件】

1 个赞

不能回答的你问题,

建议 源码编译 +gdb调试 +obd启动

  • observer默认几百个线程,后面无法从main函数之间启动测试了
  • 参考obd离线部署
cd build_debug
/oceanbase/oceanbase/build_debug
以本地目录为基础创建一个镜像。此命令主要用于使用 OBD 启动自行编译的 OceanBase 开源软件,您可以通过此命令将编译产物加入本地仓库,之后就可以使用 obd cluster 相关的命令启动它
make DESTDIR=./ install 
obd mirror create -n oceanbase-ce -V 3.1.4-1 -p ./usr/local -t my-oceanbase
obd mirror list
1 个赞

谢谢大佬,有操作文档吗?感谢大佬。 我主动的是java,c++这里不是很懂

没有完整描述 可以看看这个 https://wangcy6.github.io/post/oceanbase/2022/oceanbase_day2/
开发部分

debug mode
bash build.sh debug --init --make -j8
cd build_debug
/oceanbase/oceanbase/build_debug
以本地目录为基础创建一个镜像。此命令主要用于使用 OBD 启动自行编译的 OceanBase 开源软件,您可以通过此命令将编译产物加入本地仓库,之后就可以使用 obd cluster 相关的命令启动它
make DESTDIR=./ install 

1.1 在线安装 OBD

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y ob-deploy # 该操作只需要在 OB 中控机上执行,因为 OBD 是一个黑屏部署、管理和运维工具,统一从一台机器上发起操作,所以不需要每台机器均安装

obd mirror create -n oceanbase-ce -V 3.1.4-1 -p ./usr/local -t my-oceanbase
obd mirror list

+------------------------------------------------------------------+
|                      Mirror Repository List                      |
+----------------------------+--------+---------+------------------+
| SectionName                | Type   | Enabled | Update Time      |
+----------------------------+--------+---------+------------------+
| oceanbase.community.stable | remote | False   | 2022-08-01 19:49 |
| oceanbase.development-kit  | remote | False   | 2022-08-01 19:49 |
| local                      | local  | -       | 2022-08-02 10:59 |

离线安装部署,必须禁用远程仓库:
禁用远程仓库
obd mirror disable remote
Disable remote ok

[ERROR] Repository(/root/.obd/repository/my-oceanbase/3.1.4-1/my-oceanbase) existed

[root@node1 build_debug]# obd mirror create -n oceanbase-ce -V 3.1.4-1 -p ./usr/local -t 
[root@node1 build_debug]# obd mirror create -n oceanbase-ce -V 3.1.4-1 -p ./usr/local -t my-oceanbase
Package ok
name: oceanbase-ce
version: 3.1.4-1
release:20220814195653
arch: x86_64


配置文件:【1】
https://gitee.com/oceanbase/obdeploy/blob/master/example/mini-distributed-example.yaml
echo 'fs.aio-max-nr=1048576' | sudo tee /etc/sysctl.conf
sysctl -p

echo -e "root soft nofile 655350\nroot hard nofile 655350\n* soft nofile 655350\n* hard nofile 655350">> /etc/security/limits.conf


obd cluster deploy test -c /oceanbase/mini-local-example.yaml
obd cluster deploy test -c /root/mini-local-example.yaml
obd cluster start test
# Connect to the OceanBase Database by using a MySQL client.
mysql -h127.1 -uroot -P2883

不需要部署集群哈。目前连最简单的启动流程,sql流程,事务流程,内存模型,日志流程等等都debug不了哈。

上面单个节点的。ob官方教程也有vscode +命令启动 这个不方面

https://github.com/oceanbase/oceanbase/wiki/how_to_debug

只有gdb的文档,没有vscode的。连接地址在教学视频里面有vscode。等两天去看,就没有了。