WPP 跟踪期间不支持多行宏
我使用 WPP(预处理器)和 Visual Studio 编译器向基于“Windows 事件跟踪”(ETW) 的用户模式应用程序添加跟踪。
此 MSDN 内容介绍了如何转换现有内容宏以允许从它们内部进行跟踪。那里的例子是CHECK_HR,它获取单个参数(HR),如果它不为0,则生成跟踪。
现在,我发现如果参数是多行,则生成的预处理器函数不起作用,因为WPP 的工作方式。但我找不到任何关于此类问题的参考!
CHECK_HR(DoSomething(a,b,c)); // works
CHECK_HR(DoSomething(a,
b, c)); // don't work
问题是,当预处理器在 File.cpp wpp 第 17 行中遇到宏时,它会生成一个名为 wpp_File_cpp17 的函数,并使用 LINE 从宏中调用它。但对于上述多行宏,__ LINE__ 将是 18,并且会出现错误:
wpp_File_cpp18: unknown function
有人有解决此问题的方法吗?我知道 MSFT 在内部广泛使用 WPP,我想知道他们如何处理这个问题......
I'm adding tracing to a user-mode application based on "Event Tracing for Windows" (ETW) using WPP (a pre-processor) and visual studio compiler.
This MSDN content explains how convert existing macros to allow tracing from within them. The example there is CHECK_HR, which gets a single argument (HR) and generates a trace if it is not 0.
Now, I found that the generated pre-processor function don't work if the argument is multi-line, due to the way WPP works. But I could not find any reference to such a problem!
CHECK_HR(DoSomething(a,b,c)); // works
CHECK_HR(DoSomething(a,
b, c)); // don't work
Problem is that when the macro is encountered by the pre-processor in line 17 of File.cpp wpp it generates a function called something like wpp_File_cpp17 and uses LINE to call it from the macro. But for multi-line macro as above the __ LINE__ will be 18 and one will get an error:
wpp_File_cpp18: unknown function
Does anyone have a work-around for this issue? I know MSFT use WPP extensively internally, I wonder how they handle this...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尝试重现此问题,但没有成功 - 多行 WPP 调用对我有用,因此您收到的错误似乎有点奇怪。您是否以任何方式修改了
CHECK_HR
宏?您可以尝试在调用的每一行末尾添加斜杠:
此外,在您的示例中,您缺少右括号,这会导致 WPP_CALL_blahblah_undefined。但很可能这只是本例中的一个拼写错误。
I tried to reproduce this issue, without success -- multi-line WPP calls work for me, so the error you're getting seems kind of weird. Did you modify the
CHECK_HR
macro in any way?You could try putting slashes at the end of each line of the call:
Also, in your example you're missing a closing parenthesis, this causes WPP_CALL_blahblah_undefined. But most likely that's just a typo in this example.