-
Notifications
You must be signed in to change notification settings - Fork 6
3 Debugging with CLion
Instructions written with generous help from Jamie Smith and Austin Traver.
You can use the Docker image for building and debugging while working on your favorite IDE on your local machine. This tutorial will go through setting things up with CLion, a Jetbrains IDE that you have a license to use as a student. Download it here.
You have a couple options for integrating CLion with the xv6 codebase: CMake or existing Makefiles.
To set up with the existing xv6 Makefiles, install the Makefile extension
in CLion. The IDE should then automatically detect the project's Makefile and work. After running make qemu-nox-gdb
, a .gdbinit
is generated.
You'll need to remove the following lines for it to work:
I'm grateful to Jamie Smith for setting up a CMake config for the xv6 assignments. You'll need to download the corresponding xv6-clion files from his fork of xv6 and place them in the xv6-public-master
directory. Please follow his setup guide to setup CMake for CLion
After you've followed the instructions above, you're ready to set up a remote debugging configuration with the running Docker image. Make sure you execute ./run.sh start
before continuing on below.
First, create a new GDB Remote Debug
configuration.
Next, within Clion, go to Preferences
and search for Edit Configurations
, and configure the following settings:
-
GDB
: Bundled GDB multiarch (may need to installgdb
locally) - 'target remote' args:
localhost:25000
- Symbol file:
/YOUR-PATH/xv6-public-master/kernel
- Sysroot:
/YOUR-PATH/xv6-public-master
- Path Mappings (Remote to Local):
/xv6_docker/
to/YOUR-PATH/xv6-public-master
Your finished configuration should look something like this:
- Setup your terminal in the IDE (optional)
As far as setting up your terminal within the CLion IDE, I haven't (yet) come up with a seamless way to integrate the debugging environment with CLion. For the time being, open up CLion, create a new terminal window, and cd
into to the cs350-docker
directory. You might want to split the terminal screen on the bottom with the debugger window.
-
From within the Docker container, run
make qemu-nox-gdb
- Make sure you're in a Docker shell and run the command to start a
gdb
session.
- Make sure you're in a Docker shell and run the command to start a
-
From within the Clion IDE, set a breakpoint in the code, and begin a remote debugging session
Make sure the configuration you made in 2
is selected and click the green bug icon:
It might take a while for the server to detect the port open from the Docker image, but a Debug window will eventually open in CLion and show you some very useful information about variables and registers!