cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointAttributeTranslator.java
author l12wang
Mon, 23 Nov 2009 00:59:16 -0600
changeset 117 09f3d307f081
permissions -rw-r--r--
Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
117
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
     1
/*******************************************************************************
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia and others.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
     3
 * All rights reserved. This program and the accompanying materials
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
     4
 * are made available under the terms of the Eclipse Public License v1.0
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
     5
 * which accompanies this distribution, and is available at
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
     6
 * http://www.eclipse.org/legal/epl-v10.html
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
     7
 *
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
     8
 * Contributors:
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
     9
 * 	Nokia - Initial API and implementation. Nov, 2009.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    10
 *******************************************************************************/
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    11
package org.eclipse.cdt.dsf.mi.service;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    12
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    13
import java.util.ArrayList;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    14
import java.util.HashMap;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    15
import java.util.HashSet;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    16
import java.util.List;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    17
import java.util.Map;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    18
import java.util.Set;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    19
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    20
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    21
import org.eclipse.cdt.debug.core.model.ICBreakpointExtension;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    22
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    23
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    24
import org.eclipse.cdt.debug.internal.core.breakpoints.BreakpointProblems;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    25
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    26
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    27
import org.eclipse.cdt.dsf.datamodel.DMContexts;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    28
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    29
import org.eclipse.cdt.dsf.debug.service.IBreakpointAttributeTranslatorExtension;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    30
import org.eclipse.cdt.dsf.debug.service.IDsfBreakpointExtension;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    31
import org.eclipse.cdt.dsf.debug.service.ISourceLookup;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    32
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator.BreakpointEventType;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    33
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator.ITargetBreakpointInfo;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    34
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    35
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    36
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    37
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    38
import org.eclipse.cdt.dsf.debug.service.ISourceLookup.ISourceLookupDMContext;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    39
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    40
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    41
import org.eclipse.cdt.dsf.service.DsfSession;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    42
import org.eclipse.core.resources.IMarker;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    43
import org.eclipse.core.resources.IResource;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    44
import org.eclipse.core.runtime.CoreException;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    45
import org.eclipse.core.runtime.IProgressMonitor;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    46
import org.eclipse.core.runtime.IStatus;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    47
import org.eclipse.core.runtime.Platform;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    48
import org.eclipse.core.runtime.Status;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    49
import org.eclipse.core.runtime.jobs.Job;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    50
import org.eclipse.debug.core.DebugException;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    51
import org.eclipse.debug.core.model.IBreakpoint;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    52
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    53
public class MIBreakpointAttributeTranslator implements IBreakpointAttributeTranslatorExtension {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    54
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    55
    private final static String GDB_DEBUG_MODEL_ID = "org.eclipse.cdt.dsf.gdb"; //$NON-NLS-1$
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    56
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    57
    // Extra breakpoint attributes
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    58
    private static final String ATTR_DEBUGGER_PATH = GdbPlugin.PLUGIN_ID + ".debuggerPath";   //$NON-NLS-1$
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    59
    private static final String ATTR_THREAD_FILTER = GdbPlugin.PLUGIN_ID + ".threadFilter";   //$NON-NLS-1$
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    60
//    private static final String ATTR_THREAD_ID     = GdbPlugin.PLUGIN_ID + ".threadID";       //$NON-NLS-1$
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    61
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    62
	private DsfServicesTracker	dsfServicesTracker;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    63
	private DsfSession			dsfSession;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    64
	private BreakpointsMediator	breakpointsMediator;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    65
	private String				debugModelId;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    66
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    67
	/**
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    68
	 * Manage breakpoint problem markers. <br>
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    69
	 * It's better be done by MIBreakpoints service so that it's accessible by
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    70
	 * the MIBreakpoints service too. But to minimize change to MIBreakpoints in
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    71
	 * this iteration, I just put it here..... 11/18/09
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    72
	 */
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    73
    private Map<ICBreakpoint, IMarker> fBreakpointMarkerProblems =
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    74
        new HashMap<ICBreakpoint, IMarker>();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    75
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    76
	public MIBreakpointAttributeTranslator(DsfSession dsfSession, String debugModelId) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    77
		super();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    78
		this.dsfSession = dsfSession;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    79
		this.debugModelId = debugModelId;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    80
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    81
		dsfServicesTracker = new DsfServicesTracker(GdbPlugin.getDefault().getBundle().getBundleContext(), dsfSession.getId());
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    82
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    83
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    84
	public boolean canUpdateAttributes(IBreakpointDMContext bp, Map<String, Object> delta) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    85
		/*
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    86
		 * This method decides whether we need to re-install the breakpoint
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    87
		 * based on the attributes change (refer to caller in
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    88
		 * BreakpointsMediator).
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    89
		 */         
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    90
        // Check if there is any modified attribute
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    91
        if (delta == null || delta.size() == 0)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    92
            return true;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    93
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    94
        // Check the "critical" attributes
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    95
        if (delta.containsKey(ATTR_DEBUGGER_PATH)            // File name
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    96
        ||  delta.containsKey(MIBreakpoints.LINE_NUMBER)     // Line number
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    97
        ||  delta.containsKey(MIBreakpoints.FUNCTION)        // Function name
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    98
        ||  delta.containsKey(MIBreakpoints.ADDRESS)         // Absolute address
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
    99
        ||  delta.containsKey(ATTR_THREAD_FILTER)            // Thread ID
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   100
        ||  delta.containsKey(MIBreakpoints.EXPRESSION)      // Watchpoint expression
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   101
        ||  delta.containsKey(MIBreakpoints.READ)            // Watchpoint type
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   102
        ||  delta.containsKey(MIBreakpoints.WRITE)) {        // Watchpoint type
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   103
            return false;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   104
        }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   105
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   106
        // for other attrs (ICBreakpoint.INSTALL_COUNT, ICBreakpoint.IGNORE_COUNT,
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   107
        // ICBreakpoint.CONDITION, etc), we can update them.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   108
        return true;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   109
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   110
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   111
	public void dispose() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   112
		if (dsfServicesTracker != null)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   113
			dsfServicesTracker.dispose();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   114
		dsfSession = null;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   115
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   116
		clearBreakpointProblemMarkers();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   117
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   118
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   119
	public List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   120
			throws CoreException {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   121
		// deprecated
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   122
		List<Map<String, Object>> retVal = new ArrayList<Map<String, Object>>();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   123
		return retVal;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   124
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   125
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   126
	public void initialize(BreakpointsMediator mediator) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   127
		breakpointsMediator = mediator;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   128
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   129
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   130
	public boolean supportsBreakpoint(IBreakpoint bp) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   131
        if (bp instanceof ICBreakpoint && bp.getModelIdentifier().equals(debugModelId)) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   132
            IMarker marker = bp.getMarker();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   133
            if (marker != null) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   134
                return true;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   135
            }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   136
        }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   137
        return false;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   138
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   139
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   140
	public void updateBreakpointStatus(IBreakpoint bp) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   141
		// obsolet, do nothing.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   142
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   143
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   144
	public void updateBreakpointsStatus(Map<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>> bpsInfo,
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   145
			BreakpointEventType eventType) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   146
		for (IBreakpoint bp : bpsInfo.keySet()) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   147
			if (! (bp instanceof ICBreakpoint))	// not C breakpoints, bail out.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   148
				return;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   149
			
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   150
			final ICBreakpoint icbp = (ICBreakpoint) bp;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   151
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   152
			Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]> targetBpPerContext = bpsInfo.get(bp);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   153
			
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   154
			switch (eventType) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   155
			case ADDED: {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   156
				int installCountTotal = 0;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   157
				StringBuffer errMsg = new StringBuffer();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   158
				for (ITargetBreakpointInfo[] tbpInfos : targetBpPerContext.values()) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   159
					// For each BpTargetDMContext, we increment the installCount for each
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   160
					// target BP that has been successfully installed.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   161
					int installCountPerContext = 0;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   162
					for (ITargetBreakpointInfo tbp : tbpInfos) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   163
						if (tbp.getTargetBreakpoint() != null)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   164
							installCountPerContext++;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   165
						else // failure in installation
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   166
							errMsg.append(tbp.getStatus().getMessage()).append('\n');
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   167
					}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   168
					installCountTotal += installCountPerContext;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   169
				}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   170
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   171
				for (int i=0; i < installCountTotal; i++)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   172
					try {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   173
						// this will eventually carried out in a workspace runnable.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   174
						icbp.incrementInstallCount();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   175
					} catch (CoreException e) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   176
						GdbPlugin.getDefault().getLog().log(e.getStatus());
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   177
					}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   178
				
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   179
				if (errMsg.length() > 0)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   180
					addBreakpointProblemMarker(icbp, errMsg.toString(), IMarker.SEVERITY_WARNING);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   181
				else // no error, clean message if any.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   182
					removeBreakpointProblemMarker(icbp);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   183
				
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   184
				break;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   185
				}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   186
			case MODIFIED:
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   187
				break;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   188
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   189
			case REMOVED: {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   190
				int removeCountTotal = 0;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   191
				for (ITargetBreakpointInfo[] tbpInfos : targetBpPerContext.values()) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   192
					// For each BpTargetDMContext, we decrement the installCount for each
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   193
					// target BP that we tried to remove, even if the removal failed. That's
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   194
					// because I've not seen a way to tell platform that removal fails 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   195
					// and the BP should be kept in UI.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   196
					removeCountTotal += tbpInfos.length;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   197
				}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   198
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   199
				for (int i=0; i < removeCountTotal; i++)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   200
					try {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   201
						if (icbp.isRegistered())	// not deleted in UI
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   202
							icbp.decrementInstallCount();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   203
					} catch (CoreException e) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   204
						GdbPlugin.getDefault().getLog().log(e.getStatus());
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   205
					}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   206
				break;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   207
				}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   208
			}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   209
		}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   210
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   211
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   212
	public Map<String, Object> convertAttributes(Map<String, Object> platformAttrs) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   213
		Map<String, Object> targetAttrs = new HashMap<String, Object>();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   214
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   215
		if (platformAttrs.containsKey(MIBreakpoints.BREAKPOINT_TYPE))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   216
			targetAttrs.put(MIBreakpoints.BREAKPOINT_TYPE,      platformAttrs.get(MIBreakpoints.BREAKPOINT_TYPE));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   217
        	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   218
		if (platformAttrs.containsKey(ICWatchpoint.EXPRESSION))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   219
			targetAttrs.put(MIBreakpoints.EXPRESSION,      platformAttrs.get(ICWatchpoint.EXPRESSION));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   220
		if (platformAttrs.containsKey(ICWatchpoint.READ))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   221
			targetAttrs.put(MIBreakpoints.READ,            platformAttrs.get(ICWatchpoint.READ));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   222
		if (platformAttrs.containsKey(ICWatchpoint.WRITE))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   223
			targetAttrs.put(MIBreakpoints.WRITE,           platformAttrs.get(ICWatchpoint.WRITE));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   224
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   225
		if (platformAttrs.containsKey(ICBreakpoint.SOURCE_HANDLE))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   226
			targetAttrs.put(MIBreakpoints.FILE_NAME,       platformAttrs.get(ICBreakpoint.SOURCE_HANDLE));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   227
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   228
		if (platformAttrs.containsKey(IMarker.LINE_NUMBER))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   229
			targetAttrs.put(MIBreakpoints.LINE_NUMBER,     platformAttrs.get(IMarker.LINE_NUMBER));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   230
		if (platformAttrs.containsKey(ICLineBreakpoint.FUNCTION))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   231
			targetAttrs.put(MIBreakpoints.FUNCTION,        platformAttrs.get(ICLineBreakpoint.FUNCTION));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   232
		if (platformAttrs.containsKey(ICLineBreakpoint.ADDRESS))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   233
			targetAttrs.put(MIBreakpoints.ADDRESS,         platformAttrs.get(ICLineBreakpoint.ADDRESS));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   234
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   235
		if (platformAttrs.containsKey(ICBreakpoint.CONDITION))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   236
			targetAttrs.put(MIBreakpoints.CONDITION,           platformAttrs.get(ICBreakpoint.CONDITION));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   237
		if (platformAttrs.containsKey(ICBreakpoint.IGNORE_COUNT))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   238
			targetAttrs.put(MIBreakpoints.IGNORE_COUNT,        platformAttrs.get(ICBreakpoint.IGNORE_COUNT));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   239
		if (platformAttrs.containsKey(ICBreakpoint.ENABLED))
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   240
			targetAttrs.put(MIBreakpoints.IS_ENABLED,          platformAttrs.get(ICBreakpoint.ENABLED));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   241
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   242
		return targetAttrs;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   243
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   244
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   245
    @SuppressWarnings("unchecked")
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   246
	public void resolveBreakpoint(IBreakpointsTargetDMContext context, IBreakpoint breakpoint, 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   247
    		Map<String, Object> bpAttributes, final DataRequestMonitor<List<Map<String, Object>>> drm) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   248
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   249
    	assert dsfSession.getExecutor().isInExecutorThread();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   250
    	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   251
    	// Create a copy as we don't want to change "bpAttributes".
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   252
		final Map<String, Object>	targetBPAttrBase = new HashMap<String, Object>(bpAttributes);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   253
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   254
		final Set<String> threads = (Set<String>) targetBPAttrBase.get(ATTR_THREAD_FILTER);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   255
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   256
		final List<Map<String, Object>>	targetBPList = new ArrayList<Map<String, Object>>();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   257
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   258
		// get debugger path (compilation-path) for source file, if any.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   259
		determineDebuggerPath(context, targetBPAttrBase, new RequestMonitor(dsfSession.getExecutor(), drm){
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   260
			@Override
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   261
			protected void handleSuccess() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   262
				// Create attribute list for each thread
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   263
				for (String thread : threads) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   264
					Map<String, Object> targetBP = new HashMap<String, Object>(targetBPAttrBase);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   265
					targetBP.put(MIBreakpointDMData.THREAD_ID, thread);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   266
					targetBPList.add(targetBP);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   267
				}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   268
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   269
				drm.setData(targetBPList);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   270
				drm.done();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   271
			}});
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   272
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   273
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   274
    /**
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   275
     * determineDebuggerPath
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   276
     * 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   277
     * Adds the path to the source file to the set of attributes
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   278
     * (for the debugger).
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   279
     * 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   280
     * @param dmc
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   281
     * @param targetAttrs
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   282
     * @param rm
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   283
     */
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   284
    private void determineDebuggerPath(IBreakpointsTargetDMContext dmc,
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   285
            final Map<String, Object> targetAttrs, final RequestMonitor rm)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   286
    {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   287
        String hostPath = (String) targetAttrs.get(MIBreakpoints.FILE_NAME);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   288
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   289
        if (hostPath != null) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   290
            ISourceLookup sourceService   = dsfServicesTracker.getService(ISourceLookup.class);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   291
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   292
            ISourceLookupDMContext srcDmc = DMContexts.getAncestorOfType(dmc, ISourceLookupDMContext.class);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   293
            if (srcDmc != null) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   294
                sourceService.getDebuggerPath(srcDmc, hostPath,
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   295
                    new DataRequestMonitor<String>(dsfSession.getExecutor(), rm) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   296
                        @Override
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   297
                        protected void handleSuccess() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   298
                            targetAttrs.put(ATTR_DEBUGGER_PATH, adjustDebuggerPath(getData()));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   299
                            rm.done();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   300
                        }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   301
                    });
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   302
            } else {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   303
                // Source lookup not available for given context, use the host
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   304
                // path for the debugger path.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   305
                targetAttrs.put(ATTR_DEBUGGER_PATH, adjustDebuggerPath(hostPath));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   306
                rm.done();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   307
            }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   308
        } else {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   309
            // Some types of breakpoints do not require a path
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   310
            // (e.g. watchpoints)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   311
            rm.done();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   312
        }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   313
    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   314
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   315
    /**
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   316
     * See bug232415
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   317
     * 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   318
     * @param path	the absolute path to the source file
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   319
     * @return
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   320
     */
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   321
    private String adjustDebuggerPath(String path) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   322
    	String result = path;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   323
    	// Make it MinGW-specific
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   324
    	if (Platform.getOS().startsWith("win")) { //$NON-NLS-1$
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   325
        	if (!path.startsWith("/")) { //$NON-NLS-1$
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   326
        		result = path.substring(path.lastIndexOf('\\') + 1);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   327
        	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   328
    	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   329
    	return result;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   330
    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   331
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   332
	/**
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   333
	 * Get the list of threads from the platform breakpoint attributes
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   334
	 * 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   335
	 * @param context
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   336
	 *            if the context is not null, only get threads that are children
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   337
	 *            of this context. otherwise get all threads.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   338
	 * @param breakpoint
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   339
	 * @return
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   340
	 */
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   341
    private Set<String> extractThreads(IBreakpointsTargetDMContext context, ICBreakpoint breakpoint) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   342
        Set<String> results = new HashSet<String>();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   343
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   344
        // Find the ancestor
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   345
        List<IExecutionDMContext[]> threads = new ArrayList<IExecutionDMContext[]>(1);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   346
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   347
        try {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   348
            // Retrieve the targets
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   349
            IDsfBreakpointExtension filterExtension = getFilterExtension(breakpoint);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   350
            IContainerDMContext[] targets = filterExtension.getTargetFilters();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   351
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   352
            // If no target is present, breakpoint applies to all.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   353
            if (targets.length == 0) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   354
                results.add("0"); //$NON-NLS-1$    
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   355
                return results;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   356
            }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   357
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   358
            // Extract the thread IDs (if there is none, we are covered)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   359
            for (IContainerDMContext ctxt : targets) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   360
                if (context == null || 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   361
                	DMContexts.isAncestorOf(ctxt, context)) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   362
                    threads.add(filterExtension.getThreadFilters(ctxt));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   363
                }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   364
            }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   365
        } catch (CoreException e1) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   366
        }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   367
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   368
        if (supportsThreads(breakpoint)) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   369
            for (IExecutionDMContext[] targetThreads : threads) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   370
                if (targetThreads != null) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   371
                    for (IExecutionDMContext thread : targetThreads) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   372
                        if (thread instanceof IMIExecutionDMContext) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   373
                        	IMIExecutionDMContext dmc = (IMIExecutionDMContext) thread;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   374
                            results.add(((Integer) dmc.getThreadId()).toString());
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   375
                        }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   376
                    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   377
                } else {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   378
                    results.add("0"); //$NON-NLS-1$    
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   379
                    break;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   380
                }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   381
            }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   382
        } else {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   383
            results.add("0"); //$NON-NLS-1$
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   384
        }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   385
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   386
        return results;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   387
    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   388
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   389
    /**
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   390
     * Indicates if the back-end supports multiple threads for
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   391
     * this type of breakpoint
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   392
     * 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   393
     * @param breakpoint
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   394
     */
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   395
    protected boolean supportsThreads(ICBreakpoint breakpoint) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   396
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   397
        return !(breakpoint instanceof ICWatchpoint);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   398
    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   399
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   400
    /**
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   401
     * @param bp
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   402
     * @return
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   403
     * @throws CoreException
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   404
     */
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   405
    private IDsfBreakpointExtension getFilterExtension(ICBreakpoint bp) throws CoreException {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   406
        return (IDsfBreakpointExtension) bp.getExtension(GDB_DEBUG_MODEL_ID, ICBreakpointExtension.class);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   407
    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   408
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   409
	public Map<String, Object> getAllBreakpointAttributes(IBreakpoint breakpoint, boolean bpManagerEnabled) throws CoreException {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   410
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   411
		assert ! dsfSession.getExecutor().isInExecutorThread();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   412
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   413
		// Check that the marker exists and retrieve its attributes.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   414
		// Due to accepted race conditions, the breakpoint marker may become
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   415
		// null while this method is being invoked. In this case throw an exception
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   416
		// and let the caller handle it.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   417
		IMarker marker = breakpoint.getMarker();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   418
		if (marker == null || !marker.exists()) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   419
			throw new CoreException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED,
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   420
					"Breakpoint marker does not exist", null));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   421
		}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   422
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   423
		// Suppress cast warning: platform is still on Java 1.3
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   424
		@SuppressWarnings("unchecked")
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   425
		Map<String, Object> attributes = marker.getAttributes();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   426
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   427
		Map<String, Object>	targetAttrs = convertAttributes(attributes);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   428
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   429
		// Determine breakpoint type.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   430
        if (breakpoint instanceof ICWatchpoint)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   431
            targetAttrs.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.WATCHPOINT);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   432
        else if (breakpoint instanceof ICLineBreakpoint)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   433
            targetAttrs.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   434
        else {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   435
	    	// catchpoint?
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   436
	    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   437
        	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   438
		// Adjust for "skip-all"
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   439
		if (!bpManagerEnabled) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   440
		    targetAttrs.put(MIBreakpoints.IS_ENABLED, false);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   441
		}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   442
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   443
		Set<String> threads = extractThreads(null, (ICBreakpoint) breakpoint);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   444
        targetAttrs.put(ATTR_THREAD_FILTER, threads);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   445
        
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   446
        return targetAttrs;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   447
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   448
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   449
	public boolean canUpdateAttributes(IBreakpoint bp, IBreakpointsTargetDMContext context, Map<String, Object> attrDelta) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   450
		boolean yesWeCan;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   451
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   452
		if (attrDelta.containsKey(MIBreakpoints.IS_ENABLED) && bp != null) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   453
			// GDB special: 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   454
			// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=261082
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   455
			//
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   456
			Map<String, Object> delta = new HashMap<String, Object>(attrDelta);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   457
			
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   458
			delta.remove(MIBreakpoints.IS_ENABLED);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   459
			
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   460
			yesWeCan = canUpdateAttributes(null, delta);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   461
			
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   462
			if (yesWeCan) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   463
				// other attribute change indicates we can. Now check the ENABLE.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   464
				// if the breakpoint is already installed in the "context" (a process), 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   465
				// we can. Otherwise no.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   466
				ITargetBreakpointInfo[] targetBPs = breakpointsMediator.getTargetBreakpoints(context, bp);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   467
				yesWeCan = targetBPs != null && targetBPs.length > 0;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   468
			}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   469
		}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   470
		else 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   471
			yesWeCan = canUpdateAttributes(null, attrDelta);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   472
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   473
		return yesWeCan;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   474
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   475
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   476
    private void addBreakpointProblemMarker(final ICBreakpoint breakpoint, final String description, final int severity) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   477
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   478
        new Job("Add Breakpoint Problem Marker") { //$NON-NLS-1$
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   479
        	{setSystem(true); };
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   480
        	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   481
            @Override
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   482
            protected IStatus run(IProgressMonitor monitor) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   483
                
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   484
                if (breakpoint instanceof ICLineBreakpoint) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   485
                	// If we have already have a problem marker on this breakpoint
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   486
                	// we should remove it first.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   487
                    IMarker marker = fBreakpointMarkerProblems.remove(breakpoint);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   488
                    if (marker != null) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   489
                        try {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   490
                            marker.delete();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   491
                        } catch (CoreException e) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   492
                        }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   493
                	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   494
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   495
                    ICLineBreakpoint lineBreakpoint = (ICLineBreakpoint) breakpoint;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   496
                    try {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   497
                        // Locate the workspace resource via the breakpoint marker
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   498
                        IMarker breakpoint_marker = lineBreakpoint.getMarker();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   499
                        IResource resource = breakpoint_marker.getResource();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   500
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   501
                        // Add a problem marker to the resource
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   502
                        IMarker problem_marker = resource.createMarker(BreakpointProblems.BREAKPOINT_PROBLEM_MARKER_ID);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   503
                        int line_number = lineBreakpoint.getLineNumber();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   504
                        problem_marker.setAttribute(IMarker.LOCATION,    String.valueOf(line_number));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   505
                        problem_marker.setAttribute(IMarker.MESSAGE,     description);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   506
                        problem_marker.setAttribute(IMarker.SEVERITY,    severity);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   507
                        problem_marker.setAttribute(IMarker.LINE_NUMBER, line_number);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   508
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   509
                        // And save the baby
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   510
                        fBreakpointMarkerProblems.put(breakpoint, problem_marker);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   511
                    } catch (CoreException e) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   512
                    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   513
                }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   514
                return Status.OK_STATUS;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   515
            }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   516
        }.schedule();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   517
    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   518
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   519
    private void removeBreakpointProblemMarker(final ICBreakpoint breakpoint) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   520
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   521
        new Job("Remove Breakpoint Problem Marker") { //$NON-NLS-1$
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   522
        	{setSystem(true); };
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   523
            @Override
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   524
            protected IStatus run(IProgressMonitor monitor) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   525
                
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   526
                IMarker marker = fBreakpointMarkerProblems.remove(breakpoint);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   527
                if (marker != null) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   528
                    try {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   529
                        marker.delete();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   530
                    } catch (CoreException e) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   531
                    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   532
                }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   533
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   534
                return Status.OK_STATUS;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   535
            }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   536
        }.schedule();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   537
    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   538
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   539
    /**
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   540
     */
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   541
    private void clearBreakpointProblemMarkers()
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   542
    {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   543
        new Job("Clear Breakpoint problem markers") { //$NON-NLS-1$
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   544
        	{ setSystem(true); };
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   545
            @Override
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   546
            protected IStatus run(IProgressMonitor monitor) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   547
                for (IMarker marker : fBreakpointMarkerProblems.values()) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   548
                	if (marker != null) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   549
                		try {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   550
							marker.delete();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   551
						} catch (CoreException e) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   552
						}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   553
                	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   554
                }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   555
                fBreakpointMarkerProblems.clear();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   556
                return Status.OK_STATUS;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   557
            }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   558
        }.schedule();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   559
    }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   560
}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents:
diff changeset
   561