这个 CopyPDBs 函数(来自 clr.dll)在做什么?

What is this CopyPDBs function (from clr.dll) doing?

在生产环境 运行 IIS 中使用 Process Explorer 分析 ASP.NET MVC 应用程序时,我注意到 [=13] 对这个 CopyPDBs 函数有很多调用=]:

它们都具有完全相同的堆栈跟踪:

ntdll.dll!ZwWaitForSingleObject+0xa
KERNELBASE.dll!WaitForSingleObjectEx+0x98
clr.dll!GetMetaDataInternalInterface+0x3064a
clr.dll!GetMetaDataInternalInterface+0x30732
clr.dll!GetMetaDataInternalInterface+0x306e5
clr.dll!CopyPDBs+0x44a2
KERNEL32.DLL!BaseThreadInitThunk+0x22
ntdll.dll!RtlUserThreadStart+0x34

我的问题是:clr.dll 中的这个 CopyPDBs 函数究竟在做什么?

我已经搜索了很多,但仍然找不到关于此功能的任何解释 and/or 文档。

注意:这个问题与我之前在 ServerFault 中提出的问题有某种关系:https://serverfault.com/questions/684554/high-cpu-usage-of-iis-process-w3wp-exe-because-of-many-slow-clr-dllcopypdbs

它什么也没做。 Process Explorer 无权访问 clr.dll 的 PDB 文件,因此它对代码的了解不够。当您查看指令与已知符号的偏移量时,总是非常明显,+0x44a2 很长很长,超过了 CopyPDBs() 函数。您从 clr.dll 看到的所有符号都是垃圾。来自 ntdll.dll 的符号很好,请注意小的偏移量。

如果没有为 DLL 中的内部函数提供符号的 PDB 文件,调试器只能依赖导出的函数。 Clr.dll 没有很多。

帮助 Process Explorer 显示更好的堆栈跟踪是 this blog post 的主题。

Windbg 不是唯一的方法,您也可以使用 Visual Studio:

  1. 工具 > 选项 > 调试 > 符号。勾选“微软符号 服务器”复选框和 select 缓存目录。
  2. 项目 > 属性 > 调试 > 勾选 "Enable native code debugging" 选项。
  3. 按 F5,您将看到调试器正在下载符号。需要一段时间,它只发生一次。
  4. 将您通过“选项”>“配置符号”选择的缓存目录告知 Process Explorer。