@Override public String getHoverText(Annotation annotation, ITextViewer textViewer, IRegion hoverRegion) { if (!BfDebugModelPresentation.INSTRUCTION_POINTER_ANNOTATION_TYPE.equals(annotation.getType())) { return null; } IAdaptable adaptable = DebugUITools.getDebugContext(); if (adaptable instanceof BfStackFrame) { BfStackFrame stackFrame = (BfStackFrame) adaptable; try { int instructionPointer = stackFrame.getCharStart(); String text = "Instruction Pointer: [<b>" + instructionPointer + "</b>]"; int memoryPointer = stackFrame.getMemoryPointer(); IMemoryBlock memoryBlock = stackFrame.getDebugTarget().getMemoryBlock(memoryPointer, 1); byte value = memoryBlock.getBytes()[0]; text = text + "<br>Memory Value: [<b>0x" + Integer.toHexString(memoryPointer).toUpperCase() + "</b>]=<b>0x" + Integer.toHexString((value & 0xFF)) + "</b>"; return text; } catch (DebugException ex) { DbgActivator.getDefault().logError("Memory Block could not be evaluated", ex); } } return null; }
@Override public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException { if (this.process.getProcessListener().getSuspendedState() != null) { return new BfMemoryBlock(this, this.process.getProcessListener().getSuspendedState(), startAddress, length); } else { return null; } }
@Override public IMemoryBlock getMemoryBlock(final long startAddress, final long length) throws DebugException { // synthetic targets do not support memory block retrieval return null; }
@Override public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException { return null; }
public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException { return null; }
@Override public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException { notSupported("MontoDebugTarget does not support memory block retrieval", null); return null; }
@Override public void memoryBlocksRemoved(IMemoryBlock[] memory) { }
@Override public void memoryBlocksAdded(final IMemoryBlock[] memory) { WorkbenchJob job = new WorkbenchJob("Update Memory View") { private static final long RESCHEDULE_TIME = 200; private static final int MAX_ATTEMPTS = 5; private volatile int attempts = 0; @Override public IStatus runInUIThread(IProgressMonitor monitor) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (page == null) { return Status.OK_STATUS; } try { IMemoryRenderingSite memoryView = null; for (IViewReference ref : page.getViewReferences()) { if (ref.getId().equals(IDebugUIConstants.ID_MEMORY_VIEW)) { memoryView = (IMemoryRenderingSite) ref.getView(true); break; } } if (memoryView == null) { if (attempts < MAX_ATTEMPTS) { //Memory view may still not been opened, try 5 times attempts++; this.schedule(RESCHEDULE_TIME); } else { attempts = 0; } return Status.OK_STATUS; } for (IMemoryBlock mb : memory) { if (mb instanceof BfMemoryBlock && !((BfMemoryBlock) mb).isUserCreated()) { IMemoryRenderingType renderingType = DebugUITools.getMemoryRenderingManager().getPrimaryRenderingType(mb); IMemoryRendering rendering = renderingType.createRendering(); IMemoryRenderingContainer container = memoryView.getContainer(IDebugUIConstants.PLUGIN_ID + ".MemoryView.RenderingViewPane.1"); rendering.init(container, mb); container.addMemoryRendering(rendering); } } } catch (CoreException e) { DbgActivator.getDefault().logError("Updating Memory View failed", e); } this.attempts = 0; return Status.OK_STATUS; } }; job.setUser(false); job.schedule(); }
@Override public void fireSuspendEvent(int detail) { this.stackFrame = new BfStackFrame(getDebugTarget(), this, "Brainfuck Stack Frame"); if (detail == DebugEvent.STEP_END) { this.isStepping = false; this.fireChangeEvent(DebugEvent.CONTENT | DebugEvent.STATE); } else if (detail == DebugEvent.BREAKPOINT) { try { IBreakpointManager bpManager = DebugPlugin.getDefault().getBreakpointManager(); int location = this.getDebugTarget().getProcess().getProcessListener().getInstructionPointer(); List<IBreakpoint> breakpoints = new ArrayList<>(); for (IBreakpoint bp : bpManager.getBreakpoints(getModelIdentifier())) { if (bp instanceof BfBreakpoint && ((BfBreakpoint) bp).getCharStart() == location) { breakpoints.add(bp); } } this.suspendedBreakpoints = breakpoints.toArray(new IBreakpoint[breakpoints.size()]); // this.fireChangeEvent(DebugEvent.CONTENT | DebugEvent.STATE); } catch (CoreException ex) { DbgActivator.getDefault().logError("Breakpoints cannot be found", ex); } } try { IMemoryBlockManager mbManager = DebugPlugin.getDefault().getMemoryBlockManager(); List<IMemoryBlock> memoryBlocks = Arrays.asList(mbManager.getMemoryBlocks(getDebugTarget())); boolean found = false; int length = this.getDebugTarget().getProcess().getProcessListener().getSuspendedState().getDataSize(); for (IMemoryBlock block : memoryBlocks) { if (block.getStartAddress() == 0 && block.getLength() == length) { found = true; break; } } if (!found) { BfMemoryBlock mb = (BfMemoryBlock) this.getDebugTarget().getMemoryBlock(0, length); mb.setUserCreated(false); mb.fireCreationEvent(); mbManager.addMemoryBlocks(new IMemoryBlock[]{mb}); } } catch (DebugException e) { DbgActivator.getDefault().logError("Memory block could not be created", e); } super.fireSuspendEvent(detail); }
public IMemoryBlock getMemoryBlock( long startAddress, long length ) throws DebugException { return null; }
/** * {@inheritDoc} Unused method. * * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long) */ public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException { return null; }