How do I debug my source code in SimWB using the GUI?
Question
How do I debug my source code in SimWB using the GUI?
Answer
Debugging source code under SimWB
SimWB provides the ability to debug models using KDbg. The following steps are needed to start the debugger from SimWB.
- First re-make the code with the –g flag. This is done by modifying the make file in the source code folder on the real-time host. This should be the default when generating the code from the SimWB MLToolkit.For example:
- Go to "/usr/local/ccursim/projects/RTW.Sources/modelname_ccurt/modelname_ccurt" folder where "modelname" is the name of the model.
- Edit the "modelname.mk" file
- In the General User Options add the –g flag. Approximately line 153 in the model Makefile file should now read OPTS = -g
- Use the commands "make –f modelname.mk clean" and "make –f modelname.mk" to remake the model.
- In the SimConfig GUI, go the test/session tab and select the test/session you want to run.
- Go to the Debug Options tab and make sure the Debug Selected Tasks checkbox is checked, the list of models in your test should appear in the list. Select the model you want to debug.
- Go back to the Run/Playback tab and click the Run button.
- The KDbg GUI will open and stop in the ccurrt_mainC.c file for this model. If the debugger stops in the schedutils.c task it is an indication that you need to remake the source with the –g file.
- If the debugger window does not open, look in the cfgsrv.log - under the cfgsrv tab in the message window. There will be a system message that indicates why SimWB could not open the debugger window in your X server. Refer to the step above on how to allow remote connection to your X server.
- Now you can place break points in the source code to debug the model. The model is called by the rt_OneStep() function.