write_debug_record should dump info recursively; close #1581