Geany is an IDE the supports a number of languages including Vala. This tutorial will show you how to get the debugger plugin for Geany working with Vala code. At the time of this writing the plugin in the Ubuntu repositories happens to be broken. We’ll install it from source and configure it for Vala. If you don’t use Ubuntu or a derivative like Elementary OS this article should still be applicable. You just might need to change a few things.
You can install Geany with:
sudo apt-get install geany
There is a package called geany-plugin-debugger. You can try installing it. At the time of this writing its broken. It installs to the wrong location. If you copy the files to the right location it causes a segmentation fault as soon as you enable it. This was reported half a year ago: https://bugs.launchpad.net/ubuntu/+source/geany-plugins/+bug/1354747
Instead you can get all the plugins for Geany off Github. At the current time the version of Geany in the Ubuntu repos is 1.24. All we care about is the debugger but the other ones are nice to have. I removed the ones from the build script that won’t compile on 1.24 and forked it. You can get it using this command:
git clone https://github.com/agronick/geany-plugins.git
If you have Geany 1.25 grab the offical one:
git clone https://github.com/geany/geany-plugins.git
You need autotools to compile it. Just do
sudo apt-get autotools
Now to install it just do:
make -j PROCESSORS #Replace PROCESSORS with the number of processor cores your computer has or the number of jobs you want to spawn to compile
sudo make install
Hopefully this worked. If you get an dependency error install whatever dependency is missing.
Now open up Geany. If you go to Tools > Plugin Manager you should be able to enable the debugger. It wont work just yet though. There are a few more things you need to set up.
At this point you’ll want to create a new project. Now you’ll need to set the build parameters. Go to Build > Set Build Commands.
Set this under Vala Commands:
valac -c "%f"
valac -g --save-temps --pkg gtk+-3.0 "%f"
You can remove the –pkg gtk+-3.0 part if you don’t want to build GTK apps.
Now you will need to do the following:
- Insert a breakpoint in your Vala program
- Click the build icon
- Open the debugging view
- Browse for the executable it created
- Run your Vala program
There you go. You now have a working Vala debugger. You can step through the code and look up variables at runtime right in your IDE. I hope this helps and is useful. I know I was looking for it for a few months. Its nice to finally have.
I also made this video on how to debug segmentation faults in a command line: