The $tree() Function

TotalView also includes the built-in $tree() function that can help you set search paths.

The $tree() function takes the name of a directory, and uses a simple tree-walking algorithm to recursively search a directory and each of its sub-directories for source files. This is useful when your source code is distributed across a large or deeply nested directory tree and you want to search for a file in an entire directory hierarchy.

Long search paths have a tendency to slow performance as TotalView frequently traverses the search path to find files. If the directory is at the top of a deep directory tree, using the $tree() function might cause every subdirectory to be searched, potentially degrading performance.

Syntax

The $tree() function syntax is as follows: 

$tree(directory)

There are the following considerations: 

  • directory is the root of the directory hierarchy you want TotalView to search.

  • Only one directory should be passed per $tree() function.

  • You can use multiple $tree() entries in a search path, but you cannot nest one within another.

Example

To add all sub-directories under /usr/project/src to the source search path:

$tree(/usr/project/src)

TotalView searches /usr/project/src first. If it doesn't find the required file, it continues searching sub-directories recursively.

How $tree() Works

  • The directory tree is walked once, when $tree() is first encountered during a file search.

  • TotalView caches the list of discovered sub-directories to improve performance in subsequent searches.

  • The cache is flushed whenever the search path is changed.

Performance Considerations

Using $tree() may noticeably slow performance under the following conditions:

  • The directory structure is deeply nested.

  • There are many files or directories to scan.

  • The file system is remote or slow.

Use with care in large environments.