Added nice debugging patch from Jeremy

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21863 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2005-10-23 15:11:19 +00:00
parent bffdc3c8e7
commit 97eb32b7f1
2 changed files with 43 additions and 1 deletions

View file

@ -365,6 +365,13 @@ _NSAddHandler (NSHandler* handler)
NSThread *thread;
thread = GSCurrentThread();
#if defined(__WIN32__) && defined(DEBUG)
if (thread->_exception_handler
&& IsBadReadPtr(thread->_exception_handler, sizeof(NSHandler)))
{
NSLog(@"ERROR: Current exception handler is bogus.");
}
#endif
handler->next = thread->_exception_handler;
thread->_exception_handler = handler;
}
@ -375,5 +382,28 @@ _NSRemoveHandler (NSHandler* handler)
NSThread *thread;
thread = GSCurrentThread();
thread->_exception_handler = thread->_exception_handler->next;
#if defined(DEBUG)
if (thread->_exception_handler != handler)
{
NSLog(@"ERROR: Removing exception handler that is not on the top "
@"of the stack. (You probably called return in an NS_DURING block.)");
}
#if defined(__WIN32__)
if (IsBadReadPtr(handler, sizeof(NSHandler)))
{
NSLog(@"ERROR: Could not remove exception handler, "
@"handler is bad pointer.");
thread->_exception_handler = 0;
return;
}
if (handler->next && IsBadReadPtr(handler->next, sizeof(NSHandler)))
{
NSLog(@"ERROR: Could not restore exception handler, "
@"handler->next is bad pointer.");
thread->_exception_handler = 0;
return;
}
#endif
#endif
thread->_exception_handler = handler->next;
}