Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Driver Kit
 How do I use WPP in static librarie...

  Switch on low bandwidth view
Windows Driver Kit: Driver Development Tools
How do I use WPP in static libraries?

The use of WPP in static libraries will be demonstrated using the sample that can be found in the %sdxroot%\sdktools\trace\wppsamples\staticlib directory.

Notice that, in this sample, both the .lib file and the .exe file have their own control GUID. This allows tracing to be enabled in either the .lib file, the .exe file, or both.

The .lib file can be accessed using WPP at several points, as shown in the following code example. Note that it is not important to define the actual value of the control GUID (marked in bold) because the static library is not calling the WPP_INIT_TRACING macro, which does the actual registration with ETW.

#define WPP_CONTROL_GUIDS \
WPP_DEFINE_CONTROL_GUID(mylib,(0,0,0,0,0), \
WPP_DEFINE_BIT(Error) \
WPP_DEFINE_BIT(Unusual) \
WPP_DEFINE_BIT(Noise) \
)

The .dll, .exe, and .sys files that use the library must call WPP_INIT_TRACING, which will register the provider with WPP. The binary that calls the macro WPP_INIT_TRACING must have a copy of the WPP control GUIDs obtained by the WPP_CONTROL_GUID macro, as well as the flag values obtained in the last three lines of the example by using the WPP_DEFINE_BIT macro.

In the following code sample, the static library's control GUID is declared first and control GUID’s flags match the ones defined in the library:

#define WPP_CONTROL_GUIDS \
WPP_DEFINE_CONTROL_GUID(SharedStaticLibs,(81b20feb,73a8,4b62,95bc,354477c97a6f), \
WPP_DEFINE_BIT(Error) \
WPP_DEFINE_BIT(Unusual) \
WPP_DEFINE_BIT(Noise) \
) \
WPP_DEFINE_CONTROL_GUID(AppSpecificFlags,(81b20fec,73a8,4b62,95bc,354477c97a6f), \
WPP_DEFINE_BIT(EntryExit) \
WPP_DEFINE_BIT(Initialization) \
WPP_DEFINE_BIT(MemoryAllocations) \

 

You can choose the degree of control that you need for tracing on both your component and the static library, by specifying either a separate control GUID for the .lib and the .exe files, each with its own flags, or one control GUID for both. In the sample, the .exe file is using the same flags as the .lib file.

There is one limitation. There can only be one control GUID for the .lib file.


Send feedback on this topic
Built on May 20, 2009
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker