Currently the GNAT Ada and SPARK tools are installed on student.compute. You will need to log in to this machine to use the tools.
When ssh'ing to student.compute, include option -Y. This avoids some cut-and-paste problems with the GPS IDE.
At a terminal shell, run
module add GNAT
module add SPARK
to add directories containing the the tool executables to your current PATH.
If you are using the default DICE GNOME-based window manager, the GPS IDE tool might have problems displaying certain pop-up windows. To avoid this, run at a terminal shell the command
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/DialogsUseHeader':<0>}"
You only ever have to do this once: this setting is remembered permanently. If you need to undo it for some reason, run
gsettings reset org.gnome.settings-daemon.plugins.xsettings overrides
This is not a problem with the alternate KDE window manager.
Type
gnatprove -Pproject.gpr -u sparkfile.adb
to run GNATprove with project file project.gpr on SPARK source file sparkfile.adb. The provided project files contain some useful default switches for GNATprove.
Switches of interest include
gnatprove -Pproject.gpr --clean
to completely clean out the intermediate files created by GNATprove. For example, GNATprove remembers which prover successfully last proved each VC and will use that prover again rather than trying in turn provers listed using the --prover switch.
gps -Pproject.gpr
to start up GPS using project file project.gpr.
To make available the full range of options when running with GNATprove, switch to the advanced user profile in menu Edit 〉 Preferences 〉 SPARK, by changing the value of User profile from Basic to Advanced.
To have GNATprove both do flow analysis and try proving assertions, select the file and use menu SPARK 〉 Prove File.
At the command line, type
gnatmake -Pproject.gpr sparkfile.adb
to run the GNAT compiler, binder and linker with project file project.gpr on main file sparkfile.adb. As with other project building utilities, GNATmake figures out which files sparkfile.adb depends on, and, as needed, it will compile those too and include them in the binding and linking process.
The provided project files are configured to write an executable file to the current directory with the name of the provided sparkfile.adb without the extension. To run the executable, type
./sparkfile
Occasionally, GNATmake does not realise it has work to do (e.g. if you rebuild with different switch options). In such cases, you can run
gnatclean -Pproject.gpr sparkfile.adb
to delete all the intermediate files and the executable file, forcing GNATmake to start from scratch next time you run it.
tar xf lab1.tar
This will create a directory lab1 containing the following files you need to complete and experiment with. The project file is proj.gpr, so use switch -Pproj.gpr when running GPS or GNATprove.
Compile and run the tests provided in test_search.adb. The proj.gpr file includes a compiler switch -gnata which enables assertion checking. Try adding a bug to one or more of the assertions in binary_search.ads or binary_search.adb and see if one of the tests picks up the bug. Also see if a bug in the input data (e.g. not sorted) or in the code causes an assertion failure.
Generally, testing is a helpful step when debugging assertions.
Solutions will be posted here after students have had a chance to work through labs.
Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk Please contact our webadmin with any comments or corrections. Logging and Cookies Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh |