0

For iterating over native objects, i can store it in windbg variable and then do linq queries on fields in windbg to filter on intereting objects.

>  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_)

but dx windbg command fails for sos commands:

0:045> dx @$Txs = !dumpheap -live -type System.Fabric.Transaction
Error: Unexpected token at 'System.Fabric.Transaction'

Can i iterate over managed objects using Linq in windbg ?

Ashish Negi
  • 5,193
  • 8
  • 51
  • 95
  • [The documentation for `dx`](https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/dx--display-visualizer-variables-) says it uses NatVis, but NatVis doesn't apply to Managed objects - so that's why. – Dai Apr 29 '20 at 01:04
  • @Dai Is there any other way to iterate over managed objects, filter on fields and pipe multiple stages ? – Ashish Negi Apr 29 '20 at 01:57

1 Answers1

1

If you don't like the WinDbg .foreach loop in conjuntion with !dumpheap -short, the closest I can think of is the NetExt WinDbg Extension.

It can be used like

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

Source: Example of NetExt documentation

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222