Using Sun WorkShop

Controlling the Browser Database With sb_init

This section describes how to work with source files whose database information is stored in multiple directories. As a default, the database is built in the current working directory and searches that database when you issue a query.

Understanding sb_init

The text file sb_init is used by the Source Browsing mode of Sun WorkShop, the compilers, and sbtags to obtain control information about the source browsing database structure. Use sb_init if you want to work with source files whose database information is stored in multiple directories.

The sb_init file should be placed in the directory from which source browsing, the compilers, and sbtags are run. These tools look in the current working directory for the sb_init file.

Moving the sb_init File

The default is to look in the current working directory for the sb_init file. To instruct Sun WorkShop and the compiler to search for the sb_init file in another directory, set the environment variable SUNPRO_SB_INIT_FILE_NAME to /absolute/pathname/sb_init.

File Commands

To use an sb_init command, add the command to the file. The sb_init file is limited to the following commands:

Command Reference

import


import /pathname
 to directory

This command allows the Source Browsing mode of Sun WorkShop to read databases in directories other than the current working directory. Use of the import command enables you to retain separate databases for separate directories.

For example, you may want to set up administrative boundaries so that programmers working on Project A cannot write into directories for Project B and vice versa. In that case, Project A and Project B each need to maintain their own databases, both of which can then be read but not written by programmers working on the other project.

In Figure D-1, the current working directory is /project/source1. The database in source2 is read by including either of these commands in the source1 sb_init file:


import /project/source2
import ../source2

Figure D-1 import Example

Graphic

export


export prefix 
into path

This command causes the compilers and sbtags to write database component files associated with source files to directories other than the current working directory used by the Source Browsing mode of Sun WorkShop and the compiler.

Whenever the compiler processes a source file whose absolute path starts with prefix, the resulting browser database (.bd) file is stored in path.

The export command contains an implied import command of path, so that exported database components are automatically read by the Source Browsing mode of Sun WorkShop.

The export command enables you to save disk space by placing database files associated with identical files, such as #include files from /usr/include, in a single database, while still retaining distinct databases for individual projects.

If your sb_init files include multiple export commands, then you must arrange them from the most specific to the least specific. The compiler scans export commands in the same order that it encounters them in the sb_init file.

In Figure D-2, to place the .bd file and index file created for files from /usr/include in a database subdirectory in the sys subdirectory, the user included this export command in the sb_init file for source1:


export /usr/include into /project/sys

Figure D-2 export Example 1

Graphic

If the configuration had included a source2 directory with a sb_init file containing the same export command, then you would save disk space because you did not create two identical database files. For the stdio.h files, the compiler would create a single database file for stdio.h in the sys subdirectory.

The sb_init file contains an implied export/into. command that instructs the compiler to put database files created for source files not explicitly mentioned by an export command in the current working directory. In Figure D-2, the .bd files associated with a.cc and b.cc are placed in the database subdirectory in the source1 directory.

When you include the export command in the sb_init file, an implied import command causes the specified database to be read. Given the configuration in Figure D-2, the database in the sys subdirectory, as well as the database in the source1 directory, is searched each time you issue a query.

As another example, suppose the user included this export command in the sb_init file for source1:


export /project/include into /project/include

As shown in Figure D-3, this places the database files and index file created for files from /project/include in the database subdirectory in the /project/include subdirectory. An implied import command caused the database in /project/include to be read.

Figure D-3 export Example 2

Graphic

The database files are stored in a common subdirectory even though the command located the include file in a nonstandard location. The export command saves disk space if the project includes multiple references from many different directories to the same include file.

replacepath


replacepath from_prefix   to_prefix

This command specifies how to modify path names in the source browsing database.

In general, from-prefix corresponds to the automounter "mount point" (the path name where the automounter actually mounts the file system); and to-prefix corresponds to the automounter "trigger point" (the path name known and used by the developer).

There is considerable flexibility in how an automounter is used; the method can vary from host to host.

Path replacement rules are matched in the order that they are found and matching stops after a replacement is done.

The default replacepath command is used to strip away automounter artifacts:


replacepath /tmp_mnt

When used for this purpose, the command should be given as the mount point as the first argument and the trigger point as the second argument.

automount-prefix


automount-prefix mount_point  trigger_point

The automount-prefix command enables you to browse on a machine other than the one on which you compiled your program. This command is identical to the replacepath command except that automount-prefix path translations occur at compile time and are written into the database.

The automount-prefix command defines which automounter prefixes to remove from the source names stored in the database. The directory under which the automounter mounts the file systems is the mount_point; the trigger_point is the prefix you use to access the exported file system. The default is /.

If the path in the database fails, the path translations from both commands (that is, automount_prefix and replacepath) are used to search for source files while browsing.

At first glance, searching both paths may not seem possible; the browser database that is created when you run the compiler contains the absolute path for each source file. If the absolute path is not uniform across machines, then Sun WorkShop will not be able to display the source files when it responds to a query.

To get around this problem, you can do either of the following:

There is a default automount-prefix command that is used to strip away automounter artifacts:


automount-prefix /tmp_mnt
 /

The default rule is generated only if no automount-prefix commands are specified.

For more information on using the automounter, see the automount(1M) man page.

cleanup-delay

This command limits the time elapsed between rebuilding the index and the associated database garbage collection. The compilers automatically invoke sbcleanup if the limit is exceeded. The default value is 12 hours.