Unryu: Debugging

Unryu debugs a program with GDB: breakpoints on lines, stepping, the call stack, the local variables, watches, and a name's value when you rest the pointer on it. GDB's own console is the Terminal tab, so every GDB command still works there, and the program's input and output are there too.

1. Starting

Build the program with debugging information (-g), and without optimization (-O0) to step line by line. Then choose Debug > Start (Ctrl+F5). The program is the one the project's debug session names (Debug > Set Target...: the program, its arguments, and the folder it runs in); with none set, it is what Build makes of the file in front (prog for prog.c, in its folder), and when that is not there either, Set Target asks.

GDB starts in the Terminal tab, as its console, and the sidebar gets a Debug page. Unryu sets your breakpoints and runs the program. A breakpoint in a library not loaded yet is kept for when it loads. When nothing else runs in the Terminal tab: something that runs there already must stop first.

Unryu talks to the same GDB over its machine interface, on a pseudo-terminal of its own (GDB's new-ui), so what you type in the console and what you do in Unryu go to one GDB. A breakpoint you make or delete in the console shows on its line too. Run, Continue, the steps and Run to Cursor are typed into the console for you (run, next, until ...): GDB gives the terminal to the program only for its console's commands, so this way a program that reads its input gets it. While the debugger runs, Build > Execute does not stop it; Debug > Stop does.

2. Breakpoints

Debug > Toggle Breakpoint (Ctrl+F9) puts a breakpoint on the cursor's line, or takes it off; Shift+click in the markers margin does the same for the line clicked (a plain click there is a bookmark). A breakpoint is a red dot in the markers margin, and moves with its line as you edit. Debug > Remove All Breakpoints takes them all off. You can set them before starting and while the program runs or is stopped.

3. Running and stepping

ItemKeyWhat it does
Start / Continue / Run AgainCtrl+F5Starts the debugger; while the program is stopped, lets it go on; after it ended, runs it again from the start.
PauseStops the running program where it is.
StopCtrl+Shift+F5Ends GDB and the program.
Step OverF6The next line, a function it calls run whole.
Step IntoF7The next line, into a function it calls.
Step OutShift+F7To the end of the function, back in its caller.
Run to CursorCtrl+F7On until the cursor's line.

When the program stops, its file opens at the line, which has a yellow arrow in the markers margin and its own background (the editor theme's execution and execution-text; the breakpoint's dot is breakpoint). The status bar says why it stopped: at a breakpoint, stepped, out of the function, at the cursor, or the signal it got. When it ends, the status bar says its exit code. While the window is hidden, the tray tells you (The Window).

4. The Debug page

The sidebar's Debug page shows, at each stop:

The page is there while the debugger runs, and goes when it stops.

5. Values on hover

While the program is stopped, the popup over a name has one more row, Value now: GDB's value of that name at this stop (it says "asking GDB" for the moment it takes).

6. The session

Each project keeps its debug session: the program, its arguments and folder, the breakpoints and the watches, in debug.conf in Unryu's settings folder. A file of no project keeps its session with its folder. They come back when you open the project's files again, and are saved as you change them and when Unryu quits, each breakpoint at its line then.