org.eclipse.debug.core.DebugException Java Examples

The following examples show how to use org.eclipse.debug.core.DebugException. 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: ScriptStackFrame.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public boolean equals( Object obj )
{
	if ( obj instanceof ScriptStackFrame )
	{
		ScriptStackFrame sf = (ScriptStackFrame) obj;
		try
		{
			return sf.getName( ).equals( getName( ) )
					&& sf.getLineNumber( ) == getLineNumber( )
					&& sf.id == id;
		}
		catch ( DebugException e )
		{
			//donothing
		}
	}
	return false;
}
 
Example #2
Source File: FlexMavenPackagedProjectStagingDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Waits until {@code launch} terminates or {@code monitor} is canceled. if the monitor is
 * canceled, attempts to terminate the launch before returning.
 *
 * @return true if the launch terminated normally; false otherwise
 */
@VisibleForTesting
static boolean waitUntilLaunchTerminates(ILaunch launch, IProgressMonitor monitor)
    throws InterruptedException, DebugException {
  while (!launch.isTerminated() && !monitor.isCanceled()) {
    Thread.sleep(100 /*ms*/);
  }

  if (monitor.isCanceled()) {
    launch.terminate();
    return false;
  }
  for (IProcess process : launch.getProcesses()) {
    if (process.getExitValue() != 0) {
      return false;
    }
  }
  return true;
}
 
Example #3
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public String getName( ) throws DebugException
{
	if ( name == null )
	{
		name = getDefaultName( );
		try
		{
			name = getLaunch( ).getLaunchConfiguration( )
					.getAttribute( IScriptConstants.ATTR_REPORT_PROGRAM,
							name );
		}
		catch ( CoreException e )
		{
		}
	}
	return renderState( ) + name;
}
 
Example #4
Source File: DebugPluginListener.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
public void serverChanged(ServerEvent event) {
  Preconditions.checkState(server == event.getServer());
  switch (event.getState()) {
    case IServer.STATE_STARTED:
      openBrowserPage(server);
      fireChangeEvent(DebugEvent.STATE);
      return;

    case IServer.STATE_STOPPED:
      server.removeServerListener(serverEventsListener);
      fireTerminateEvent();
      try {
        logger.fine("Server stopped; terminating launch"); //$NON-NLS-1$
        launch.terminate();
      } catch (DebugException ex) {
        logger.log(Level.WARNING, "Unable to terminate launch", ex); //$NON-NLS-1$
      }
      checkUpdatedDatastoreIndex(launch.getLaunchConfiguration());
      return;

    default:
      fireChangeEvent(DebugEvent.STATE);
      return;
  }
}
 
Example #6
Source File: SwtBotLaunchManagerActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public static void terminateAllLaunchConfigs(SWTBot bot) {
  SwtBotUtils.print("Terminating Launches");

  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunch[] launches = manager.getLaunches();
  if (launches == null || launches.length == 0) {
    SwtBotUtils.print("No Launches to terminate");
  }

  for (ILaunch launch : launches) {
    if (!launch.isTerminated()) {
      try {
        launch.terminate();
      } catch (DebugException e) {
        SwtBotUtils.printError("Could not terminate launch." + e.getMessage());
      }
    }
  }

  SwtBotWorkbenchActions.waitForIdle(bot);

  SwtBotUtils.print("Terminated Launches");
}
 
Example #7
Source File: JavaDebugElementCodeMining.java    From jdt-codemining with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected RGB getRGB(IVariable variable) throws DebugException {
	IJavaValue v = (IJavaValue) variable.getValue();
	if ("org.eclipse.swt.graphics.RGB".equals(v.getJavaType().toString())) {
		Integer red = null, blue = null, green = null;
		for (IVariable field : v.getVariables()) {
			if ("red".equals(field.getName().toString())) {
				red = Integer.parseInt(field.getValue().getValueString());
			} else if ("green".equals(field.getName().toString())) {
				green = Integer.parseInt(field.getValue().getValueString());
			} else if ("blue".equals(field.getName().toString())) {
				blue = Integer.parseInt(field.getValue().getValueString());
			}
		}
		if (red != null && green != null && blue != null) {
			return new RGB(red, green, blue);
		}
	}
	return null;
}
 
Example #8
Source File: ScriptModelPresentation.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Gets the expression display name
 * 
 * @param expression
 * @return
 * @throws DebugException
 */
private String getExpressionText( IExpression expression )
		throws DebugException
{
	StringBuffer buff = new StringBuffer( );
	IValue javaValue = expression.getValue( );

	buff.append( '"' + expression.getExpressionText( ) + '"' );

	if ( javaValue != null )
	{
		String valueString = getValueText( javaValue );
		if ( valueString.length( ) > 0 )
		{
			buff.append( "= " ); //$NON-NLS-1$
			buff.append( valueString );
		}
	}
	return buff.toString( );
}
 
Example #9
Source File: SimulationView.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	Display.getDefault().asyncExec(new Runnable() {

		@Override
		public void run() {
			IDebugTarget[] debugTargets = debugTarget.getLaunch().getDebugTargets();
			for (IDebugTarget current : debugTargets) {
				if (current instanceof IStep) {
					try {
						((IStep) current).stepOver();
					} catch (DebugException e) {
						e.printStackTrace();
					}
				}
			}
		}
	});
}
 
Example #10
Source File: SimulationView.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	Display.getDefault().asyncExec(new Runnable() {

		@Override
		public void run() {
			try {
				IDebugTarget[] debugTargets = debugTarget.getLaunch().getDebugTargets();
				for (IDebugTarget current : debugTargets) {
					current.suspend();
				}
			} catch (DebugException e) {
				e.printStackTrace();
			}
		}
	});
}
 
Example #11
Source File: ScriptDebugThread.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public IStackFrame[] getStackFrames( ) throws DebugException
{
	IStackFrame[] retValue;
	if ( isSuspended( ) )
	{
		retValue = ( (ScriptDebugTarget) getDebugTarget( ) ).getStackFrames( );
	}
	else
	{
		retValue = new IStackFrame[0];
	}
	return retValue;
}
 
Example #12
Source File: VoiceXMLBrowserProcess.java    From JVoiceXML with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void terminate() throws DebugException {
    if (running) {
        if (browser != null) {
            browser.stop();
        }
        running = false;
        DebugEvent[] eventSet = new DebugEvent[2];
        eventSet[0] = new DebugEvent(this, DebugEvent.TERMINATE);
        eventSet[1] = new DebugEvent(launch, DebugEvent.CHANGE);
        DebugPlugin.getDefault().fireDebugEventSet(eventSet);
    }
}
 
Example #13
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void terminate( ) throws DebugException
{
	setTerminating( true );
	try
	{
		// Process the proces is terminated by client directly.
		if ( ( !isTerminated( ) ) && reportVM.isTerminated( ) )
		{
			terminated( );
			return;
		}
	}
	catch ( VMException e1 )
	{
		logger.warning( e1.getMessage( ) );
	}

	try
	{
		reportVM.terminate( );

	}
	catch ( VMException e )
	{
		logger.warning( e.getMessage( ) );
	}
}
 
Example #14
Source File: ScriptDebugThread.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public IStackFrame getTopStackFrame( ) throws DebugException
{
	IStackFrame[] frames = getStackFrames( );
	if ( frames.length > 0 )
	{
		return frames[0];
	}
	return null;
}
 
Example #15
Source File: TerminateLaunchesAction.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
private void terminateLaunch( ILaunch launch ) {
  try {
    if( launch.canTerminate() ) {
      launch.terminate();
    }
  } catch( DebugException e ) {
    status.merge( e.getStatus() );
  }
}
 
Example #16
Source File: LaunchTerminator.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
private static void terminateLaunch( ILaunch launch ) {
  try {
    launch.terminate();
  } catch( DebugException debugException ) {
    StatusManager.getManager().handle( debugException.getStatus(), StatusManager.LOG );
  }
}
 
Example #17
Source File: CloudSdkDebugTargetPresentation.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Override
public String getText(Object element) {
  if (element instanceof IDebugTarget) {
    try {
      IDebugTarget target = (IDebugTarget) element;
      String text = target.getName();
      return target.isTerminated() ? Messages.getString("target.terminated", text) : text;
    } catch (DebugException ex) {
      logger.log(Level.FINE, "Unexpected execption", ex);
      /* FALLTHROUGH */
    }
  }
  return super.getText(element);
}
 
Example #18
Source File: JavaDebugElementCodeMiningASTVisitor.java    From jdt-codemining with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(MethodDeclaration node) {
	try {
		// TODO: improve the comparison of the method which is visited and the debug
		// frame
		inFrame = (node.getName().toString().equals(fFrame.getMethodName()));
	} catch (DebugException e) {
		e.printStackTrace();
	}
	return super.visit(node);
}
 
Example #19
Source File: ScriptDebugThread.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public String getDisplayName( )
{
	try
	{
		return getName( );
	}
	catch ( DebugException e )
	{
		return NAME;
	}
}
 
Example #20
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Step into
 * 
 * @throws DebugException
 */
public void stepInto( ) throws DebugException
{
	try
	{
		thread.setStepping( true );
		reportVM.stepInto( );
	}
	catch ( VMException e )
	{
		logger.warning( e.getMessage( ) );
	}

}
 
Example #21
Source File: FlexMavenPackagedProjectStagingDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testWaitUntilLaunchTerminates_normalExit()
    throws DebugException, InterruptedException {
  IProcess process = mock(IProcess.class);
  when(process.getExitValue()).thenReturn(0);

  ILaunch launch = mock(ILaunch.class);
  when(launch.isTerminated()).thenReturn(true);
  when(launch.getProcesses()).thenReturn(new IProcess[] {process, process});

  boolean normalExit = FlexMavenPackagedProjectStagingDelegate.waitUntilLaunchTerminates(
      launch, new NullProgressMonitor());
  assertTrue(normalExit);
}
 
Example #22
Source File: KubeUtil.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void terminate() {
	if (process != null && process.isAlive()) {
		process.destroy();
	}
	if (launch != null && !launch.isTerminated()) {
		try {
			launch.terminate();
		} catch (DebugException e) {
			Logger.logError("An error occured trying to terminate the port forward launch: " + localPort + ":" + remotePort, e);
		}
	}
}
 
Example #23
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void suspend( ) throws DebugException
{
	try
	{
		reportVM.suspend( );
	}
	catch ( VMException e )
	{
		logger.warning( e.getMessage( ) );
	}
}
 
Example #24
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public String getDisplayName( )
{
	try
	{
		return getName( );
	}
	catch ( DebugException e )
	{
		return getDefaultName( );
	}
}
 
Example #25
Source File: ScriptVariable.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public String getDisplayName( )
{
	try
	{
		return getName( );
	}
	catch ( DebugException e )
	{
		return name;
	}
}
 
Example #26
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Step return
 * 
 * @throws DebugException
 */
public void stepReturn( ) throws DebugException
{
	try
	{
		thread.setStepping( true );
		reportVM.stepOut( );
	}
	catch ( VMException e )
	{
		logger.warning( e.getMessage( ) );
	}

}
 
Example #27
Source File: TLCProcessJob.java    From tlaplus with MIT License 5 votes vote down vote up
/**
* @return The processee's exit/return value or -1 if unknown.
*/
  public int getExitValue() {
  	if (this.process != null) {
  		try {
  			return this.process.getExitValue();
  		} catch (DebugException shouldNotHappen) {
  			shouldNotHappen.printStackTrace();
  		}
  	}
  	return 255;
  }
 
Example #28
Source File: DsfGdbAdaptor.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * This method terminates the current DSF-GDB session
 */
public void dispose() {
    if (fLaunch != null && fLaunch.canTerminate() && !isTerminating) {
        isTerminating = true;
        try {
            fLaunch.terminate();
        } catch (DebugException e) {
            GdbTraceCorePlugin.logError(e.getMessage(), e);
        }
        fLaunch = null;
    }
}
 
Example #29
Source File: SCTDebugTarget.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public void terminate() throws DebugException {
	fireEvent(new DebugEvent(getDebugTarget(), DebugEvent.TERMINATE));
	terminated = true;
	executionControl.terminate();
	if (engine.getExecutionContext() != null)
		engine.getExecutionContext().eAdapters().remove(updater);
}
 
Example #30
Source File: ScriptModelPresentation.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param value
 * @return
 * @throws DebugException
 */
private String getValueText( IValue value ) throws DebugException
{

	String refTypeName = value.getReferenceTypeName( );
	String valueString = value.getValueString( );
	boolean isString = false;

	// boolean isObject = true;
	// boolean isArray = value instanceof IJavaArray;
	StringBuffer buffer = new StringBuffer( );
	// Always show type name for objects & arrays (but not Strings)
	if ( !isString && ( refTypeName.length( ) > 0 ) )
	{
		String qualTypeName = refTypeName;
		buffer.append( qualTypeName );
		buffer.append( ' ' );

	}

	// Put double quotes around Strings
	if ( valueString != null && ( isString || valueString.length( ) > 0 ) )
	{
		if ( isString )
		{
			buffer.append( '"' );
		}
		buffer.append( valueString );
		if ( isString )
		{
			buffer.append( '"' );
		}
	}

	return buffer.toString( );
}