slight refactoring of show_backtrace to allow it to be used outside the REPL