trace: Several enhancements to dump_state.py