From 27dec4bb1e8eb4cf067a33d278757bf66c204f1d Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 29 Jul 2015 22:28:50 -0400 Subject: [PATCH] user_debugger: Adjust handling of continue request. - B_DEBUG_MESSAGE_CONTINUE_THREAD now checks if the thread in question is in a suspended state rather than waiting on the debug nub port, and if so, handles resuming it automatically. This allows the continue message to be used on the main thread of a team that was freshly created under debug control without the API user having to be cognizant of the distinction. --- src/system/kernel/debug/user_debugger.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/system/kernel/debug/user_debugger.cpp b/src/system/kernel/debug/user_debugger.cpp index a4eb75ebc3..fabfecd62d 100644 --- a/src/system/kernel/debug/user_debugger.cpp +++ b/src/system/kernel/debug/user_debugger.cpp @@ -1,5 +1,6 @@ /* * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2015, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -1854,6 +1855,18 @@ debug_nub_thread(void *) result = write_port(threadDebugPort, B_DEBUGGED_THREAD_MESSAGE_CONTINUE, &commandMessage, sizeof(commandMessage)); + } else if (result == B_BAD_THREAD_STATE) { + Thread* thread = Thread::GetAndLock(threadID); + if (thread == NULL) + break; + + BReference threadReference(thread, true); + ThreadLocker threadLocker(thread, true); + if (thread->state == B_THREAD_SUSPENDED) { + threadLocker.Unlock(); + resume_thread(threadID); + break; + } } break;