Support setting the breakpoint on the lowest layer

This commit is contained in:
Mike Auty
2025-05-05 13:14:19 +01:00
parent f5ec6dc7dd
commit ae08c8ecfc
+16 -1
View File
@@ -799,7 +799,9 @@ class Volshell(interfaces.plugins.PluginInterface):
return constructed
def breakpoint(self, address: int, layer_name: Optional[str] = None) -> None:
def breakpoint(
self, address: int, layer_name: Optional[str] = None, lowest: bool = False
) -> None:
"""Sets a breakpoint on a particular address (within a specific layer)"""
if layer_name is None:
if self.current_layer is None:
@@ -807,6 +809,18 @@ class Volshell(interfaces.plugins.PluginInterface):
layer_name = self.current_layer
layer: interfaces.layers.DataLayerInterface = self.context.layers[layer_name]
if lowest:
while isinstance(layer, interfaces.layers.TranslationLayerInterface):
mapping = layer.mapping(address, 1)
if not mapping:
raise ValueError(
"Offset cannot be mapped lower, cannot break at lowest layer"
)
_, _, mapped_offset, _, mapped_layer_name = next(mapping)
layer = self.context.layers[mapped_layer_name]
address = mapped_offset
# Check if the read value is already overloaded
if not hasattr(layer.read, "breakpoints"):
# Layer read is not yet wrapped
@@ -825,6 +839,7 @@ class Volshell(interfaces.plugins.PluginInterface):
setattr(layer, "read", wrapped_read)
# Add the new breakpoint
print(f"Setting breakpoint {address:x} on {layer.name}")
breakpoints = getattr(layer.read, "breakpoints")
breakpoints.add(address)
setattr(layer.read, "breakpoints", breakpoints)