DNProfiler Sample

Sample Overview

The DNProfiler sample is derived from an "Under The Hood" article by Matt Pietrek on the Microsoft® Developer Network® (MSDN) (msdn.microsoft.com).  The source code was modified to support the Shared Source CLI (SSCLI) by removing the dependency on the registry and adding a new environment variable. 

Information on the Microsoft® .NET Framework profiling APIs is available in the Profiling.doc file in the Microsoft® .NET Framework SDK, in the Tool Developers Guide\docs directory.  Consult the MSDN article for more information on the functionality provided by this sample and the profiling API. 

This sample differs from the code described by the MSDN article in the use of COM and the registry. COM registration is replaced by an environment variable, COR_PROFILER_DLL in profiler_on.bat, that contains the path to the DNProfiler.dll on Microsoft Windows®.

The SSCLI version of the sample also does not support the DN_PROFILER_BREAK option, which causes a break point when the profiler is initialized. To obtain similar functionality, set a breakpoint in CProfilerCallback::Initialize(IUnknown * pICorProfilerInfoUnk) in profilercallback.cpp.

To use this sample on UNIX system-based platforms, create a script that sets the same environment variables found in profiling_on.bat. Set the COR_PROFILER_DLL environment variable to contain the path to the libdnprofiler.so dynamic library file.

Sample Source and Build Output Locations

The sample source is found in sscli\samples\utilities\dnprofiler. 

The source files are:

The build output location is %TARGETCOMPLUS%\samples\utilities\dnprofiler.  The output file is a dynamic library named:

Building the Sample

All samples are built from the buildall script. 

You can also build all the samples by switching to the root of the sample directory, sscli\samples, and typing build -c.

You can build this specific sample by switching to the sample directory and typing build -c.

Running the Sample

These steps require that the Shared Source CLI (SSCLI) be already built and functional.

  1. Run env.bat or source the env.csh or env.sh script files, depending on your platform.
  2. Switch to the %TARGETCOMPLUS%\samples\utilities\dnprofiler directory.
  3. Run the profiling_on.bat batch file to set up the required profiling environment variables.
  4. Use the clix application launcher to run any managed application.
  5. A profiler output file called DNProfiler.out will be created in the %TARGETCOMPLUS% directory. Open this file to read profiling information.
  6. To modify the level of profiling information, edit the profiler_on.bat or profiler_on.sh file to change the DN_PROFILER_MASK environment variable to contain the various flag values in the commented region of the file. For example, to only log class log transitions from managed to unmanaged code:

    set DN_PROFILER_MASK=0x800

  7. To turn profiling off, use the profiling_off.bat. 

The profiler flag values are defined in sscli\palrt\idl\corprof.h.

Issues


Copyright (c) 2002 Microsoft Corporation. All rights reserved.