add runtime_stack to record stack and write file.