org.eclipse.debug.core.model.IStackFrame Java Examples
The following examples show how to use
org.eclipse.debug.core.model.IStackFrame.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DebugPluginListener.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public void handleDebugEvents(DebugEvent[] events) { for (DebugEvent event : events) { Object source = event.getSource(); if (source instanceof IJavaThread) synchronized (this) { lastThread = (IJavaThread) source; } else if (source instanceof IStackFrame) synchronized (this) { lastFrame = (IStackFrame) source; } else if (source instanceof IDebugTarget) synchronized (this) { if (event.getKind() == DebugEvent.TERMINATE) { if (lastThread != null && lastThread.getDebugTarget() == source) lastThread = null; if (lastFrame != null && lastFrame.getDebugTarget() == source) lastFrame = null; } } } }
Example #2
Source File: IgnoreCaughtExceptionCommandHandler.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; Object elem = structuredSelection.getFirstElement(); if (elem instanceof IAdaptable) { IAdaptable iAdaptable = (IAdaptable) elem; elem = iAdaptable.getAdapter(IStackFrame.class); } if (elem instanceof PyStackFrame) { try { PyStackFrame pyStackFrame = (PyStackFrame) elem; IPath path = pyStackFrame.getPath(); int lineNumber = pyStackFrame.getLineNumber(); PyExceptionBreakPointManager.getInstance().ignoreCaughtExceptionsWhenThrownFrom .addIgnoreThrownExceptionIn(path.toFile(), lineNumber); } catch (DebugException e) { Log.log(e); } } } return null; }
Example #3
Source File: CaughtException.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public CaughtException(String currentFrameId, String excType, String msg, StoppedStack threadNstack) { this.currentFrameId = currentFrameId; this.excType = StringEscapeUtils.unescapeXml(excType); this.msg = StringEscapeUtils.unescapeXml(msg); this.threadNstack = threadNstack; IStackFrame[] stack = threadNstack.stack; for (IStackFrame iStackFrame : stack) { if (iStackFrame instanceof PyStackFrame) { PyStackFrame f = (PyStackFrame) iStackFrame; if (currentFrameId.equals(f.getId())) { f.setCurrentStackFrame(); break; } } } }
Example #4
Source File: DebugPluginListener.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public String findXtextSourceFileNameForClassFile(String simpleFileName) { if (!simpleFileName.endsWith(".class")) return null; String typename = simpleFileName.substring(0, simpleFileName.length() - ".class".length()); synchronized (this) { try { List<IStackFrame> frames = Lists.newArrayList(); if (lastFrame != null) frames.add(lastFrame); if (lastThread != null) frames.addAll(Lists.newArrayList(lastThread.getStackFrames())); for (IStackFrame frame : frames) if (frame instanceof IJavaStackFrame) { IJavaStackFrame jsf = (IJavaStackFrame) frame; String simpleName = Strings.lastToken(jsf.getDeclaringTypeName(), "."); if (simpleName.equals(typename)) return jsf.getSourceName(); } } catch (DebugException e) { log.error(e.getMessage(), e); } return null; } }
Example #5
Source File: ScriptDebugThread.java From birt with Eclipse Public License 1.0 | 5 votes |
public IStackFrame[] getStackFrames( ) throws DebugException { IStackFrame[] retValue; if ( isSuspended( ) ) { retValue = ( (ScriptDebugTarget) getDebugTarget( ) ).getStackFrames( ); } else { retValue = new IStackFrame[0]; } return retValue; }
Example #6
Source File: ScriptDebugThread.java From birt with Eclipse Public License 1.0 | 5 votes |
public IStackFrame getTopStackFrame( ) throws DebugException { IStackFrame[] frames = getStackFrames( ); if ( frames.length > 0 ) { return frames[0]; } return null; }
Example #7
Source File: ScriptDebugTarget.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Gets the stack frames. * * @return * @throws DebugException */ protected IStackFrame[] getStackFrames( ) throws DebugException { VMStackFrame[] frames; try { frames = reportVM.getStackFrames( ); int len = frames.length; IStackFrame[] retValue = new IStackFrame[len]; for ( int i = len - 1; i >= 0; i-- ) { VMStackFrame frame = frames[i]; // may be need to init the variable ScriptStackFrame debugStack = new ScriptStackFrame( thread, frame.getName( ), i ); debugStack.setLineNumber( frame.getLineNumber( ) ); retValue[len - i - 1] = debugStack; } return retValue; } catch ( VMException e ) { logger.warning( e.getMessage( ) ); } return null; }
Example #8
Source File: CurrentExceptionView.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public void createPartControl(Composite parent) { super.createPartControl(parent); viewer.addDoubleClickListener(new IDoubleClickListener() { /** * When double-clicking show the location that has thrown the exception (or the stack frame clicked). */ @Override public void doubleClick(DoubleClickEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object context = structuredSelection.getFirstElement(); if (context instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) context; IStackFrame frame = (IStackFrame) adaptable.getAdapter(IStackFrame.class); if (frame != null) { ISourceDisplay adapter = (ISourceDisplay) frame.getAdapter(ISourceDisplay.class); if (adapter != null) { IWorkbenchPage activePage = UIUtils.getActivePage(); if (activePage != null) { adapter.displaySource(frame, activePage, false); } } } } } } }); }
Example #9
Source File: CaughtException.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> adapter) { if (adapter == IStackFrame.class) { IStackFrame[] stack = this.threadNstack.stack; if (stack != null && stack.length > 0) { return (T) stack[0]; } } return null; }
Example #10
Source File: PyThread.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * If a thread is entering a suspended state, pass in the stack */ public void setSuspended(boolean state, IStackFrame[] stack) { isSuspended = state; if (stack != null) { // Only save the stack when it's paused (otherwise, it should be null, but we // don't want to reset it because we want to reuse the stack later on so that // the expanded state in the tree is properly kept). this.stack = stack; } }
Example #11
Source File: PyThread.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public IStackFrame[] getStackFrames() throws DebugException { if (isSuspended && stack != null) { return stack; } return new IStackFrame[0]; }
Example #12
Source File: JdtEvaluationProvider.java From java-debug with Eclipse Public License 1.0 | 5 votes |
private JDIStackFrame createStackFrame(JDIThread thread, int depth) { try { IStackFrame[] jdiStackFrames = thread.getStackFrames(); return jdiStackFrames.length > depth ? (JDIStackFrame) jdiStackFrames[depth] : null; } catch (DebugException e) { return null; } }
Example #13
Source File: XMLUtils.java From Pydev with Eclipse Public License 1.0 | 4 votes |
public StoppedStack(PyThread thread, String stopReason, IStackFrame[] stack) { this.thread = thread; this.stopReason = stopReason; this.stack = stack; }
Example #14
Source File: AbstractDebugTarget.java From Pydev with Eclipse Public License 1.0 | 4 votes |
private void processThreadSuspended(String payload) { StoppedStack threadNstack; try { threadNstack = XMLUtils.XMLToStack(this, payload); } catch (CoreException e) { PydevDebugPlugin.errorDialog("Error reading ThreadSuspended", e); return; } PyThread t = threadNstack.thread; int reason = DebugEvent.UNSPECIFIED; String stopReason = threadNstack.stopReason; if (stopReason != null) { int stopReason_i = Integer.parseInt(stopReason); if (stopReason_i == AbstractDebuggerCommand.CMD_STEP_OVER || stopReason_i == AbstractDebuggerCommand.CMD_STEP_INTO || stopReason_i == AbstractDebuggerCommand.CMD_STEP_CAUGHT_EXCEPTION || stopReason_i == AbstractDebuggerCommand.CMD_STEP_RETURN || stopReason_i == AbstractDebuggerCommand.CMD_RUN_TO_LINE || stopReason_i == AbstractDebuggerCommand.CMD_SET_NEXT_STATEMENT) { //Code which could be used to know where a caught exception broke the debugger. //if (stopReason_i == AbstractDebuggerCommand.CMD_STEP_CAUGHT_EXCEPTION) { // System.out.println("Stopped: caught exception"); // IStackFrame stackFrame[] = (IStackFrame[]) threadNstack[2]; // if (stackFrame.length > 0) { // IStackFrame currStack = stackFrame[0]; // if (currStack instanceof PyStackFrame) { // PyStackFrame pyStackFrame = (PyStackFrame) currStack; // try { // System.out.println(pyStackFrame.getPath() + " " + pyStackFrame.getLineNumber()); // } catch (DebugException e) { // Log.log(e); // } // } // } // //} reason = DebugEvent.STEP_END; } else if (stopReason_i == AbstractDebuggerCommand.CMD_THREAD_SUSPEND) { reason = DebugEvent.CLIENT_REQUEST; } else if (stopReason_i == AbstractDebuggerCommand.CMD_SET_BREAK) { reason = DebugEvent.BREAKPOINT; } else if (stopReason_i == AbstractDebuggerCommand.CMD_ADD_EXCEPTION_BREAK) { reason = DebugEvent.BREAKPOINT; // exception breakpoint } else { PydevDebugPlugin.log(IStatus.ERROR, "Unexpected reason for suspension: " + stopReason_i, null); reason = DebugEvent.UNSPECIFIED; } } if (t != null) { IStackFrame stackFrame[] = threadNstack.stack; t.setSuspended(true, stackFrame); fireEvent(new DebugEvent(t, DebugEvent.SUSPEND, reason)); } }
Example #15
Source File: PySourceLocator.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public Object getSourceElement(IStackFrame stackFrame) { return stackFrame; }
Example #16
Source File: PyThread.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public IStackFrame getTopStackFrame() { return (stack == null || stack.length == 0) ? null : stack[0]; }
Example #17
Source File: PyDebugTargetConsole.java From Pydev with Eclipse Public License 1.0 | 4 votes |
private IStackFrame[] createFrames() { PyStackFrameConsole frame = new PyStackFrameConsole(virtualConsoleThread, this); return new IStackFrame[] { frame }; }
Example #18
Source File: DebuggerTestWorkbench.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public void run() { try { currentStep = "launchEditorInDebug"; //make a launch for debugging debuggerTestUtils.launchEditorInDebug(); //switch to debug perspective, because otherwise, when we hit a breakpoint it'll ask if we want to show it. debuggerTestUtils.switchToPerspective("org.eclipse.debug.ui.DebugPerspective"); PyBreakpointRulerAction createAddBreakPointAction = debuggerTestUtils.createAddBreakPointAction( 1); createAddBreakPointAction.run(); currentStep = "waitForLaunchAvailable"; ILaunch launch = debuggerTestUtils.waitForLaunchAvailable(); PyDebugTarget target = (PyDebugTarget) debuggerTestUtils.waitForDebugTargetAvailable(launch); currentStep = "waitForSuspendedThread"; IThread suspendedThread = debuggerTestUtils.waitForSuspendedThread(target); assertTrue(suspendedThread.getName().startsWith("MainThread")); IStackFrame topStackFrame = suspendedThread.getTopStackFrame(); assertTrue("Was not expecting: " + topStackFrame.getName(), topStackFrame.getName().indexOf("debug_file.py:2") != 0); IVariable[] variables = topStackFrame.getVariables(); HashSet<String> varNames = new HashSet<String>(); for (IVariable variable : variables) { PyVariable var = (PyVariable) variable; varNames.add(var.getName()); } HashSet<String> expected = new HashSet<String>(); expected.add("Globals"); expected.add("__doc__"); expected.add("__file__"); expected.add("__name__"); expected.add("mod1"); assertEquals(expected, varNames); assertTrue(target.canTerminate()); target.terminate(); finished = true; } catch (Throwable e) { debuggerTestUtils.failException = e; } }