next up previous contents
Next: Other Software Tools on Up: Debugging tools Previous: Following are possible causes   Contents

Some useful hints to debug parallel/distributed programs

  1. It is a good idea to test the algorithms with only one process first. ie we should test the algorithm sequentially first and then start with two processes.

  2. dbx can be used to step through the code and find the problem but we can single step the execution of process 0 only. The data of the rest of the processes is observed by printing the variable values at the various steps.

  3. Generous use of printf statements to print the various information at the various steps can be helpful. To print each line of information, it is a good idea to print the process id to distinguish the output from many processes. It is better if the information printed is only one line long otherwise output is very cluttered.

  4. All the debugging statements can be enclosed in #ifdef _DEBUG_ and #endif pairs. Then use #define _DEBUG_, at the begining of the source file to enable debugging. For example,

#define _DEBUG_        /* Only once and at the begining of any source file */ 
#ifdef _DEBUG_
  printf("Process id = %d\n", m_getmyid());
#endif

The debugging statements can be disabled by removing the statement #define _DEBUG_.


next up previous contents
Next: Other Software Tools on Up: Debugging tools Previous: Following are possible causes   Contents
Sushil Prasad 2004-09-16