This allows a request to specify that any gdb exception raised in
exec_and_log within the gdb thread to be propagated back to the DAP
thread (using the Canceller object as the orchestrator).
Approved-By: Tom Tromey <tom@tromey.com>
@in_gdb_thread
-def exec_and_expect_stop(cmd, expected_pause=False):
+def exec_and_expect_stop(cmd, expected_pause=False, propagate_exception=False):
"""A wrapper for exec_and_log that sets the continue-suppression flag.
When EXPECTED_PAUSE is True, a stop that looks like a pause (e.g.,
# continuing.
_suppress_cont = not expected_pause
# FIXME if the call fails should we clear _suppress_cont?
- exec_and_log(cmd)
+ exec_and_log(cmd, propagate_exception)
# Map from gdb stop reasons to DAP stop reasons. Some of these can't
@in_gdb_thread
-def exec_and_log(cmd):
+def exec_and_log(cmd, propagate_exception=False):
"""Execute the gdb command CMD.
If logging is enabled, log the command and its output."""
log("+++ " + cmd)
output = gdb.execute(cmd, from_tty=True, to_string=True)
if output != "":
log(">>> " + output)
- except gdb.error:
- log_stack()
+ except gdb.error as e:
+ if propagate_exception:
+ raise DAPException(str(e)) from e
+ else:
+ log_stack()