API consolidation for org.eclipse.objectteams.otdt.debug
- redefine the line between API and non-API
- add javadoc to API
- removed some unused stuff
Also:
- implemented clearing the TeamView when a launch terminates
- removed redundant sort mode "activation order"
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/breakpoints/IOOTBreakPoints.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/breakpoints/IOOTBreakPoints.java
new file mode 100644
index 0000000..629adcc
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/breakpoints/IOOTBreakPoints.java
@@ -0,0 +1,38 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2006, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.core.breakpoints;
+
+/**
+ * Do not edit: This interface is auto-generated from org/objectteams/Team.java
+ * using scripts/genIOOTBreakPoints.sh
+ *
+ * Purpose: make specific line numbers of Team.java available for the debugger.
+ */
+public interface IOOTBreakPoints
+{
+ int LINE_TeamConstructor = 62;
+ int LINE_ConfinedGetTeam = 93;
+ int LINE_ActivateMethod = 164;
+ int LINE_DeactivateMethod = 195;
+ int LINE_ImplicitActivateMethod = 242;
+ int LINE_ImplicitDeactivateMethod = 277;
+ int LINE_FinalizeMethod = 486;
+}
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/breakpoints/OOTBreakpoints.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/breakpoints/OOTBreakpoints.java
new file mode 100644
index 0000000..586d3a3
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/breakpoints/OOTBreakpoints.java
@@ -0,0 +1,213 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OOTBreakpoints.java 23427 2010-02-03 22:23:59Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.core.breakpoints;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.debug.core.IJavaBreakpoint;
+import org.eclipse.jdt.debug.core.JDIDebugModel;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+
+import static org.eclipse.objectteams.otdt.debug.core.breakpoints.IOOTBreakPoints.*;
+
+/**
+ * @author ike
+ *
+ * This class provides methods to create OOT-specific (org.objectteams.Team) breakpoints
+ *
+ * $Id: OOTBreakpoints.java 23427 2010-02-03 22:23:59Z stephan $
+ */
+@SuppressWarnings("nls")
+public class OOTBreakpoints
+{
+ public static final String FIELD_THIS = "this";
+ public static final String LOCAL_THREAD_ACT_DEACT = "thread";
+ public static final String LOCAL_THREAD_IMPLICIT_ACT_DEACT = "currentThread";
+ public static final String FIELD_ALL_THREADS = "ALL_THREADS";
+
+ public static final String ATTR_OT_BREAKPOINT = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint";
+ public static final String ATTR_OT_BREAKPOINT_CTOR = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.Constructor";
+ public static final String ATTR_OT_BREAKPOINT_FINALIZE = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.FinalizeMethod";
+ public static final String ATTR_OT_BREAKPOINT_ACT = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.ActivateMethod";
+ public static final String ATTR_OT_BREAKPOINT_DEACT = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.DeactivateMethod";
+ public static final String ATTR_OT_BREAKPOINT_IMPLICIT_ACT = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.ImplicitActivateMethod";
+ public static final String ATTR_OT_BREAKPOINT_IMPLICIT_DEACT = OTDebugPlugin.PLUGIN_ID + ".TeamBreakpoint.ImplicitDeactivateMethod";
+
+
+ //associated with "public Team() {}"
+ public static int getTeamConstructorLineNumber()
+ {
+ return LINE_TeamConstructor;
+ }
+
+ //associated with "doRegistration();"
+ public static int getActivateMethodLineNumber()
+ {
+ return LINE_ActivateMethod;
+ }
+
+ //associated with "_OT$lazyGlobalActiveFlag = false;"
+ public static int getDeactivateMethodLineNumber()
+ {
+ return LINE_DeactivateMethod;
+ }
+
+ //associated with "implicitActivationsPerThread.set(Integer.valueOf(implActCount + 1 ));"
+ public static int getImplicitActivateMethodLineNumber()
+ {
+ return LINE_ImplicitActivateMethod;
+ }
+
+ //implicitActivationsPerThread.set(Integer.valueOf(implActCount - 1));
+ public static int getImplicitDeactivateMethodLineNumber()
+ {
+ return LINE_ImplicitDeactivateMethod;
+ }
+
+ // implicit "return;"
+ public static int getFinalizeMethodLineNumber() {
+ return LINE_FinalizeMethod;
+ }
+
+ public static Map<String, Boolean> getBreakpointAttributes()
+ {
+ Map<String, Boolean> attrs = new HashMap<String, Boolean>();
+ attrs.put(OOTBreakpoints.ATTR_OT_BREAKPOINT, Boolean.TRUE);
+ return attrs;
+ }
+
+ public static IBreakpoint createOOTConstructorBreakpoint(IType oot)
+ throws CoreException
+ {
+ Map<String, Boolean> constructorAttributes = getBreakpointAttributes();
+ constructorAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_CTOR, Boolean.TRUE);
+ return createOOTBreakpoint(oot, getTeamConstructorLineNumber(), constructorAttributes);
+ }
+
+ public static IBreakpoint createOOTFinalizeBreakpoint(IType oot)
+ throws CoreException
+ {
+ Map<String, Boolean> finalizeMethodAttributes = getBreakpointAttributes();
+ finalizeMethodAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_FINALIZE, Boolean.TRUE);
+ return createOOTMethodBreakpoint(oot, getFinalizeMethodLineNumber(), finalizeMethodAttributes);
+ }
+
+ public static IBreakpoint createOOTActivateBreakpoint(IType oot)throws CoreException
+ {
+ Map<String, Boolean> activateMethodAttributes = getBreakpointAttributes();
+ activateMethodAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_ACT, Boolean.TRUE);
+ return createOOTBreakpoint(oot, getActivateMethodLineNumber(), activateMethodAttributes);
+ }
+
+ public static IBreakpoint createOOTDeactivateBreakpoint(IType oot) throws CoreException
+ {
+ Map<String, Boolean> deactivateMethodAttributes = getBreakpointAttributes();
+ deactivateMethodAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_DEACT, Boolean.TRUE);
+ return createOOTBreakpoint(oot, getDeactivateMethodLineNumber(), deactivateMethodAttributes);
+ }
+
+ public static IBreakpoint createOOTImplicitActivateBreakpoint(IType oot)throws CoreException
+ {
+ Map<String, Boolean> implicitActivateMethodAttributes = getBreakpointAttributes();
+ implicitActivateMethodAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_ACT, Boolean.TRUE);
+ return createOOTBreakpoint(oot, getImplicitActivateMethodLineNumber(), implicitActivateMethodAttributes);
+ }
+
+ public static IBreakpoint createOOTImplicitDeactivateBreakpoint(IType oot)throws CoreException
+ {
+ Map<String, Boolean> implicitDeactivateMethodAttributes = getBreakpointAttributes();
+ implicitDeactivateMethodAttributes.put(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_DEACT, Boolean.TRUE);
+ return createOOTBreakpoint(oot, getImplicitDeactivateMethodLineNumber(), implicitDeactivateMethodAttributes);
+ }
+ public static IBreakpoint createOOTBreakpoint(IType oot, int linenumber, Map attributes)
+ throws CoreException
+ {
+ IResource teamResource = oot.getJavaProject().getResource();
+ IJavaBreakpoint breakpoint = JDIDebugModel.createLineBreakpoint(
+ teamResource,
+ oot.getFullyQualifiedName(),
+ linenumber,
+ -1, -1, 0,
+ false /*register*/,
+ attributes);
+ breakpoint.setPersisted(false);
+
+ return breakpoint;
+ }
+
+ public static IBreakpoint createOOTMethodBreakpoint(IType oot, int linenumber, Map attributes)
+ throws CoreException
+ {
+ IResource teamResource = oot.getJavaProject().getResource();
+ IJavaBreakpoint breakpoint = JDIDebugModel.createMethodBreakpoint(
+ teamResource,
+ oot.getFullyQualifiedName(),
+ "finalize",
+ "()V",
+ true /*entry*/, false /*exit*/, false /*native*/,
+ linenumber,
+ -1, -1, 0,
+ false /*register*/,
+ attributes);
+ breakpoint.setPersisted(false);
+ return breakpoint;
+ }
+
+ public static final boolean isOOTBreakpoint(IBreakpoint breakpoint) throws CoreException
+ {
+ return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT) != null;
+ }
+
+ public static final boolean isOOTConstructorBreakpoint(IBreakpoint breakpoint) throws CoreException
+ {
+ return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_CTOR) != null;
+ }
+
+ public static final boolean isOOTFinalizeBreakpoint(IBreakpoint breakpoint) throws CoreException
+ {
+ return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_FINALIZE) != null;
+ }
+
+ public static final boolean isOOTActiveMethodBreakpoint(IBreakpoint breakpoint) throws CoreException
+ {
+ return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_ACT) != null;
+ }
+
+ public static final boolean isOOTDeactiveMethodBreakpoint(IBreakpoint breakpoint) throws CoreException
+ {
+ return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_DEACT) != null;
+ }
+
+ public static final boolean isOOTImplicitActiveMethodBreakpoint(IBreakpoint breakpoint) throws CoreException
+ {
+ return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_ACT) != null;
+ }
+
+ public static final boolean isOOTImplicitDeactiveMethodBreakpoint(IBreakpoint breakpoint) throws CoreException
+ {
+ return breakpoint.getMarker().getAttribute(OOTBreakpoints.ATTR_OT_BREAKPOINT_IMPLICIT_DEACT) != null;
+ }
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/breakpoints/OTJavaWatchpoint.java b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/breakpoints/OTJavaWatchpoint.java
new file mode 100644
index 0000000..0d5fc51
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.otdt.debug/src/org/eclipse/objectteams/otdt/debug/internal/breakpoints/OTJavaWatchpoint.java
@@ -0,0 +1,142 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2006 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute for Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id: OTJavaWatchpoint.java 23427 2010-02-03 22:23:59Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.core.breakpoints;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.core.IJavaVariable;
+import org.eclipse.jdt.internal.debug.core.breakpoints.JavaWatchpoint;
+import org.eclipse.jdt.internal.debug.core.model.JDIObjectValue;
+import org.eclipse.jdt.internal.debug.core.model.JDIThread;
+
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.Value;
+import com.sun.jdi.event.Event;
+import com.sun.jdi.event.ModificationWatchpointEvent;
+
+/**
+ * FIXME(SH): THIS CLASS IS NOT USED.
+ *
+ * @author ike
+ *
+ * This class is for dealing with the Modification Watchpoint and getting the modified value.
+ *
+ * $Id: OTJavaWatchpoint.java 23427 2010-02-03 22:23:59Z stephan $
+ */
+public class OTJavaWatchpoint extends JavaWatchpoint
+{
+ private Hashtable _threadToObjectRefTable;
+// unused private String _searchField;
+
+ public OTJavaWatchpoint(IResource resource, String typeName, String fieldName, int lineNumber, int charStart, int charEnd, int hitCount, boolean register, Map attributes, String searchString) throws DebugException
+ {
+ super(resource, typeName, fieldName, lineNumber, charStart, charEnd, hitCount, register, attributes);
+
+ _threadToObjectRefTable = new Hashtable();
+// unused _searchField = searchString;
+ }
+
+ /** Overrides the JavaWatchpoint.handleBreakpointEvent() method to handle
+ * the ModificationWatchpointEvent and to store the value, which
+ * will be set.
+ */
+ @Override
+ public boolean handleBreakpointEvent(Event event, JDIThread thread, boolean suspendVote)
+ {
+ if (event instanceof ModificationWatchpointEvent)
+ {
+ ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent)event;
+ Value currentValue = modEvent.valueCurrent();
+ Value valueToBe = modEvent.valueToBe();
+ ObjectReference objectRef = modEvent.object();
+
+ Hashtable objectRefs;
+ if (!_threadToObjectRefTable.containsKey(thread))
+ {
+ objectRefs = new Hashtable();
+ }
+ else
+ {
+ objectRefs = (Hashtable)_threadToObjectRefTable.get(thread);
+ }
+
+ Value [] values;
+ if (!objectRefs.containsKey(objectRef))
+ {
+ values = new Value[2];
+
+ }
+ else
+ {
+ values = (Value [])objectRefs.get(objectRef);
+ }
+
+ values[0] = currentValue;
+ values[1] = valueToBe;
+ objectRefs.put(objectRef, values);
+
+ _threadToObjectRefTable.put(thread, objectRefs);
+ }
+ return super.handleBreakpointEvent(event, thread, suspendVote);
+ }
+
+ public Value getValueToBe(IJavaThread thread, IJavaVariable variable) throws DebugException
+ {
+ Value [] values = getValues(thread, variable);
+
+ if (values != null && values.length >=2)
+ return values[1];
+ else
+ return null;
+ }
+
+ public Value getCurrentValue(IJavaThread thread, IJavaVariable variable) throws DebugException
+ {
+ Value [] values = getValues(thread, variable);
+
+ if (values != null && values.length >=2)
+ return values[0];
+ else
+ return null;
+ }
+
+ private Value[] getValues(IJavaThread thread, IJavaVariable variable) throws DebugException
+ {
+ Hashtable objRefTable = (Hashtable) _threadToObjectRefTable.get(thread);
+
+ for (Iterator iter = objRefTable.keySet().iterator(); iter.hasNext();)
+ {
+ Value objRef = (ObjectReference) iter.next();
+ JDIObjectValue value = (JDIObjectValue)variable.getValue();
+
+ if (value.getUnderlyingObject().equals(objRef))
+ {
+ return (Value [])objRefTable.get(objRef);
+ }
+ }
+ return null;
+ }
+}