rem: for (ThreadDebugHandlerMap::iterator it = fThreadDebugHandlers.begin(); it != fThreadDebugHandlers.end(); it = fThreadDebugHandlers.begin()) { _DeleteThreadHandler(it->second);
add: if (fMessageCountSem >= 0) delete_sem(fMessageCountSem);  if (fHandlerThread >= 0 && find_thread(NULL) != fHandlerThread) { status_t result; wait_for_thread(fHandlerThread, &result); }   if (fDebugContext.nub_port >= 0) destroy_debug_context(&fDebugContext);   while (DebugMessage *message = fMessages.Head()) { fMessages.Remove(message); delete message;
context: TeamDebugHandler::~TeamDebugHandler(){	// delete all thread debug handlers.	for (ThreadDebugHandlerMap::iterator it = fThreadDebugHandlers.begin();		 it != fThreadDebugHandlers.end();		 it = fThreadDebugHandlers.begin()) {		_DeleteThreadHandler(it->second);	}}