backporting dump-state exposure from the master branch