The module database is stored as an ASCII file using the following formatting conventions:
tool cgprof cautious no module modulename module-property module-property module-property ... module modulename ...The first two lines describe the tool being run and must not be modified. They are followed by a single multi-line entry for each module that describes the following module properties.
Instrumenting the module with codediscovery 0:
module GDI32.DLL
path C:\WINNT\SYSTEM32\GDI32.DLL
index 4
etchpath P:\project\ie\GDI32-ETCH.DLL
etchname GDI32-ETCH.DLL
etchmoduletype etch
contextsave 48
codediscovery 0
Patching the module:
module GDI32.DLL
path C:\WINNT\SYSTEM32\GDI32.DLL
index 4
etchpath P:\project\ie\GDI32-PATCH.DLL
etchname GDI32-PATCH.DLL
etchmoduletype patch
contextsave 48
codediscovery 2
Although it is sometimes useful to edit properties for existing
modules by editing modules.bdb, you should never add modules to
a project by editing the modules.bdb file directly.
The recommended method to add modules to modules.bdb is to run
CGInstrument with the module name as the module argument. For
example, to instrument notepad.exe, and then add winmm.dll as an
additional DLL:
This same method applies to applications such as Direct Draw applications
that use multiple executables. For example, to instrument the Direct-Draw
game Monster Truck Madness (mtm.exe) and Direct Draw Help (ddhelp) in such
a way that they use the same instance of ddraw.dll, you would do the following:
Copyright (c) 1997 The University of Washington. All rights reserved.Controlling code discovery
In order to change the codediscovery property for a given module, change the
integer value after the codediscovery property to 0,1 or 2. The example below shows
how to change the module GDI32.dll from codediscovery 2 to codediscovery 0.
The modifications have been highlighted in red.
Instrumenting the module with codediscovery 2:
module GDI32.DLL
path C:\WINNT\SYSTEM32\GDI32.DLL
index 4
etchpath P:\project\ie\GDI32-ETCH.DLL
etchname GDI32-ETCH.DLL
etchmoduletype etch
contextsave 48
codediscovery 2
Changing a module to be patched instead of instrumented
To change a module to be patched, you need to update the following properties:
For each of these properties, change the string "etch" in the property value
to "patch".
The example below shows how to change the module
GDI32.dll from instrumented to patched.
Instrumenting the module:
module GDI32.DLL
path C:\WINNT\SYSTEM32\GDI32.DLL
index 4
etchpath P:\project\ie\GDI32-ETCH.DLL
etchname GDI32-ETCH.DLL
etchmoduletype etch
contextsave 48
codediscovery 2
Adding Modules to modules.bdb
cginstrument notepad.exe
cginstrument winmm.dll
This will cause winmm.dll and all the DLLs it imports to be added to
the module database. If you add winmm.dll by hand, the new DLLs
imported by winmm.dll will not be added to the module database.
This will typically result in a runtime error.
cginstrument mtm.exe
cginstrument ddhelp.exe
By instrumenting both programs in the same directory, you cause them
to share the same module database, allowing the executables to share
the same DLLs.