1 package net.mograsim.plugin.launch;
3 import java.util.ArrayList;
4 import java.util.Collections;
7 import org.eclipse.core.runtime.PlatformObject;
8 import org.eclipse.debug.core.DebugException;
9 import org.eclipse.debug.core.ILaunch;
10 import org.eclipse.debug.core.model.IDebugTarget;
11 import org.eclipse.debug.core.model.IRegisterGroup;
12 import org.eclipse.debug.core.model.IStackFrame;
13 import org.eclipse.debug.core.model.IThread;
14 import org.eclipse.debug.core.model.IVariable;
16 import net.mograsim.machine.Machine;
17 import net.mograsim.machine.MachineDefinition;
18 import net.mograsim.machine.registers.RegisterGroup;
19 import net.mograsim.plugin.MograsimActivator;
21 public class MachineStackFrame extends PlatformObject implements IStackFrame
23 private final MachineThread thread;
24 private final List<MachineRegisterGroup> registerGroups;
26 public MachineStackFrame(MachineThread thread)
29 List<MachineRegisterGroup> registerGroupsModifiable = new ArrayList<>();
30 MachineDefinition machDef = getMachine().getDefinition();
31 if (!machDef.getUnsortedRegisters().isEmpty())
32 registerGroupsModifiable.add(new MachineRegisterGroup(this, "<unsorted>", machDef.getUnsortedRegisters()));
33 addRegisterGroups(null, registerGroupsModifiable, machDef.getRegisterGroups());
34 this.registerGroups = Collections.unmodifiableList(registerGroupsModifiable);
37 private void addRegisterGroups(String base, List<MachineRegisterGroup> target, List<RegisterGroup> registerGroups)
39 for (RegisterGroup rg : registerGroups)
41 String name = (base == null ? "" : base + '.') + rg.id();
42 target.add(new MachineRegisterGroup(this, name, rg.getRegisters()));
43 addRegisterGroups(name, target, rg.getSubGroups());
48 public String getModelIdentifier()
50 return MograsimActivator.PLUGIN_ID;
53 public Machine getMachine()
55 return thread.getMachine();
59 public IDebugTarget getDebugTarget()
61 return thread.getDebugTarget();
65 public ILaunch getLaunch()
67 return thread.getLaunch();
71 public boolean canStepInto()
73 return thread.canStepInto();
77 public boolean canStepOver()
79 return thread.canStepOver();
83 public boolean canStepReturn()
85 return thread.canStepReturn();
89 public boolean isStepping()
91 return thread.isStepping();
95 public void stepInto() throws DebugException
101 public void stepOver() throws DebugException
107 public void stepReturn() throws DebugException
113 public boolean canResume()
115 return thread.canResume();
119 public boolean canSuspend()
121 return thread.canSuspend();
125 public boolean isSuspended()
127 return thread.isSuspended();
131 public void resume() throws DebugException
137 public void suspend() throws DebugException
143 public boolean canTerminate()
145 return thread.canTerminate();
149 public boolean isTerminated()
151 return thread.isTerminated();
155 public void terminate() throws DebugException
161 public IThread getThread()
167 public IVariable[] getVariables() throws DebugException
169 return new IVariable[0];
173 public boolean hasVariables() throws DebugException
179 public int getLineNumber() throws DebugException
181 // TODO could we transmit the active microinstruction address using this?
186 public int getCharStart() throws DebugException
192 public int getCharEnd() throws DebugException
198 public String getName() throws DebugException
200 return "pseudo stack frame";
204 public IRegisterGroup[] getRegisterGroups() throws DebugException
206 return registerGroups.toArray(IRegisterGroup[]::new);
210 public boolean hasRegisterGroups() throws DebugException