|
From: Markus B. <mba...@us...> - 2005-10-06 23:29:57
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21414/src/org/rubypeople/rdt/internal/debug/core Modified Files: RubyLineBreakpoint.java RubyDebuggerProxy.java Added Files: RubyExceptionBreakpoint.java Log Message: RubyExceptionBreakpoints / catchpoints functionality added --- NEW FILE: RubyExceptionBreakpoint.java --- /* * Author: Markus Barchfeld * * Copyright (c) 2005 RubyPeople. * * This file is part of the Ruby Development Tools (RDT) plugin for eclipse. RDT is * subject to the "Common Public License (CPL) v 1.0". You may not use RDT except in * compliance with the License. For further information see org.rubypeople.rdt/rdt.license. */ package org.rubypeople.rdt.internal.debug.core; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.Breakpoint; public class RubyExceptionBreakpoint extends Breakpoint { private static String RUBY_EXCEPTION_ATTR = "RubyException" ; public RubyExceptionBreakpoint(final String exception) throws CoreException { // we need to have a resource, because the marker needs it (BTW: why the hell do // we need a marker for?) // The workspace root is chosen because JavaExceptionsBreakpoints do so as well final IResource resource = ResourcesPlugin.getWorkspace().getRoot() ; IWorkspaceRunnable wr = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { setMarker(resource.createMarker(RubyLineBreakpoint.RUBY_BREAKPOINT_MARKER)); getMarker().setAttribute(RUBY_EXCEPTION_ATTR, exception); // REGISTERED ? getMarker().setAttribute(REGISTERED, false); setRegistered(true); setEnabled(true); } }; try { ResourcesPlugin.getWorkspace().run(wr, null); } catch (CoreException e) { throw new DebugException(e.getStatus()); } } /** * Returns the type of marker associated with this type of breakpoints */ public static String getMarkerType() { return RubyLineBreakpoint.RUBY_BREAKPOINT_MARKER; } public String getModelIdentifier() { return "org.rubypeople.rdt.debug"; } public String getException() throws CoreException { return (String) this.ensureMarker().getAttribute(RUBY_EXCEPTION_ATTR); } public void setException(String newValue) throws CoreException { this.ensureMarker().setAttribute(RUBY_EXCEPTION_ATTR, newValue); } } Index: RubyDebuggerProxy.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** RubyDebuggerProxy.java 3 Oct 2005 07:16:25 -0000 1.17 --- RubyDebuggerProxy.java 6 Oct 2005 23:29:49 -0000 1.18 *************** *** 29,33 **** public class RubyDebuggerProxy { ! public final static String DEBUGGER_ACTIVE_KEY = "org.rubypeople.rdt.debug.ui.debuggerActive" ; private Socket socket; private PrintWriter writer; --- 29,34 ---- public class RubyDebuggerProxy { ! ! public final static String DEBUGGER_ACTIVE_KEY = "org.rubypeople.rdt.debug.ui.debuggerActive"; private Socket socket; private PrintWriter writer; *************** *** 41,54 **** debugTarget.setRubyDebuggerProxy(this); } ! public boolean checkConnection() { try { ! return this.getSocket().isConnected() ; ! } ! catch(DebuggerNotFoundException ex) { ! return false ; ! } ! catch(IOException ex) { ! return false ; } } --- 42,53 ---- debugTarget.setRubyDebuggerProxy(this); } ! public boolean checkConnection() { try { ! return this.getSocket().isConnected(); ! } catch (DebuggerNotFoundException ex) { ! return false; ! } catch (IOException ex) { ! return false; } } *************** *** 58,100 **** this.setBreakPoints(); this.startRubyLoop(); ! } catch (IOException e) { ! } } public void stop() { ! if (rubyLoop == null) { ! // only in tests, where no real connection is established ! return; ! } rubyLoop.setShouldStop(); rubyLoop.interrupt(); } - protected Socket acquireSocket() throws IOException { ! int tryCount = 10; for (int i = 0; i < tryCount; i++) { try { socket = new Socket("localhost", 1098); ! return socket ; } catch (IOException e) { try { Thread.sleep(500); ! } catch (InterruptedException e1) { ! } } } ! return null ; ! } ! protected Socket getSocket() throws IOException, DebuggerNotFoundException { ! if (socket == null) { ! socket = acquireSocket() ; ! if (socket == null) { ! throw new DebuggerNotFoundException() ; ! } } return socket; --- 57,94 ---- this.setBreakPoints(); this.startRubyLoop(); ! } catch (IOException e) {} } public void stop() { ! if (rubyLoop == null) { ! // only in tests, where no real connection is established ! return; ! } rubyLoop.setShouldStop(); rubyLoop.interrupt(); } protected Socket acquireSocket() throws IOException { ! int tryCount = 10; for (int i = 0; i < tryCount; i++) { try { socket = new Socket("localhost", 1098); ! return socket; } catch (IOException e) { try { Thread.sleep(500); ! } catch (InterruptedException e1) {} } } ! return null; ! } ! protected Socket getSocket() throws IOException, DebuggerNotFoundException { ! if (socket == null) { ! socket = acquireSocket(); ! if (socket == null) { throw new DebuggerNotFoundException(); } } return socket; *************** *** 141,145 **** IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IRubyDebugTarget.MODEL_IDENTIFIER); for (int i = 0; i < breakpoints.length; i++) { ! this.addBreakpoint(breakpoints[i]) ; } } --- 135,139 ---- IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IRubyDebugTarget.MODEL_IDENTIFIER); for (int i = 0; i < breakpoints.length; i++) { ! this.addBreakpoint(breakpoints[i]); } } *************** *** 148,152 **** try { if (breakpoint.isEnabled()) { ! this.printBreakpoint("add", breakpoint.getMarker().getResource().getName(), breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1) ); } } catch (IOException e) { --- 142,150 ---- try { if (breakpoint.isEnabled()) { ! if (breakpoint instanceof RubyExceptionBreakpoint) { ! this.println("catch " + ((RubyExceptionBreakpoint) breakpoint).getException()); ! } else { ! this.printBreakpoint("add", breakpoint.getMarker().getResource().getName(), breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1)); ! } } } catch (IOException e) { *************** *** 159,163 **** public void removeBreakpoint(IBreakpoint breakpoint) { try { ! this.printBreakpoint("remove", breakpoint.getMarker().getResource().getName(), breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1) ); } catch (IOException e) { RdtDebugCorePlugin.log(e); --- 157,165 ---- public void removeBreakpoint(IBreakpoint breakpoint) { try { ! if (breakpoint instanceof RubyExceptionBreakpoint) { ! this.println("catch off"); ! } else { ! this.printBreakpoint("remove", breakpoint.getMarker().getResource().getName(), breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1)); ! } } catch (IOException e) { RdtDebugCorePlugin.log(e); *************** *** 165,176 **** } ! public void updateBreakpoint(IBreakpoint breakpoint, IMarkerDelta markerDelta) { // line might have changed or enablement/disablement ! try { ! // remove is called even if it has not been added at program start ! // (happens if enablement changed from disabled at program start to enabled) ! this.printBreakpoint("remove", breakpoint.getMarker().getResource().getName(), markerDelta.getAttribute(IMarker.LINE_NUMBER, -1)); ! this.addBreakpoint(breakpoint) ; } catch (IOException e) { RdtDebugCorePlugin.log(e); --- 167,185 ---- } ! public void updateBreakpoint(IBreakpoint breakpoint, IMarkerDelta markerDelta) { // line might have changed or enablement/disablement ! try { ! if (breakpoint instanceof RubyExceptionBreakpoint) { ! // so far we allow only one catch exception ! // catch off must be set in the case that the enablement has changed to disabled ! this.println("catch off"); ! } else { ! // remove is called even if it has not been added at program start ! // (happens if enablement changed from disabled at program start to ! // enabled) ! this.printBreakpoint("remove", breakpoint.getMarker().getResource().getName(), markerDelta.getAttribute(IMarker.LINE_NUMBER, -1)); ! } ! this.addBreakpoint(breakpoint); } catch (IOException e) { RdtDebugCorePlugin.log(e); *************** *** 241,249 **** RubyVariable[] variables = new VariableReader(getMultiReaderStrategy()).readVariables(frame); if (variables.length == 0) { ! return null ; } - else { - return variables[0] ; - } } catch (IOException ioex) { ioex.printStackTrace(); --- 250,257 ---- RubyVariable[] variables = new VariableReader(getMultiReaderStrategy()).readVariables(frame); if (variables.length == 0) { ! return null; ! } else { ! return variables[0]; } } catch (IOException ioex) { ioex.printStackTrace(); *************** *** 252,256 **** } - public void readStepOverEnd(RubyStackFrame stackFrame) { try { --- 260,263 ---- *************** *** 275,279 **** try { this.println("th " + ((RubyThread) stackFrame.getThread()).getId() + " ; step " + stackFrame.getIndex()); ! /*return new SuspensionReader(getMultiReaderStrategy()).readSuspension(); */ } catch (Exception e) { RdtDebugCorePlugin.log(e); --- 282,289 ---- try { this.println("th " + ((RubyThread) stackFrame.getThread()).getId() + " ; step " + stackFrame.getIndex()); ! /* ! * return new ! * SuspensionReader(getMultiReaderStrategy()).readSuspension(); ! */ } catch (Exception e) { RdtDebugCorePlugin.log(e); *************** *** 301,311 **** } } ! public LoadResultReader.LoadResult readLoadResult(String filename) { try { ! this.println("load " +filename) ; return new LoadResultReader(getMultiReaderStrategy()).readLoadResult(); } catch (Exception e) { ! return null ; } } --- 311,321 ---- } } ! public LoadResultReader.LoadResult readLoadResult(String filename) { try { ! this.println("load " + filename); return new LoadResultReader(getMultiReaderStrategy()).readLoadResult(); } catch (Exception e) { ! return null; } } *************** *** 323,332 **** } ! public void setShouldStop() { ! } public void run() { try { ! System.setProperty(DEBUGGER_ACTIVE_KEY, "true") ; getDebugTarget().updateThreads(); println("cont"); --- 333,341 ---- } ! public void setShouldStop() {} public void run() { try { ! System.setProperty(DEBUGGER_ACTIVE_KEY, "true"); getDebugTarget().updateThreads(); println("cont"); *************** *** 339,355 **** RdtDebugCorePlugin.debug(hit); new Thread() { public void run() { getDebugTarget().suspensionOccurred(hit); } ! } ! .start(); ! } } catch (DebuggerNotFoundException ex) { ! throw ex ; } catch (Exception ex) { ! RdtDebugCorePlugin.debug("Exception in socket reader loop.", ex) ; ! } ! finally { ! System.setProperty(DEBUGGER_ACTIVE_KEY, "false") ; getDebugTarget().terminate(); try { --- 348,363 ---- RdtDebugCorePlugin.debug(hit); new Thread() { + public void run() { getDebugTarget().suspensionOccurred(hit); } ! }.start(); ! } } catch (DebuggerNotFoundException ex) { ! throw ex; } catch (Exception ex) { ! RdtDebugCorePlugin.debug("Exception in socket reader loop.", ex); ! } finally { ! System.setProperty(DEBUGGER_ACTIVE_KEY, "false"); getDebugTarget().terminate(); try { Index: RubyLineBreakpoint.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyLineBreakpoint.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RubyLineBreakpoint.java 1 Oct 2005 23:11:09 -0000 1.6 --- RubyLineBreakpoint.java 6 Oct 2005 23:29:49 -0000 1.7 *************** *** 11,15 **** public class RubyLineBreakpoint extends LineBreakpoint { ! private static final String RUBY_BREAKPOINT_MARKER = "org.rubypeople.rdt.debug.core.RubyBreakpointMarker"; //$NON-NLS-1$ public RubyLineBreakpoint(final IResource resource, final int lineNumber) throws CoreException { --- 11,15 ---- public class RubyLineBreakpoint extends LineBreakpoint { ! protected static final String RUBY_BREAKPOINT_MARKER = "org.rubypeople.rdt.debug.core.RubyBreakpointMarker"; //$NON-NLS-1$ public RubyLineBreakpoint(final IResource resource, final int lineNumber) throws CoreException { |