目前,我可以使用下面的代码使用ClrMD获取堆中存在的所有对象。是否有可能仅获取目标进程中使用的对象集(即,仅获取目标进程的源代码中的对象)。
var types = heap.EnumerateObjectAddresses()
.GroupBy(obj => heap.GetObjectType(obj).Name)
.Select(group => new { Key = group.Key, Count = group.Count() })
.OrderBy(type => type.Count);
foreach (var type in types)
Console.WriteLine("{0} {1}", type.Key, type.Count);
Console.ReadLine();发布于 2017-08-08 14:26:16
据我所知,VS配置文件工具具有在程序运行时收集函数的所有调用者(对象、函数)的功能。这是你想要的吗?
参考资料:
How to list all calls of a function at runtime?
更新:
CLrMD确实具有枚举PDB信息的类。我建议您尝试使用DataTarget类来枚举堆栈帧的参数/局部变量。他们必须将代码添加到DataTarget类中才能做到这一点,因为它目前看起来不支持它。
https://stackoverflow.com/questions/45545367
复制相似问题