This is a refactoring to allow reusing pieces and also to let the code
document itself better. Currently the reuse opportunity exists in the
downstream debugger.
Approved-By: Simon Marchi <simon.marchi@efficios.com> Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)