Move the entire debug print loop into DEBUG_WITH_TYPE.

No functionality change.