Skip to content

Commit

Permalink
Fixed issue where commands were not marked async. Updated evaluate co…
Browse files Browse the repository at this point in the history
…mmand to be async.
  • Loading branch information
daveleroy committed Jun 30, 2019
1 parent 3a9692d commit b2dd607
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion modules/debugger/debugger_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def open_repl_console(self) -> None:
input = AutoCompleteTextInputHandler(label)
def run(**args):
expression = args['text']
self.debugger.evaluate(expression)
self.run_async(self.debugger.evaluate(expression))

# just re run the same command right away to avoid flicker
def run_not_main(**args):
Expand Down
48 changes: 21 additions & 27 deletions modules/debugger_stateful/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,29 +288,45 @@ def stop(self) -> core.awaitable[None]:

self.force_stop_adapter()

@core.async
def resume(self) -> core.awaitable[None]:
assert self.adapter, 'no adapter for command'
assert self.adapter, 'debugger not running'
yield from self.adapter.Resume(self._thread_for_command())

@core.async
def pause(self) -> core.awaitable[None]:
assert self.adapter, 'no adapter for command'
assert self.adapter, 'debugger not running'
yield from self.adapter.Pause(self._thread_for_command())

@core.async
def step_over(self) -> core.awaitable[None]:
assert self.adapter, 'no adapter for command'
assert self.adapter, 'debugger not running'
yield from self.adapter.StepOver(self._thread_for_command())
self.selected_frame = None

@core.async
def step_in(self) -> core.awaitable[None]:
assert self.adapter, 'no adapter for command'
assert self.adapter, 'debugger not running'
yield from self.adapter.StepIn(self._thread_for_command())
self.selected_frame = None

@core.async
def step_out(self) -> core.awaitable[None]:
assert self.adapter, 'no adapter for command'
assert self.adapter, 'debugger not running'
yield from self.adapter.StepOut(self._thread_for_command())
self.selected_frame = None

@core.async
def evaluate(self, command: str) -> core.awaitable[None]:
self.log_info(command)
assert self.adapter, 'debugger not running'

adapter = self.adapter

response = yield from adapter.Evaluate(command, self.frame, "repl")
event = OutputEvent("console", response.result, response.variablesReference)
self.on_output(event)

def log_info(self, string: str) -> None:
output = OutputEvent("debugger.info", string, 0)
self.on_output(output)
Expand All @@ -322,28 +338,6 @@ def log_output(self, string: str) -> None:
def log_error(self, string: str) -> None:
output = OutputEvent("debugger.error", string, 0)
self.on_output(output)

def evaluate(self, command: str):
self.log_info(command)

adapter = self.adapter

if not adapter:
self.log_error("Failed to run command: Debugger is not running")
return

@core.async
def run():
try:
response = yield from adapter.Evaluate(command, self.frame, "repl")
except Exception as e:
self.log_error(str(e))
return

event = OutputEvent("console", response.result, response.variablesReference)
self.on_output(event)
core.run(run())


# after a successfull launch/attach, stopped event, thread event we request all threads
# see https://microsoft.github.io/debug-adapter-protocol/overview
Expand Down

0 comments on commit b2dd607

Please sign in to comment.