? suspend_all_on_stop.patch ? thread_try_to_debug.patch Index: exceptions.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/exceptions.cc,v retrieving revision 1.172 diff -u -p -r1.172 exceptions.cc --- exceptions.cc 14 Oct 2003 09:21:55 -0000 1.172 +++ exceptions.cc 31 Oct 2003 20:50:31 -0000 @@ -360,9 +360,7 @@ try_to_debug (bool waitloop) si.dwFlags = 0; si.cb = sizeof (si); - /* FIXME: need to know handles of all running threads to - suspend_all_threads_except (current_thread_id); - */ + pthread::suspend_all_except_self (); /* if any of these mutexes is owned, we will fail to start any cygwin app until trapped app exits */ @@ -400,7 +398,10 @@ try_to_debug (bool waitloop) else { if (!waitloop) - return 1; + { + pthread::resume_all (); + return 1; + } SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE); while (!being_debugged ()) Sleep (0); @@ -409,9 +410,8 @@ try_to_debug (bool waitloop) SetThreadPriority (GetCurrentThread (), prio); } - /* FIXME: need to know handles of all running threads to - resume_all_threads_except (current_thread_id); - */ + pthread::resume_all (); + return 0; } @@ -426,7 +426,15 @@ handle_exceptions (EXCEPTION_RECORD *e, if (debugging && ++debugging < 500000) { - SetThreadPriority (hMainThread, THREAD_PRIORITY_NORMAL); + /* + * Give debugger a chance to attach + */ + LONG prio = GetThreadPriority (GetCurrentThread ()); + pthread::suspend_all_except_self (); + SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE); + Sleep (0); + SetThreadPriority (GetCurrentThread (), prio); + pthread::resume_all (); return 0; }