What is the best way to debug fastcgi scripts?

Do you use Ruby?  Expect?  Or just deal with 'incomplete header' 
messages in the Apache logs?