Debugging with GNOME Builder

GNOME Builder 3.26 ships a number of new features, including improved symbol searching, inline documentation and integrated debugging. Prior to this, developers could code and compile their program in Builder, but would need to switch to a separate debugger (either gdb or a graphical debugger like Nemiver). Now that Builder integrates a debugger, a developer can write, compile and run their program with an attached debugger right inside Builder!

Install GNOME Builder

Builder is available in the main Fedora repositories. Install it with dnf or GNOME Software. If you haven’t yet upgraded to Fedora 27, Builder 3.26 is also available in a Flatpak hosted on Flathub and can be installed on any Linux distribution that Flatpak supports.

Clone the project

Clone the stop-watch project in Builder by selecting Open Project from the application menu. Click the Clone… button and enter into the Repository URL field. Click the Clone button to clone and open the project.

Debugging the project

Run the Stop Watch app by clicking the Run button (or press Control + F5). After the project compiles, the Stop Watch window opens.

Note that the Run button may be disabled at first. This is because Builder is downloading the necessary runtimes needed to develop the application. Check the transfers pop-up in the right of the menubar for progress on these downloads. Once the downloads have completed, the build button will enable.

Now try starting the stop watch by clicking Start. Uh-oh. It’s not counting properly. It appears the timer never gets past 1 second.

Open src/stop-watch-window.c and set a breakpoint in the start_button_clicked_cb function by clicking on the line number (line 58 in this case). This will allow you to pause the program once the clicked signal handler is invoked on the Start button.

Now Run with Debugger by clicking the expand arrow next to the Run button, or press F5. Builder automatically sets a breakpoint at the entrypoint to your program (the entry to the main function). Below the editor view, there is a control panel showing the debug controls. Click the Continue button to continue the program execution, presenting the Stop Watch window. Now click the Start button again. This time the breakpoint inside start_button_clicked_cb catches and the program pauses again.

Once again, the debugging control panel will appear. Step over any function calls to maintain execution within this signal handler. As you step, the current line will advance. Since self->timer_started is FALSE, control jumps into the else block. Continue stepping, watching the flow of control through the program until you reach the last line of the signal handler. Look closely at line 76. Looks like the programmer forgot to toggle the timer_started variable! Change line 76 to:

self->timer_started = !self->timer_started;

Now run the program again. Click Start and the timer starts counting seconds properly.

Get Involved

GNOME Builder can debug more than just C programs; it supports Python, JavaScript and Vala too. The GNOME project has a collection of projects aimed at new contributors. For example, take a look at Music for a Python project. If you’re most comfortable with JavaScript, take a look at Maps or Polari. Happy hacking!

Fedora Project community


  1. Hey guys,

    as far as I know builder does not support debugging for python? you can program python but there is no debugging, breakpoint etc. If I’m wrong please tell me how to do it I’d like to know that.


  2. Matthew Bunt

    Builder is beginning to really look like a nice IDE. I hope it’s Rust support gets into better shape soon. RLS has never worked right. Although to be honest I’m not sure if this is an RLS issue or a Builder issue.

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions