How do I DYNAMICALLY manage my search path so TotalView finds my source files?

 

Last week's tip showed how to initialize the EXECUTABLE_PATH variable to a predefined search path. This week's tip presents a Tcl proc that will do a better job:

# Usage:
#
#	rpath [root] [filter]
#
# If root is not specified, start at the current directory. filter is a
# a regular expression that removes unwanted entries. If it is not
# specified, the macro automatically filters out CVS/RCS/SCCS
# directories. The TotalView search path is set to the result. 
 
proc rpath {{root "."} {filter "/(CVS|RCS|SCCS)(/|$)"}} {
 
	# Invoke the UNIX find command to recursively obtain 
	# a list of all directory names below "root".
	set find [split [exec find $root -type d -print] \n]
 
	set npath ""
 
	# Filter out unwanted directories.
	foreach path $find {
		if {! [regexp $filter $path]} {
			append npath ":"
			append npath $path
		}
	}
 
	# Tell TotalView to use it.
	dset EXECUTABLE_PATH $npath 
}

Notice that the CLI is executing the shell's find command to traverse your computer's file system. The found directories are then appended to a variable.

Notice that the statement setting the EXECUTABLE_PATH variable is the only statement that is unique to the CLI.


You can find tips that we've already sent out in our Tip Archive

Help us improve these tips!