# HG changeset patch
# User l12wang
# Date 1258959556 21600
# Node ID 09f3d307f0818cf43a49dc2b74e40374970964e2
# Parent 05ea843f7d56e1a2e7ad19ae01495d69b346940f
Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
diff -r 05ea843f7d56 -r 09f3d307f081 cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointAttributeTranslator.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointAttributeTranslator.java Mon Nov 23 00:59:16 2009 -0600
@@ -0,0 +1,561 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Nokia and others.
+ * 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
+ *
+ * Contributors:
+ * Nokia - Initial API and implementation. Nov, 2009.
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.mi.service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.debug.core.model.ICBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICBreakpointExtension;
+import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICWatchpoint;
+import org.eclipse.cdt.debug.internal.core.breakpoints.BreakpointProblems;
+import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
+import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
+import org.eclipse.cdt.dsf.datamodel.DMContexts;
+import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator;
+import org.eclipse.cdt.dsf.debug.service.IBreakpointAttributeTranslatorExtension;
+import org.eclipse.cdt.dsf.debug.service.IDsfBreakpointExtension;
+import org.eclipse.cdt.dsf.debug.service.ISourceLookup;
+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.IBreakpointDMContext;
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
+import org.eclipse.cdt.dsf.debug.service.ISourceLookup.ISourceLookupDMContext;
+import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
+import org.eclipse.cdt.dsf.service.DsfServicesTracker;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IBreakpoint;
+
+public class MIBreakpointAttributeTranslator implements IBreakpointAttributeTranslatorExtension {
+
+ private final static String GDB_DEBUG_MODEL_ID = "org.eclipse.cdt.dsf.gdb"; //$NON-NLS-1$
+
+ // Extra breakpoint attributes
+ private static final String ATTR_DEBUGGER_PATH = GdbPlugin.PLUGIN_ID + ".debuggerPath"; //$NON-NLS-1$
+ private static final String ATTR_THREAD_FILTER = GdbPlugin.PLUGIN_ID + ".threadFilter"; //$NON-NLS-1$
+// private static final String ATTR_THREAD_ID = GdbPlugin.PLUGIN_ID + ".threadID"; //$NON-NLS-1$
+
+ private DsfServicesTracker dsfServicesTracker;
+ private DsfSession dsfSession;
+ private BreakpointsMediator breakpointsMediator;
+ private String debugModelId;
+
+ /**
+ * Manage breakpoint problem markers.
+ * It's better be done by MIBreakpoints service so that it's accessible by
+ * the MIBreakpoints service too. But to minimize change to MIBreakpoints in
+ * this iteration, I just put it here..... 11/18/09
+ */
+ private Map fBreakpointMarkerProblems =
+ new HashMap();
+
+ public MIBreakpointAttributeTranslator(DsfSession dsfSession, String debugModelId) {
+ super();
+ this.dsfSession = dsfSession;
+ this.debugModelId = debugModelId;
+
+ dsfServicesTracker = new DsfServicesTracker(GdbPlugin.getDefault().getBundle().getBundleContext(), dsfSession.getId());
+ }
+
+ public boolean canUpdateAttributes(IBreakpointDMContext bp, Map delta) {
+ /*
+ * This method decides whether we need to re-install the breakpoint
+ * based on the attributes change (refer to caller in
+ * BreakpointsMediator).
+ */
+ // Check if there is any modified attribute
+ if (delta == null || delta.size() == 0)
+ return true;
+
+ // Check the "critical" attributes
+ if (delta.containsKey(ATTR_DEBUGGER_PATH) // File name
+ || delta.containsKey(MIBreakpoints.LINE_NUMBER) // Line number
+ || delta.containsKey(MIBreakpoints.FUNCTION) // Function name
+ || delta.containsKey(MIBreakpoints.ADDRESS) // Absolute address
+ || delta.containsKey(ATTR_THREAD_FILTER) // Thread ID
+ || delta.containsKey(MIBreakpoints.EXPRESSION) // Watchpoint expression
+ || delta.containsKey(MIBreakpoints.READ) // Watchpoint type
+ || delta.containsKey(MIBreakpoints.WRITE)) { // Watchpoint type
+ return false;
+ }
+
+ // for other attrs (ICBreakpoint.INSTALL_COUNT, ICBreakpoint.IGNORE_COUNT,
+ // ICBreakpoint.CONDITION, etc), we can update them.
+ return true;
+ }
+
+ public void dispose() {
+ if (dsfServicesTracker != null)
+ dsfServicesTracker.dispose();
+ dsfSession = null;
+
+ clearBreakpointProblemMarkers();
+ }
+
+ public List