This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: [PATCH] Fix debugger attach for threads
Christopher Faylor wrote:
On Fri, Oct 31, 2003 at 10:11:46PM +0100, Thomas Pfaff wrote:
This patch allows a debugger to attach when an exception occurs in a
thread other than the mainthread.
I am not happy about the wait in handle_exceptions, but it works on my
machine. I think that a waitloop until the debugger is attached is
cleaner, but there must be a reason why the debbugging loop is
implemented this way.
The intent is for an attached debugger to immediately see the location
that died. If you loop in the try_to_debug code then it is a pain to
figure out exactly where the exception occurred.
I don't understand why this code is needed. Why do threads need to
be suspended and resumed specially?
Because otherwise the debugger does not get enough CPU time until the
debugging counter exceeds the limit and the process terminates before
the debugger is attached.
If you think that suspending and resuming threads is a dangerous thing
than i would at least change the condition to
if (debugging && !being_debugged ())
{
/*
* Give debugger a chance to attach
*/
LONG prio = GetThreadPriority (GetCurrentThread ());
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
Sleep (0);
SetThreadPriority (GetCurrentThread (), prio);
return 0;
}
to loop until the debugger is attached.
Thomas