Expose owned C breakpoints through shared MCP session
This commit is contained in:
@@ -77,6 +77,9 @@ class McpSession:
|
||||
def screenshot(self):
|
||||
return self.call('screenshot')
|
||||
|
||||
def list_breakpoints(self):
|
||||
return self.call('list_breakpoints')
|
||||
|
||||
def press_key(self, key: str, frames: int = 3):
|
||||
"""Один физический PC-key с отпусканием даже при stop/ошибке."""
|
||||
from mame_interactive import SHIFT_KEY, resolve
|
||||
|
||||
@@ -61,6 +61,7 @@ class SessionController:
|
||||
'kind': 'log', 'message': macro['message'],
|
||||
'condition': macro['condition'], 'module': macro['module'],
|
||||
'tag': macro['tag'], 'locations': item['locations'], 'hits': 0,
|
||||
'owner': 'build', 'guard_conditions': item['conditions'],
|
||||
}
|
||||
if created:
|
||||
self.session.activate_breakpoints()
|
||||
@@ -233,6 +234,21 @@ class SessionController:
|
||||
'event_sequence': self.sequence, 'session_id': self.session_id,
|
||||
'control_owner': self.control_owner if
|
||||
self.control_deadline > time.monotonic() else None}
|
||||
if method == 'list_breakpoints':
|
||||
breakpoints = []
|
||||
for identifier, info in sorted(self.breakpoint_info.items()):
|
||||
guards = info.get('guard_conditions', [])
|
||||
locations = []
|
||||
for index, location in enumerate(info['locations']):
|
||||
locations.append({**location,
|
||||
'bank_guard': guards[index] if index < len(guards)
|
||||
else ''})
|
||||
breakpoints.append({'id': identifier,
|
||||
'owner': info.get('owner', 'dap'),
|
||||
'kind': info['kind'], 'hits': info['hits'],
|
||||
'locations': locations,
|
||||
'tag': info.get('tag')})
|
||||
return {'breakpoints': breakpoints}
|
||||
if method == 'snapshot':
|
||||
return self.session.bridge.request('snapshot')
|
||||
if method == 'mame_console_tail':
|
||||
@@ -322,7 +338,8 @@ class SessionController:
|
||||
item = self.session.break_line(arguments['file'], int(arguments['line']))
|
||||
self.breakpoint_info[item['id']] = {
|
||||
'kind': 'stop', 'message': None, 'locations': item['locations'],
|
||||
'hits': 0, 'owner': owner}
|
||||
'hits': 0, 'owner': owner,
|
||||
'guard_conditions': item['conditions']}
|
||||
return item
|
||||
if method == 'break_function':
|
||||
owner = self._owner(arguments)
|
||||
@@ -330,7 +347,8 @@ class SessionController:
|
||||
item = self.session.break_function(arguments['name'])
|
||||
self.breakpoint_info[item['id']] = {
|
||||
'kind': 'stop', 'message': None, 'locations': item['locations'],
|
||||
'hits': 0, 'owner': owner}
|
||||
'hits': 0, 'owner': owner,
|
||||
'guard_conditions': item['conditions']}
|
||||
return item
|
||||
if method == 'clear_breakpoint':
|
||||
identifier = int(arguments['id'])
|
||||
@@ -480,6 +498,7 @@ class SessionController:
|
||||
self.breakpoint_info[item['id']] = {
|
||||
'kind': kind, 'message': specification['logMessage'],
|
||||
'locations': item['locations'], 'hits': 0,
|
||||
'owner': 'dap', 'guard_conditions': item['conditions'],
|
||||
}
|
||||
results.append({'line': line, 'verified': True,
|
||||
'logMessage': specification['logMessage'], **item})
|
||||
@@ -513,7 +532,9 @@ class SessionController:
|
||||
item = self.session.break_function(name, enabled=False)
|
||||
created.append(item['id'])
|
||||
self.breakpoint_info[item['id']] = {
|
||||
'kind': 'stop', 'message': None, 'locations': item['locations'], 'hits': 0}
|
||||
'kind': 'stop', 'message': None, 'locations': item['locations'],
|
||||
'hits': 0, 'owner': 'dap',
|
||||
'guard_conditions': item['conditions']}
|
||||
results.append({'name': name, 'verified': True, **item})
|
||||
except BaseException:
|
||||
for identifier in created:
|
||||
|
||||
@@ -143,6 +143,11 @@ def make_server(client: McpSession | ManagedMcpSession,
|
||||
"""Поставить личную точку по имени C-функции."""
|
||||
return client.break_function(name)
|
||||
|
||||
@tool(annotations=reading)
|
||||
def list_breakpoints() -> dict[str, Any]:
|
||||
"""Читать C-точки всех владельцев с логическими ID и условиями банка."""
|
||||
return client.list_breakpoints()
|
||||
|
||||
@tool()
|
||||
def clear_breakpoint(identifier: int) -> dict[str, Any]:
|
||||
"""Удалить свою логическую точку по ID; чужие точки отклоняются."""
|
||||
|
||||
Reference in New Issue
Block a user