cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IBreakpointAttributeTranslatorExtension.java
changeset 117 09f3d307f081
parent 112 6b1088abccf8
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IBreakpointAttributeTranslatorExtension.java	Tue Nov 17 14:33:45 2009 -0600
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IBreakpointAttributeTranslatorExtension.java	Mon Nov 23 00:59:16 2009 -0600
@@ -7,6 +7,7 @@
  * 
  * Contributors:
  *     Wind River Systems - initial API and implementation
+ *     Nokia - enhanced to work for both GDB and EDC.  Nov. 2009.
  *******************************************************************************/
 package org.eclipse.cdt.dsf.debug.service;
 
@@ -14,7 +15,6 @@
 import java.util.Map;
 
 import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
-import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
 import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator.BreakpointEventType;
 import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator.ITargetBreakpointInfo;
 import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
@@ -22,59 +22,93 @@
 import org.eclipse.debug.core.model.IBreakpoint;
 
 /**
- * Breakpoint attribute translator interface
+ * Enhanced breakpoint attribute translator interface
  * 
  * @since 2.1
  */
 
-@ThreadSafeAndProhibitedFromDsfExecutor("")
 public interface IBreakpointAttributeTranslatorExtension extends IBreakpointAttributeTranslator {
 	/**
-	 * Convert all attributes of the given platform breakpoint (BP) to
-	 * attributes of potential target breakpoints. Two tasks are involved:<br>
-	 * 1. Convert the attributes to debugger specific ones, if needed. For
-	 * instance, GDB implementation has its own breakpoint attribute keys. <br>
-	 * 2. Resolve the breakpoint. A platform BP may be mapped to two or more
-	 * target BPs, e.g. a breakpoint in an in-line function may be mapped to
-	 * several target BPs, or a thread-specific BP may be mapped to several
-	 * target BPs each of which is for one thread. This method will return an
-	 * attribute map for each of the target BP.<br>
+	 * Resolve the breakpoint in given context. A platform BP may be mapped to
+	 * two or more target BPs, e.g. a breakpoint in an in-line function may be
+	 * mapped to several target BPs, or a thread-specific BP may be mapped to
+	 * several target BPs each of which is for one thread. This method will get
+	 * the list of attribute maps each of which corresponds to one target BP.<br>
 	 * <br>
-	 * This method must be called in DSF execution thread.
+	 * This method is and must be called in DSF execution thread.
 	 * 
 	 * @param context
 	 *            - a IBreakpointsTargetDMContext object (which could be a
 	 *            process or a loaded module) in which we locate target BPs for
-	 *            the platform BP.
+	 *            the platform BP. Cannot be null.
 	 * @param breakpoint
 	 *            - platform breakpoint.
-	 * @param bpManagerEnabled
-	 *            - flag from platform breakpoint manager indicating that all
-	 *            breakpoints are enabled.
+	 * @param bpAttributes
+	 *            - all attributes of the breakpoint, usually output from
+	 *            {@link #getAllBreakpointAttributes(IBreakpoint, boolean)}.
 	 * @param drm
 	 *            - on completion of the request, the DataRequestMonitor
 	 *            contains one or more attribute maps each of which
 	 *            corresponding to one target breakpoint.
 	 * @throws CoreException
 	 */
-    public void getTargetBreakpointAttributes(IBreakpointsTargetDMContext context, IBreakpoint breakpoint, 
-    		boolean bpManagerEnabled, DataRequestMonitor<List<Map<String, Object>>> drm);
+    public void resolveBreakpoint(IBreakpointsTargetDMContext context, IBreakpoint breakpoint, 
+    		Map<String, Object> bpAttributes, DataRequestMonitor<List<Map<String, Object>>> drm);
 
-    /**
-     * Convert platform breakpoint attributes to target-recognizable attributes. 
-     * This method does not perform task #2 done by {@link this#getTargetBreakpointAttributes(List, IBreakpoint, boolean)}.
-     * 
-     * @param platformBPAttrDelta
-     * @return
-     */
-    public Map<String, Object> convertAttributeDelta(Map<String, Object> platformBPAttrDelta);
+	/**
+	 * Get all platform defined attributes for a breakpoint plus all attributes
+	 * defined by any breakpoint extension such as ICBreakpointExtension in CDT.
+	 * In other words, get all attributes available from UI. <br>
+	 * <br>
+	 * The attributes returned are independent of runtime context (process,
+	 * module, etc), whereas attributes from
+	 * {@link #resolveBreakpoint(IBreakpointsTargetDMContext, IBreakpoint, Map, DataRequestMonitor)}
+	 * are context sensitive. <br>
+	 * <br>
+	 * Note this method must not be called in DSF dispatch thread because we are
+	 * accessing the resources system to retrieve the breakpoint attributes.
+	 * Accessing the resources system potentially requires using global locks.
+	 * 
+	 * @param platformBP
+	 * @param bpManagerEnabled
+	 * @return list of target (debugger implementation) recognizable attributes.
+	 * @throws CoreException
+	 */
+    public Map<String, Object> getAllBreakpointAttributes(IBreakpoint platformBP, boolean bpManagerEnabled) throws CoreException;
+
+	/**
+	 * Convert platform breakpoint attributes to target attributes. This usually
+	 * involves changing attributes keys to target recognizable ones. For
+	 * instance, GDB integration has its own breakpoint attribute keys. <br>
+	 * 
+	 * @param platformBPAttr
+	 * @return
+	 */
+    public Map<String, Object> convertAttributes(Map<String, Object> platformBPAttr);
         
     /**
      * Update platform about breakpoint status change, e.g. breakpoint installed on target successfully or breakpoint
-     * removed from target successfully.
-     *  
+     * removed from target successfully.<br>
+     * <br>
+     * Note this method is not and must not be called in DSF dispatch thread.
+     * 
      * @param bpsInfo
      * @param eventType
      */
     public void updateBreakpointsStatus(Map<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>> bpsInfo, BreakpointEventType eventType);
+
+	/**
+	 * This is enhanced version of
+	 * {@link #canUpdateAttributes(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext, Map)}
+	 * in that this API gives more context parameters so that client can make
+	 * decision on a finer granularity when needed.<br>
+	 * <br>
+	 * This will be called in DSF dispatch thread.
+	 * 
+	 * @param bp  platform breakpoint.
+	 * @param context 
+	 * @param attributes target-recognizable attributes.
+	 * @return false as long as one of the attributes cannot be updated by client, otherwise true.
+	 */
+	public boolean canUpdateAttributes(IBreakpoint bp, IBreakpointsTargetDMContext context, Map<String, Object> attributes);
 }
\ No newline at end of file