Slight refactoring. Also, always process all waiting debugger events before any

system watch events, since otherwise there's a potential race where we might
try to process a thread rename before having processed the notification for
that thread's creation.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39867 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2010-12-16 04:48:29 +00:00
parent ba3f23c636
commit 892f944251
2 changed files with 45 additions and 30 deletions

View File

@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2010, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@ -319,9 +320,6 @@ status_t
DebuggerInterface::GetNextDebugEvent(DebugEvent*& _event) DebuggerInterface::GetNextDebugEvent(DebugEvent*& _event)
{ {
while (true) { while (true) {
debug_debugger_message_data message;
int32 messageCode;
object_wait_info infos[2]; object_wait_info infos[2];
infos[0].object = fDebuggerPort; infos[0].object = fDebuggerPort;
infos[0].type = B_OBJECT_TYPE_PORT; infos[0].type = B_OBJECT_TYPE_PORT;
@ -338,35 +336,13 @@ DebuggerInterface::GetNextDebugEvent(DebugEvent*& _event)
return size; return size;
} }
if (infos[1].events & B_EVENT_READ) if (infos[0].events & B_EVENT_READ)
return _GetNextDebuggerEvent(_event);
else if (infos[1].events & B_EVENT_READ)
return _GetNextSystemWatchEvent(_event); return _GetNextSystemWatchEvent(_event);
size = read_port(fDebuggerPort, &messageCode, &message,
sizeof(message));
if (size < 0) {
if (size == B_INTERRUPTED)
continue;
return size;
}
if (message.origin.team != fTeamID)
continue;
bool ignore = false;
status_t error = _CreateDebugEvent(messageCode, message, ignore,
_event);
if (error != B_OK)
return error;
if (ignore) {
if (message.origin.thread >= 0 && message.origin.nub_port >= 0)
continue_thread(message.origin.nub_port, message.origin.thread);
continue;
}
return B_OK;
} }
return B_OK;
} }
@ -759,6 +735,43 @@ DebuggerInterface::_CreateDebugEvent(int32 messageCode,
} }
status_t
DebuggerInterface::_GetNextDebuggerEvent(DebugEvent*& _event)
{
while (true) {
debug_debugger_message_data message;
int32 messageCode;
ssize_t size = read_port(fDebuggerPort, &messageCode, &message,
sizeof(message));
if (size < 0) {
if (size == B_INTERRUPTED)
continue;
return size;
}
if (message.origin.team != fTeamID)
continue;
bool ignore = false;
status_t error = _CreateDebugEvent(messageCode, message, ignore,
_event);
if (error != B_OK)
return error;
if (ignore) {
if (message.origin.thread >= 0 && message.origin.nub_port >= 0)
continue_thread(message.origin.nub_port, message.origin.thread);
continue;
}
return B_OK;
}
return B_OK;
}
status_t status_t
DebuggerInterface::_GetNextSystemWatchEvent(DebugEvent*& _event) DebuggerInterface::_GetNextSystemWatchEvent(DebugEvent*& _event)
{ {

View File

@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2010, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef DEBUGGER_INTERFACE_H #ifndef DEBUGGER_INTERFACE_H
@ -73,6 +74,7 @@ private:
const debug_debugger_message_data& message, const debug_debugger_message_data& message,
bool& _ignore, DebugEvent*& _event); bool& _ignore, DebugEvent*& _event);
status_t _GetNextDebuggerEvent(DebugEvent*& _event);
status_t _GetNextSystemWatchEvent(DebugEvent*& _event); status_t _GetNextSystemWatchEvent(DebugEvent*& _event);
private: private: