debugger: move loop init out of thread body