lunes, 3 de marzo de 2008

Proof of Concept

For the Free Pascal plugin to succeed debugging capabilities are essential (furthermore, some colleagues have said us that they won't recommend such a Pascal development environment unless it has debug support). In order to study the feasibility of the approach we have tried first to debug a Pascal program with the CDT debugger.

First, I have written a small Pascal program that shows the maximum of two numbers. The function max has been defined in its own unit to measure step into capabilities of the CDT debugger across multiple Pascal files. The Free Pascal compiler has an option that can be used to generate an executable with information for the gdb debugger (-g). So we used this option to generate the application.

Now we have to create a C project, and we have to copy the binary, and the two source files (debugee.pas and maths.pas) into it. Next, we run the Debug as... dialog and write in the C/C++ Application field the name of our executable (debugee.bin). We cannot take advantage of the Search Project button, because the application is not recognized by CDT as a C/C++ application.


We are ready to debug our application. The program is halted in the first line of the main function. In Pascal this means that will halt in the first line between the "begin..end." of a program.

The first thing that can be seen is that the variables view is not populated with the variables of our program... However, the source code is correctly managed by the debugger, and the source code of our Pascal program is opened and shown with the first line highlighted. Let's step into the max function.

The debugger opens the Pascal unit source code as expected, and is positioned in the first line of the max function. In this case we can see that the actual parameters are populated into the variables view. Also note that the console shows the message wrote.

So we can use the debugger ui buttons to step over the sentences of the program. The variables are not shown in the variables view, although we can watch them adding watch expressions. This procedure works both under Windows and Linux. For the tests we have used EclipseGavab, which comes with a Pascal plugin (hence the syntax highlighting) and CDT.

No hay comentarios: