gpt4 book ai didi

c++ - 添加计数器时 Perflib 2 崩溃(来自 Perfmon)

转载 作者:太空宇宙 更新时间:2023-11-04 12:22:04 25 4
gpt4 key购买 nike

我有一个 C++ 应用程序(在 Win32 下),我需要为其提供性能计数器信息。我使用的是 Perflib v2,因此创建了一个由 CTRPP 处理的 list 。

然后我的提供者调用 PerfAutoInitialize 和 PerfCreateInstance 没有错误。

当我在 Perfmon 中添加计数器时,我的应用程序崩溃了。通过反汇编进行跟踪显示调用内部函数 (pcwum.dll) PerfpAddOrRemoveCounter 的 perflib 工作线程中的代码。这将调用 PerfpValidateCounter,它返回 edi 中的地址;此地址无效,当调用者取消引用它时,应用程序崩溃。

如果我重新启动我的提供程序,计数器在 Perfmon 中仍然可见并且正确递增。

list 如下

<instrumentationManifest xsi:schemaLocation="http://schemas.microsoft.com/win/2004/08/events eventman.xsd"
xmlns:win="http://manifests.microsoft.com/win/2004/08/windows/events"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:trace="http://schemas.microsoft.com/win/2004/08/events/trace">
<instrumentation>
<counters xmlns="http://schemas.microsoft.com/win/2005/12/counters">
<provider callback = "custom"
applicationIdentity = "TPerfStatsCollector.exe"
providerName = "TPerfstatscollector"
providerType = "userMode"
providerGuid = "{33d68436-4cf9-4f58-9976-44b048b072f3}"
symbol = "symbolGUID">
<counterSet guid = "{381300a5-3be6-46d8-8615-12d8b259aae4}"
uri = "A.AxPServer.Counters.Basic"
name = "Basic counters"
description = "These are the sample counters"
instances = "Single"
symbol = "setGUID">
<counter id = "1"
uri = "A.AxPServer.Counters.Basic.Session"
name = "Sessions"
description = "Number of sessions"
type = "perf_counter_rawcount"
detailLevel = "standard"
defaultScale = "1">
</counter>
</counterSet>
</provider>
</counters>
</instrumentation>
</instrumentationManifest>

最佳答案

我的错。这是一个 64/32 位问题,我意识到我正在构建一个 32 位提供程序以在 64 位操作系统上运行。解决这个问题后一切正常。

关于c++ - 添加计数器时 Perflib 2 崩溃(来自 Perfmon),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4431372/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com