title: How to dump the entire GDB session to a file, including commands I type and their output?
body: <p>In bash, I can use the <code>script</code> command, which dumps everything that shows on the shell to a file, including:</p>
  
  <ul>
  <li>commands typed</li>
  <li>PS1 line</li>
  <li>stdout and stderr of commands</li>
  </ul>
  
  <p>What is the equivalent in gdb?</p>
  
  <p>I tried to run <code>shell script</code> from inside GDB, but after I hit return, I was in the shell and lost the shell prompt and could not run command any more. Moreover I could not use ctrl+c or ctrl+\ to exit. I needed to force kill the <code>/bin/login tty2</code> to exit.</p>