【发布时间】:2020-08-12 23:47:21
【问题描述】:
为了迭代原生对象,我可以将其存储在 windbg 变量中,然后对 windbg 中的字段进行linq 查询以过滤有趣的对象。
> dx @$usedSessions = (*((FabricRuntime!std::unordered_map<unsigned __int64,std::shared_ptr<Store::EseLocalStore::EsePoolItem>,std::hash<unsigned __int64>,std::equal_to<unsigned __int64>,std::allocator<std::pair<unsigned __int64 const ,std::shared_ptr<Store::EseLocalStore::EsePoolItem> > > > *)0x1dfff35f1a8))
> dx @$usedSessions.Take(2).Select(s => s.second->session_->sessionId_)
但是dxwindbg 命令对于sos 命令失败:
0:045> dx @$Txs = !dumpheap -live -type System.Fabric.Transaction
Error: Unexpected token at 'System.Fabric.Transaction'
我可以在 windbg 中使用 Linq 迭代托管对象吗?
【问题讨论】:
-
The documentation for
dx说它使用 NatVis,但 NatVis 不适用于托管对象 - 所以这就是原因。 -
@Dai 有没有其他方法可以迭代托管对象、过滤字段和管道多个阶段?