Posts

Showing posts from March, 2010

Debugging QUALNET with GDB

Compiling QualNet with Debug Option By default, the optimization option of the compiler is enabled in the Linux and Mac OS X Makefiles. When the optimization option is enabled, the compiler may optimize the program for better performance. However, for better source level debugging, the optimization option of the compiler should be disabled and the debug option should be enabled. Perform following steps to recompile QualNet with the debug option enabled: 1. Go to QUALNET_HOME/main. Copy the makefile for your compiler to Makefile. 2.Edit Makefile as follows: •Enable the DEBUG line by removing the ‘#’ character so it is displayed as: DEBUG = -g •Disable the OPT line by inserting a ‘#’ character at the beginning of the line so it is displayed as: # OPT = -O3 3.Recompile QualNet by typing the following commands: make clean make Running the Debugger QualNet can be run from within debug tools such as gdb or dbx. Here, we use gdb as an example. To run gdb, perform the following

Regular expression for the functions

If you wanna have something like int thisFunction(int a, int b) { to be turned into int thisFunction(int a, int b) { printf("thisFunction Started"); You can search for functions using the following regular expression: [[a-zA-Z0-9_-]+[\s]+]?[a-zA-Z0-9_-]+[*]?[\s]+[*]?([a-zA-Z0-9_-*]+)[\s]*\([\s]*([a-zA-Z0-9_-]+[\s]+[*]?[*]?[*]?[a-zA-Z0-9_-]+[,]?[\s]*)*\)[\s]*\{ update: (static)?[\s]+(//inline//[\s]*)?[a-zA-Z0-9_-]+[*]?[*]?[\s]+([^\s\(]+)[\s]*\([^\)=]*\)[\s]*\{ Replace with: \0 // \1 Started\r\nprintf("\1 Started"); update: \0 // \3 Started\r\nprintf("\3 Started");