How can I force a crash report in OSX? My MacBook Pro regularly gets into a state where a very lightly loaded system starts processing very slowly: mouse clicks and button presses take a few minutes to process and a couple of useful things can be done in the space of a couple of hours if I'm attentive.  Note that this happens without fans or any other signal that its running close to its operating limits.
Regardless this is undesirable.  MacOS does not seem to recognize this state as a fault or failure, so I need to manually power off, and hence I don't get the &quot;your system was restarted...&quot; message with a crash report on boot (no bugs to be had in MacOS of course).
I have XCode installed (linux developer making due on MacOS).
How do I force MacOS to dump the state of the running processes and reboot?
Activity Monitor
If you just want a live view of system activity, keep Activity Monitor open and change its Dock icon to CPU to see if cores are busy. You may of course open it and see what is hogging the memory/ disk/ CPU.
You can either enable memory column in CPU tab, or CPU column in memory tab to keep a tab :) on processes.

Last time I had such a slowdown, it was spotlight processes consuming massive memory. I killed it.
Instruments.app
It is bundled with Xcode app which you say you have. It has an instrument called Activity Monitor which will store the information of all processes, network, disk speed for as long as it is run. Activity Monitor app will not store anything.

https://web.archive.org/web/20200620073428/https://help.apple.com/instruments/mac/current/#/devc63117d3
https://en.wikipedia.org/wiki/Instruments_(software)#References

Safe Mode or new user account
Not a logging method, but can help isolate issues with kernel extensions, buggy apps or anything else.

https://support.apple.com/en-us/HT201262#issue