I need some help fixing a WPP compiler error - specifically that the trace function is not found. I’ve been following every bit of guidance I can find (osr, MDSN, NTDev) and can’t seem to find the secret sauce. While I’ve been able get basic WPP working in a kernel driver, I’m now trying to add it to a static kernel library. I was trying to follow this MSDN page:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff546863(v=vs.85).aspx
But that didn’t seem to help with the compiler error. Also, for the project I’m working on, it’s a large codebase and trying to include the libraries GUID and other info in a shared spot like the 2nd part of that MSDN page somewhat implies gets complicated.
Therefore I figured I would just try to get the static library to have it’s own (basic case) and then get fancy. I’m hoping someone with more WPP experience could spot where I went sideways. I’ve tried to make the relevant code generic enough to post here. I’m targeting the Win8 DDK - therefore MSBuild project vs some of the old sources/dirs. I’ve got my run_wpp to point at wpptrace.h and that’s about it. I cut/copied most of the settings from a known-working driver WPP implementation, but no dice.
Any help is appreciated.
---------------WPPTrace.h ---------
#pragma once
#define INITGUID
#include <evntrace.h> // Needed for WPP TRACE level defines
#include <initguid.h>
// defined values use to send WPP traces directly to DbgPrint
#define MODULE_NAME mySvcLib
#define MODULE_NAME_STRING “mySvcLib”
// In order to send trace statements directly to the kernel
// debugger, the following two #defines are required. It is
// recommended to always include these.
//
#define WPP_AUTOLOGGER L"mySvcLib"
#define WPP_GLOBALLOGGER
//
// Define the tracing flags.
//
//
#define WPP_CONTROL_GUIDS <br> WPP_DEFINE_CONTROL_GUID( <br> MYSvcLibTraceGuid, (221E9D14, DF58, 402D, B9AB, F903D27FF575), <br> <br> WPP_DEFINE_BIT(MY_DBG_ERR) <br> WPP_DEFINE_BIT(MY_DBG_WARN) <br> WPP_DEFINE_BIT(MY_DBG_INFO) <br> WPP_DEFINE_BIT(MY_DBG_EVENT) <br> )
//
// To use levels and flag bits together to control tracing, the
// following two #defines are required. By default, WPP tracing
// only uses the flag bits defined with the control GUID
//
#define WPP_LEVEL_FLAG_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)
#define WPP_LEVEL_FLAG_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_##flags).Level >= lvl)
// *********************************************************
//
// This comment block is scanned by the trace preprocessor to define our
// Trace function.
//
// MACRO: TraceEvents
//
// begin_wpp config
// USEPREFIX (TraceEvents,“%!STDPREFIX!”);
// FUNC TraceEvents(LVL,FLG,MSG,…);
// end_wpp
//
#define WPP_LVL_FLG_PRE(LVL, FLG)
#define WPP_LVL_FLG_POST(LVL, FLG)
#define WPP_LVL_FLG_ENABLED(LVL, FLG) WPP_LEVEL_FLAG_ENABLED(LVL,FLG)
#define WPP_LVL_FLG_LOGGER(LVL, FLG) WPP_LEVEL_FLAG_LOGGER(LVL,FLG)
//
// To handle NULL strings in trace arguements
//
#define WPP_CHECK_FOR_NULL_STRING
------ common_logging.h --------------------------------------
#pragma once
#include <ntddk.h>
#include <stdarg.h>
#include <evntrace.h> // Needed for WPP TRACE level defines
#include “wpptrace.h”
extern int MY_verbosity;
extern int MY_printk_level;
#define ERR 0x00000001
#define WARNING 0x00000002
#define INFO 0x00000004
#define DEBUG 0x00000008
INLINE void MY_vprintk(ULONG type, const char *fmt, va_list args)
{
{
TraceEvents(type,fmt,args);
}
}
---------------------- mylib.c ------------------
#include “wpptrace.h”
#include “mylib.tmh” // For WPP and ETW tracing
< more includes>
#include “common_logging.h”
----- error message ---------
1>common_logging.h(70): error C4013: ‘WPP_CALL_mylib_c70’ undefined; assuming extern returning int</evntrace.h></stdarg.h></ntddk.h></initguid.h></evntrace.h>