Skip to content
Snippets Groups Projects
Commit 3077eac9 authored by Louis-Francis Ratté-Boulianne's avatar Louis-Francis Ratté-Boulianne Committed by Sjoerd Simons
Browse files

Wait for the GDB server to be listening before doing anything else


We were trying to connect the GDB client even before we got the
listening event. The debugger server thread is now looping forever.

Signed-off-by: default avatarLouis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: default avatarSjoerd Simons <sjoerd.simons@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D5327
parent ce494052
No related branches found
No related tags found
No related merge requests found
......@@ -177,19 +177,39 @@ class TargetTriplet:
class DebuggerServerThread(threading.Thread):
def __init__(self, target, port, app, *args):
def __init__(self, cond, target, port, app, *args):
super().__init__()
self.target = target
self.port = port
self.app = app
self.args = args
self._cond = cond
self._exception = None
self._listening = False
def run(self):
self._data = self.target.start_gdbserver(self.port, self.app, *self.args)
try:
self._data = self.target.start_gdbserver(self.port, self.app, *self.args)
with self._cond:
self._listening = True
self._cond.notify()
while True:
pass
except Exception as e:
with self._cond:
self._exception = e
self._cond.notify()
def stop(self):
self.target.stop_gdbserver(self._data)
def is_listening(self):
return self._listening
def get_exception(self):
return self._exception
class DebuggerServer:
......@@ -201,8 +221,14 @@ class DebuggerServer:
self._thread = None
def __enter__(self):
self._thread = DebuggerServerThread(self.target, self.port, self.app, *self.args)
cond = threading.Condition()
self._thread = DebuggerServerThread(cond, self.target, self.port, self.app, *self.args)
self._thread.start()
with cond:
while not self._thread.is_listening() and not self._thread.get_exception():
cond.wait()
if self._thread.get_exception():
raise self._thread.get_exception()
return self
def __exit__(self, et, ev, tb):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment