【问题标题】:Windbg Linq for managed objectsWindbg Linq 用于托管对象
【发布时间】: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 有没有其他方法可以迭代托管对象、过滤字段和管道多个阶段?

标签: c# linq windbg sos


【解决方案1】:

如果你不喜欢 WinDbg .foreach 循环与 !dumpheap -short 的结合,我能想到的最接近的是 NetExt WinDbg Extension

可以这样使用

!wfrom -type *.HttpContext 
  where ( ($contains(_request._url.m_String, "http:")) && (_response._statuscode != 0n200) ) 
  select $addr(), _request._url.m_String, _response._statusCode

来源:NetExt 文档示例

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-08
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多