In order to easily read the code of seekdb, we suggest using an IDE that can easily index the symbols of OceanBase seekdb. On Windows, we recommend Source Insight; on Mac or Linux, we recommend VSCode + ccls to read the OceanBase code. Since Source Insight is very easy to use, this document skips the introduction on how to use it.
This document introduces how to set up VSCode + ccls, which is very convenient for reading the code of seekdb. ccls is based on cquery, which is one of C/C++/Objective-C LSPs (In one word, LSP is used to provide programming language-specific features like code completion, syntax highlighting and marking of warnings and errors, as well as refactoring routines).
The number of seekdb code is pretty huge and seekdb can't be compiled under Mac or Windows, so we recommend that download the code on the remote server, and start VSCode to access the code under the remote server.
Attention
The following /path/to just means the path example, please replace it with your real path.
In the C/C++ LSP domain, the famous tools are clangd and ccls. Here we recommend ccls, because:
- The speed of building index of ccls is slower than that of clangd, but after building, the speed of accessing index of ccls is faster than that of clangd.
- Unity building is not supported by clangd, but seekdb is built in unity mode, which causes clangd to fail to build index through compile_commands.json.
NOTE: if you don't have the permission for
yum, please usesudo yum ...instead.
yum install epel-release
yum install snapd # On centos8: yum install snapd --nobest
systemctl enable --now snapd.socket
ln -s /var/lib/snapd/snap /snap
snap install ccls --classicAnd then add the command below into your env source file, such as '/.bashrc' or '/.bash_profile'
export PATH=/var/lib/snapd/snap/bin:$PATHNow, refresh your environment like this:
source ~/.bashrc # or
source ~/.bash_profileapt-get -y install cclsNOTE: If you don't have the permission, please use
sudoas the command prefix.
You can run the command below to check whether the installation was success.
ccls --versionOnce the source code has been located in the remote machine, it is easy to setup debugging environment in remote machine. At the same time, the application can be run faster because remote machine is more powerful. User can easily access the source code on the remote machine even when something is wrong with the network, just wait reload after reconnect the remote server.
Download and install the Remote plugin from the VSCode extension store.
NOTE: Make sure the connection between the local machine and the remote machine is fine. After installation the plugin, there is one icon in the left bottom corner of VSCode.
Press the icon and select Connect to Host, or press shortkey ctrl+shift+p and select Remote-SSH:Connect to Host:
Input user@remote_ip in the input frame, VSCode will create one new window, please input password in the new window:
After input the password, VSCode will connect to the remote server, and it is ready to open the remote machine's file or directory.
If you want to use the specific port, please choose Add New SSH Host, then input ssh command, then choose one configuration file to store the ssh configuration.
After that, the configured machines can be found in the Connect to Host.
Password need to be input everytime. If you want to skip this action, please configure SSH security login with credential.
We do not recommend using C/C++ plugins as they do not provide good indexing capabilities for seekdb, and they are not compatible with the ccls plugin.
C/C++ plugin can be download and installed in VSCode extension store in the case of simple scenarios:
C/C++ plugin can automatically code completion and syntax highlighting, but this plugin failed to build index for seekdb, it is hard to jump the symbol of seekdb.
If ccls will be used, it is suggested to uninstall the C/C++ plugin.
- Press the setting icon and choose Extension Settings
- Set config ccls.index.threads. CCLS uses 80% of the system cpu cores as the parallelism in default. We can search
threadsin vscode config page and set the number like below.
As default, oceanbase built in unity mode and it costs more memory than usual case. The system maybe hangs if the parallelism is too high such as 8C 16G system.
-
Git clone the source code from https://github.com/oceanbase/seekdb
-
Run the command below to generate
compile_commands.jsonbash build.sh ccls --init
After that, compile_commands.json can be found in the directory of code_path_of_oceanbase.
After finishing the previous steps, please restart VSCode. The index building procedure can be found at the bottom of VSCode:
After finishing building the index, function references and class members can be easily found for any opened file as shown in the following example:
Recommended ccls shortcut key settings:











