WPP Software Tracing

1、如果新建工程时没有使能WPP,则在工程属性中的 Wpp Tracing->General->Run Wpp Tracing->Yes;

Wpp Tracing->File Options->Scan Configuration Data->Trace.h; 然后复制Trace.h文件到工程目录下。

2、打开Trace.h, 修改#define WPP_CONTROL_GUIDS 的定义。需要使用新的GUID,改为工程名,文件名。

#define WPP_CONTROL_GUIDS                                              \
    WPP_DEFINE_CONTROL_GUID(                                           \
        工程名Guid, (xxxxxxxx,xxxx,xxxx,xxxx,xxxxxxxxxxxx),      \
                                                                       \
        WPP_DEFINE_BIT(FILE_NAME1)                                   \
        WPP_DEFINE_BIT(FILE_NAME2)                                   \
        WPP_DEFINE_BIT(FILE_NAME3)                                    \
        WPP_DEFINE_BIT(FILE_NAME4)                                    \
        )

其中新的GUID可以用Tools中的Create GUID 产生,可选不同的格式。

3、在需要打印log的源文件开始处添加头文件等,如 driver.c 文件需要添加#include "Trace.h" 和 #include "driver.tmh" 

#include "driver.h"  //  原来就有

#include "Trace.h"
#include "driver.tmh"

4、在需要打印log的地方使用

FUNC TraceEvents(LEVEL, FLAGS, MSG, ...);

如 TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");

----------------------------------------------------------------------------

https://docs.microsoft.com/zh-tw/windows-hardware/drivers/devtest/wpp-software-tracing

https://docs.microsoft.com/zh-cn/windows-hardware/drivers/devtest/wpp-software-tracing

Use Windows software trace preprocessor (WPP) to trace the operation of a software component (trace provider). A trace provider can be one of the following:

  • A kernel-mode driver.

  • A user-mode driver, application, or dynamic-link library (DLL).

    When should you use WPP software tracing?

    WPP software tracing is primarily intended for debugging code during development. If you want to publish events that can be consumed by applications interested in structured ETW events, in addition to tracing during development, use the following:

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

EmbededCoder

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值