![[Images/tutorial.gif]](Images/tutorial.gif)
Debugging Khoros code
Table of Contents - Index
Previous: Making things run faster
Next: A Small Guide to what can go wrong with Khoros programs.
![[bar]](Images/rule.gif)
Make that the Lazy method :-)
This is the simplest method: just fill your source code with kprintf calls. For example, if you have a segmentation fault in your program and does not know where it is, put some kprintf calls to show until where the program went without crashing. Using kprintf can also show critical values for variables in the programs. Of course when you catch the bugs you should remove all kprintf's.
I always suggest that you should take some time and check the results of all functions, please see
Did you checked the return values for the functions ?
![[bar]](Images/rule.gif)
Gdb is the Gnu Debugger, and can be used to debug Khoros programs with several control options. Using gdb with Khoros is very simple. First make sure you have compiled all Khoros programs with the option
#define UseOptimization NO
(defined in your $KHOROS/bootstrap/config/Site.ARCH file, where ARCH is your architecture). If you read this file you'll see that there are options to override it, and there are more options related to debugging in the $KHOROS/bootstrap/config/ARCH.cf file.
By default these options are set so you shouldn't need to worry about it.
To debug a program you created follow these steps:
- Go to its directory and do a make. For example, if you have a kroutine called sobel in a toolbox called imagemore, go to the directory $IMAGEMORE/objects/kroutine/src/sobel and run make. If the program depends on a library, e.g. if the kroutine has a corresponding library call, make sure that the library is also compiled.
- If the program was compiled without problems, run gdb without parameters.
- From gdb, use the command run with the parameters that the program sobel requires, e.g. run -i a.pgm -o b.pgm -method 1
Note: I use gdb only when I have a segmentation fault or similar error and I cannot locate it easily, and I don't have much experience in gdb. As soon as I learn more I will try to write a small guide for it :-)
Also, I tried this method with FreeBSD 2.2 and it worked without problems, please let me know if it works in other architectures too.
![[bar]](Images/rule.gif)
Table of Contents - Index
Previous: Making things run faster
Next: A Small Guide to what can go wrong with Khoros programs.
![[bar]](Images/rule.gif)
These pages copyright ©
Rafael Santos (e-mail valid until March 1998). Please let me know if this tutorial is useful for you, I need to justify the time I used to develop it. Comments, requests and bug reports are also welcome, but please see the section
Before you e-mail me...
![[bar2]](Images/rule2.gif)
Khoros copyright © Khoral Research, Inc. (KRI) - run klicense for more information.
Khoral Research Inc. is not responsible for or is supervising these pages.
![[bar2]](Images/rule2.gif)
The latest version of this document can be found at
Ejima Lab Khoros Pages at Kyushu Institute of Technology, Japan (until March 1998).
Mirrors for this tutorial can be found at Universidade do Vale do Paraíba, Brasil and PUC/RS, Brasil.
![[bar2]](Images/rule2.gif)
Generated with StructHTML, 14:19 August 30, 1997