WinDbg command to count the overall number of running processes and threads?

I wonder if there’s a WinDbg command just to retrieve the overall number of running processes and the overall number of running threads in the system? I am interested in the count only.

PS. I need this while doing a postmortem debugging with a full memory dump.

Not that I know, but !process 0 1 is fast enough, then just do a search for
“process:” and “thread:” in the Command window. It’s a fast enough
alternative.
Any extension that just counts needs to walk the list as well, so it won’t
be faster, it would remove the manual steps.

Hope I am wrong :slight_smile:

Regards, Dejan.

You can do it with the Debugger Object Model:

0: kd> dx @$cursession.Processes.Count()
@$cursession.Processes.Count() : 0x79
0: kd> dx @$cursession.Processes.Sum(tc => tc.Threads.Count())
@$cursession.Processes.Sum(tc => tc.Threads.Count()) : 0x379

More details/examples in the documentation:

https://learn.microsoft.com/en-us/windows-hardware/drivers/debuggercmds/dx--display-visualizer-variables-

@“Scott_Noone_(OSR)” of wow, that’s pretty cool. Thanks. I wonder if there’s a tutorial on how to use that dx command? The MSDN page is quite terse.

There’s a blog post here with some introductory stuff and links to further reading:

https://www.osr.com/blog/2017/05/18/windbg-debugger-objects-javascript-oh/

And part of the magic here is the NatVis support, which we talked about here:

https://www.osr.com/blog/2015/11/06/fun-windbg-natvis-support/

Not sure of any other tutorials