Setting up FreeBSD 13.0 for debugging Redis using JetBrains CLion and gdb
Setting up FreeBSD 13.0 to debug Redis using JetBrains CLion and gdb.
Contrary to the common belief, FreeBSD is not just for the servers. I am noting down all the steps needed to set up FreeBSD for debugging Redis. Mate Desktop Environment will give life to the Desktop Metaphor. JetBrains CLion will provide the Integrated Development Environment (IDE) – with gcc
, gdb
, and make
doing the heavy lifting behind the scenes – making FreeBSD a potent development environment.
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams.
FreeBSD is an outstanding operating system and I just love it. Netflix, Apple, Sony, and many others would concur.
Setting up FreeBSD 13 as a Desktop Operating System
The installation process is pretty straightforward and very well documented. The only thing special about my install is the ZFS file system in stripe
mode on a single disk. What this means is that:
- the performance benefits of
striping
as available in a multi-disk setup, will not be available; - ZFS snapshots can be taken, but this is not a backup of any sort;
- backups are my responsibility as
stripe
mode, even in a multi-disk setup, is bereft of any redundancy.
The section 2.6.4. Guided Partitioning Using Root-on-ZFS
describes how to configure ZFS in FreeBSD during install.
Once the installation is done, log in to the system as root
, fetch, and install security updates:
A fresh FreeBSD installation has nothing other than command line user interface. The X Window System needs to be installed to get a Graphical User Interface running:
pkg install xorg
FreeBSD graphics driver on bare metal
With xorg
installed, it is time to install DRM kmod
graphics driver for Intel\AMD GPUs.
amdgpu, i915, and radeon DRM modules for the linuxkpi-based KMS components. Currently corresponding to Linux 5.4.144 DRM. This version is for FreeBSD 13. https://github.com/freebsd/drm-kmod/
FreeBSD graphics driver in virtualized environment
Do not install the bare metal drivers in a virtualized environment. Instead do the following:
Mate Desktop Environment and the rest
The following will install a minimal Mate Desktop Environment:
Get sudo:
Add user to wheel
group and use visudo
command to edit the sudoers
file to allow users in wheel
group to run system tools with authentication:
Create a ~\.xinitrc
file with the below content. This will let startx
command know that it is supposed to start a Mate session:
I also installed a few very important applications – chromium
browser, peazip
archive manager, eom
image viewer:
It is now time to reboot
:
ZFS snapshots
Once rebooted, login and execute startx
command to start a Mate session. A snapshot of the file system is in order now. The power of zfs
is simply mind blowing. The only other file system that comes close is btrfs
on Linux:
Recursive snapshots of zroot/ROOT/default
mounted at /
and zroot/usr
mounted at /usr
should suffice:
List snapshots created above:
To rollback to the pristine-state snapshots created above, all I have to do is:
Setting up FreeBSD as a Redis development environment
Redis is written in C language. The source code is hosted on GitHub. Need git
to get it. Compiling it is simple. As per documentation, just make
it in the source code root directory. However, FreeBSD has its own implementation of make
, which is not fully compatible with GNU Make
. On FreeBSD one needs to install gmake
to get the GNU implementation. Also, TCL is required to run tests. Do the following to get everything needed to fetch sources, compile, run tests and debug:
Now let us get the sources:
Running the gmake
and gmake test
commands in the <DESIRED_LOCATION>\redis
directory will compile the project and execute all tests. Thereafter, if one is adventurous enough, a debugging session with appropriate breakpoints can be launched in the terminal using gdb
. Also, gdb
has a curses
-based tui
(Text User Interface) mode that improves usability:

For others that need an IDE to feel at home, vim
or emacs
can be configured to behave as an IDE. There is also a modern alternative for the venerable vim
known as neovim
. I spent a few hours configuring neovim
and gave up. I just do not have the time right now to fiddle with configurations.
JetBrains has a great C\C++ IDE called CLion. It is available in FreeBSD repos and I happen to have a license. This is an option for those who want to hit the ground running rather than fiddling with config\dotfiles:
Setting up JetBrains CLion for Redis debugging
Use the File -> Settings
menu option to launch the following dialog to set up Toolchains
. Make sure to use gmake
for Make
option:

I had downloaded the source manually and asked CLion to load an existing project. CLion informed me that the import works best when clean
is executed. I let it do its thing and ended up with a successfully imported project.
CLion detects all configurations from the makefile
and lists them as shown below. We can use the highlighted ones for debugging redis-cli
(client executable) and redis-server
(server executable). The target executable needs to be filled in in the Executable
field of the dialog.

That is all there is to set up CLion. So simple.

Ricing FreeBSD (optional)
Material Design from Google is quite important in the UX Design world. Materia GTK theme tries to bring the same UX to Unix desktop. Get it:
Papirus Icons are a must for me:
Now comes the ricing of the terminal emulator. What better to spice up the terminal than Oh My ZSH with the agnoster
theme. Installing it is as simple as (install curl
is not already available):
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
To activate agnoster
theme, open .zshrc
and update the ZSH_THEME
key's value to agnoster
.
agnoster
theme requires powerline-fonts
:
References






