Debugging Giac

It is well-known that the dynamic geometry software tool GeoGebra is free for studying and teaching mathematics. It is, however, not so well-known that it has an embedded computer algebra system, Giac, which has been developed mostly by Bernard Parisse, a French mathematician at the University of Grenoble.
Bernard is a geek not only in mathematics but also in programming. He wrote the most parts of Giac in C++, and when he develops the code, he uses standard Unix tools like gdb to debug the issues. Unfortunately, this prevents young people who are not familiar with command line tools to contribute code to Giac.
At GeoGebra we maintain Giac's code in a dedicated folder. We also have a mirror of that folder at GitHub. We are not just storing Giac's code in a publicly available directory, but also contribute to Giac by the development of some modern code including

  • the npm port of Giac,
  • an example on how Giac can be embedded in an Electron application (via node.js),
  • a Gradle script to compile Giac on various platforms:
    • JavaScript (via emscripten),
    • WebAssembly (via emscripten),
    • Java Native Interface on Windows, Linux and macOS (via SWIG),
    • natively on Linux,
    • Android and iOS (mostly contributed by Balázs Bencze).

Recently I learned that CLion (which is developed by the JetBrains people) can import the source code of Giac and, after some manual steps, it produces a CMakeLists.txt file which can be more or less useful to compile the code with cmake, and also with CLion itself. Unfortunately, CLion is not free, but luckily there is a 30 days evaluation version, and for open source developers it may be freely available under some circumstances (please check the discounts page if you are eligible).
As a result, now it is possible to do GUI based interactive debugging on Giac. I provide some screenshots below to give you a taste on how it works.
Start debugging: Giac starts to compile (via cmake)
Compilation progress is at 47%
...and at 98%
The console application starts interactively in the Console tab
A breakpoint is triggered
Debugging the code interactively
As an additional result Giac can now be compiled via cmake as well. At the moment there is no support yet to detect the GMP and MPFR libraries properly, but I plan to add some code to have a platform independent way to compile Giac not on Linux only.

Comments

Popular Posts