Support bounded machine instruction step counts in MCP
This commit is contained in:
@@ -163,8 +163,10 @@ function exports.startplugin()
|
||||
state="running"
|
||||
event("running",{reason=command})
|
||||
if command=="step" then
|
||||
local count=number(args.count or 1,64)
|
||||
assert(count>=1,"step count должен быть 1..64")
|
||||
pending={kind="step",time=now()}
|
||||
cpu().debug:step(1)
|
||||
cpu().debug:step(count)
|
||||
elseif command=="step_over" then
|
||||
pending={kind="step_over",time=now()}
|
||||
machine().debugger:command("over 1")
|
||||
|
||||
@@ -201,8 +201,10 @@ class McpSession:
|
||||
def pause_execution(self):
|
||||
return self.call('pause', {'owner': self.owner})
|
||||
|
||||
def step_instruction(self):
|
||||
return self.call('step', {'owner': self.owner})
|
||||
def step_instruction(self, count: int = 1):
|
||||
if not isinstance(count, int) or isinstance(count, bool) or count < 1 or count > 64:
|
||||
raise SessionError('Число машинных шагов должно быть 1..64')
|
||||
return self.call('step', {'count': count, 'owner': self.owner})
|
||||
|
||||
def step_source(self, kind: str = 'into'):
|
||||
if kind not in ('into', 'over', 'out'):
|
||||
|
||||
@@ -406,8 +406,11 @@ class SessionController:
|
||||
if method == 'step':
|
||||
if self.running:
|
||||
raise SessionError('CPU уже выполняется; сначала Pause')
|
||||
count = arguments.get('count', 1)
|
||||
if type(count) is not int or count < 1 or count > 64:
|
||||
raise SessionError('Число машинных шагов должно быть 1..64')
|
||||
self._control(arguments)
|
||||
self.session.bridge.request('step')
|
||||
self.session.bridge.request('step', count=count)
|
||||
self.running = True
|
||||
self._emit('continued', {'reason': 'step'})
|
||||
location = self.session.where(self.session.bridge.wait_stopped())
|
||||
|
||||
@@ -189,9 +189,9 @@ def make_server(client: McpSession | ManagedMcpSession,
|
||||
return client.pause_execution()
|
||||
|
||||
@tool()
|
||||
def step_instruction() -> dict[str, Any]:
|
||||
"""Выполнить одну машинную инструкцию Z80 и вернуть текущую позицию."""
|
||||
return client.step_instruction()
|
||||
def step_instruction(count: int = 1) -> dict[str, Any]:
|
||||
"""Выполнить 1..64 машинных инструкций Z80 и вернуть текущую позицию."""
|
||||
return client.step_instruction(count)
|
||||
|
||||
@tool()
|
||||
def step_source(kind: str = 'into') -> dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user