lunes, 30 de noviembre de 2009

Pascaline: an Eclipse plug-in for Pascal

This blog was supposed to describe, step by step, the development of a plug-in for Pascal based on the FreePascal compiler and CDT. However, as long as this has been done mainly in my free time, when I was developing I hardly had time to post the things I was learning during the process.
Anyway, nowadays, the plug-in is finished. In fact, the new release (third version of the plug-in) was finished in september. This is the web page of the project.
This plug-in has been used during the last three years by more of 3,000 students, which have tested it and proposed improvements. Now we consider it is a mature project.
If you want to give it a try you can install it from the update site, or maybe you want to try out EclipseGavab, an Eclipse package that contains Pascaline, along with other plug-ins we considered useful for our students (like a PascalFC plug-in for concurrent programming).
Please, note that all these tools are open source. Feel free to use them and modify them as you like. However, we'll be very glad if you drop us an email about who you are and where are you using the tools.
Pascaline, PascalFC Development Tools and EclipseGavab are maintained by sidelab.

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.

sábado, 16 de febrero de 2008

The very beginning

I'm starting an Eclipse Plugin for Free Pascal. My intention is to provide a plugin suitable for use in the context of some subjects that we teach at university. Up to now, we have a Free Pascal plugin that has been built from scratch. This plugin is very basic, and lacks some features that nowadays are considered essential, like an outline, a model builder, and debug integration, among others. The plugin is available here, and it has been developed by Micael Gallego and I, along with another plugin for PascalFC, a dialect of Pascal aimed at teaching concurrent programming.

Before starting the development of the plugin, I have taken a look at the technologies suitable for this task. In the context of language support within Eclipse, these technologies are CDT and DLTK. The former is designed like a tool chain that can be extended and particularized for different languages. The later is a general framework specifically tailored for dynamic languages (although other languages could suit well, as it is said in the web page). As long as i know, DLTK is mainly focused on easing the creation of a new language, by means of providing predefined wizards, an abstract editor, an outline...

However, as we need debug support, and Free Pascal compiler is able to produce debug code for gdb (available within the CDT tool chain with very good support), we'll choose the first option.

Before starting to have our hands wet, lets take a look to some documentation about the topic. The official web page of the CDT project is our first source of information. However, there are also other sources of information quite interesting. The Photran project is such one. It contains documentation about the approach taken in accomplishing a similar task for the Fortran language. In fact, it is quite similar, because there are several flavors of Fortran, and so are in Pascal (Delphi, Free Pascal, ObjectPascal.)

I'll use English as the language for this blog. However, my English is far to be perfect, so I hope readers will forgive me. Of course, suggestions and corrections about my English would be highly appreciated.

Hope it will be helpful.