What's wrong with this simple debugging code?
The kint() and ksm() functions output the results in the status messages block.

Make sure in /admin/structure/block the Status messages system block is set to a region.