How to debug an external source code linked to scilab with Eclipse CDT.
Warning : this is a very tiny tutorial aiming at showing how to debug *.so file linked to scilab within Eclipse, and is intented to person with some familiarity with Eclipse CDT. This tutorial runs on Eclipse Galileo release (July 2009), and Ganymede Release (pre-July 2009). Be careful : your scilab-bin file must point to a real binary file, not a script...( you need to "make install" Scilab Master build, not just compile it, as it provides script in the /bin directory. )
You should use a custom Makefile in your Eclipse project. I didn't check if the automaticaly generated Eclipse Makefile work or not... Build all your static object with the "-g" flag (It's assumed that you're using the gcc compiler). Be careful that "-Ox" flag can modify the sequence of your code.
Right-Clic on your project's name>Debug As>Debug configuration.
- Create a new entry below "C/C++ Attach to local Application".
- In the "Main" tab :
- Put the name of your project in "Project" box
Put the path to Scilab binary (eg /SCILAB_PATH/bin/scilab-bin)
- In the "Main" tab :
- In Debugger tab :
- Let everything as default in "Main".
- Add the path to you shared library .so in the Directory List.
- Check "Load shared library symbols automaticaly".
- In Source : let everything as default
- In Common : Check "Debug" below Display in favorite menu.
- Save your project
Start a debug session
- Double click in the margin at the line of the source code where you want to set a breakpoint.
- Run Scilab.
Then Click on the green bug icon on the top bar, and select the first entry (should be "projectname Default"). You can also right click on the name of your project>Debug as>Debug config, select the entry below C/C++ Attach to local application, and hit "Debug".
- Select the scilab process (called "scilab-bin")
- Hit yes when Eclipse ask if you want to switch to the debug perspective. It may be necessary to hit "resume" (F8) right after the debug session has start, as the pcond_thread seems to behave as a breakpoint for Scilab. That is to say, if scilab hang when entering Debug perspective , just hit F8 in Eclipse.
- Load your library in scilab. This should made debugging feature available.
- Useful Shortcuts :
- F8 : resume
- F6 : step-by-step mode.
- You can track the content of the registers and of the memory on the top-right hand window.