Debugging programs

To debug programs you will need to compile them first with symbolic debug information. For this, you need to specify the "-g" switch when compiling. If you followed the instructions found in Compiling programs, you need to enter '${resource_loc} -g' in the arguments field. Once you do this, you should see an executable in the project folder (an .exe file, if on Windows).

Descent acts as an interface to a command line debugger, so you will also need one. Currently Ddbg and Gdb are supported (see: Will other debuggers be supported?).

Selecting the debugger to use

In Windows -> Preferneces -> D -> Debug you can select the debugger to use, specify it's location and some other options.



Debugging

Before debugging you need to add breakpoints in your source files. You can do so by double click the right side of an editor containing a .d file, or by right click in the same location and selecting "Toggle Breakpoint".



Right click on the executable file and select Debug as -> D Application. The debuggee's output is redirected to a new console.



You can customize the way the program is executed in Run -> Debug ...



Here you can specify the arguments passed to the program, the environment variables and the search source path.



The debug views

When a breakpoint is hit, Eclipse will ask you if you want to switch to the Debug Perspective. Say yes.

The Debug View shows the stack frame of the current thread, and why the thread was suspended. You can navigate the stack frames by clicking on them. The buttons on the top allows you to continue or stop the execution of the program, to step into, over or out.



The Variables View shows the locals variables and arguments of the current function. Values cannot be changed in the current version.



The Breakpoints View shows the current installed breakpoints. From here you can enable, disable or delete them.



The Expressions View allows you to evaluate arbitrary expressions. The expressions will evaluate only if the underlying debugger understands them.



The Registers View shows the current status of the machine registers for the program.



The Memory View allows you to examine regions in the memory and display them as hexadecimal numbers, ascii, signed integers and unsigned integers.



If any view dosen't show, you can show it in Windows -> Show View -> Others... in the Debug category.

Will other debuggers be supported?

Other debuggers can be supported by creating a plugin that defines a new debugger in the descent.launching.debuggers extension point, and by creating a class that implements the descent.launching.model.IDebugger interface.