Fix bug that made debugger thread hang after reconnecting twice

This commit is contained in:
Yannik Marchand 2018-09-25 09:31:19 +02:00
parent 90cf855667
commit b85459eaec
3 changed files with 16 additions and 6 deletions

13
main.py
View File

@ -141,7 +141,6 @@ class Debugger:
self.s.settimeout(4)
self.s.connect((host, 1560))
self.connected = True
self.closeRequest = False
events.Connected.emit()
def handleClose(self):
@ -272,12 +271,16 @@ class Debugger:
self.sendall(bytes([byte]))
def sendall(self, data):
try:
self.s.sendall(data)
except socket.error:
self.handleClose()
if self.connected:
try:
self.s.sendall(data)
except socket.error:
self.handleClose()
def recvall(self, num):
if not self.connected:
return bytes(num)
try:
data = b""
while len(data) < num:

View File

@ -306,7 +306,9 @@ void ExceptionMgr::cleanup() {
for (int i = 0; i < list.size(); i++) {
ExceptionState *state = list[i];
OSSendMessage(&state->queue, &message, OS_MESSAGE_FLAGS_BLOCKING);
if (state->isPaused) {
OSSendMessage(&state->queue, &message, OS_MESSAGE_FLAGS_NONE);
}
}
unlock();
@ -331,6 +333,7 @@ ExceptionState *ExceptionMgr::findOrCreate(OSThread *thread) {
if (!state) {
state = new ExceptionState();
state->thread = thread;
state->isPaused = false;
OSInitMessageQueue(&state->queue, &state->message, 1);
list.push_back(state);
}
@ -512,7 +515,9 @@ Debugger::StepCommand Debugger::notifyBreak(ExceptionState *state) {
message.args[2] = (uint32_t)state->thread;
OSSendMessage(&eventQueue, &message, OS_MESSAGE_FLAGS_BLOCKING);
state->isPaused = true;
OSReceiveMessage(&state->queue, &message, OS_MESSAGE_FLAGS_BLOCKING);
state->isPaused = false;
return (StepCommand)message.message;
}

View File

@ -48,6 +48,8 @@ public:
OSMessageQueue queue;
OSMessage message;
bool isPaused;
};