It sounds as if diotalevi's Enbugger module does just that.
In reply to Re^3: dropping to the debugger from script? by Corion in thread dropping to the debugger from script? by Alien