cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/BreakpointsMediator.java
author l12wang
Tue, 24 Nov 2009 19:18:36 -0600
changeset 118 f0e9dc42b68e
parent 117 09f3d307f081
child 122 d94b9ba55bed
permissions -rw-r--r--
Don't log failure in setting breakpoint as error in Error Log view.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     1
/*******************************************************************************
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     2
 * Copyright (c) 2007, 2008 Wind River and others.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     3
 * All rights reserved. This program and the accompanying materials
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     4
 * are made available under the terms of the Eclipse Public License v1.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     5
 * which accompanies this distribution, and is available at
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     6
 * http://www.eclipse.org/legal/epl-v10.html
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     7
 *
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     8
 * Contributors:
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     9
 *     Wind River - Initial API and implementation
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: 112
diff changeset
    10
 *     Ericsson   - Low-level breakpoints integration
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
    11
 *     Nokia - refactored to work for both GDB and EDC.  Nov. 2009.
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    12
 *******************************************************************************/
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    13
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    14
package org.eclipse.cdt.dsf.debug.service;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    15
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    16
import java.util.ArrayList;
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: 112
diff changeset
    17
import java.util.Collection;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    18
import java.util.HashMap;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    19
import java.util.HashSet;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    20
import java.util.Hashtable;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    21
import java.util.LinkedList;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    22
import java.util.List;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    23
import java.util.Map;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    24
import java.util.Set;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    25
import java.util.concurrent.RejectedExecutionException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    26
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    27
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    28
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    29
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    30
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    31
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    32
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    33
import org.eclipse.cdt.dsf.datamodel.IDMContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    34
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    35
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    36
import org.eclipse.cdt.dsf.internal.DsfPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    37
import org.eclipse.cdt.dsf.service.AbstractDsfService;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    38
import org.eclipse.cdt.dsf.service.DsfSession;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    39
import org.eclipse.core.resources.IMarkerDelta;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    40
import org.eclipse.core.runtime.CoreException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    41
import org.eclipse.core.runtime.IProgressMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    42
import org.eclipse.core.runtime.IStatus;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    43
import org.eclipse.core.runtime.Status;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    44
import org.eclipse.core.runtime.jobs.Job;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    45
import org.eclipse.debug.core.DebugPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    46
import org.eclipse.debug.core.IBreakpointManager;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    47
import org.eclipse.debug.core.IBreakpointManagerListener;
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    48
import org.eclipse.debug.core.IBreakpointsListener;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    49
import org.eclipse.debug.core.model.IBreakpoint;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    50
import org.osgi.framework.BundleContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    51
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    52
/**
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: 112
diff changeset
    53
 * see these bugs for design of this service.<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: 112
diff changeset
    54
 * - https://bugs.eclipse.org/bugs/show_bug.cgi?id=218557
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
    55
 * - https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    56
 */
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    57
public class BreakpointsMediator extends AbstractDsfService implements IBreakpointManagerListener, IBreakpointsListener
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    58
{
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    59
	public enum BreakpointEventType {ADDED, REMOVED, MODIFIED}; 	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    60
	
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    61
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    62
     * The attribute translator that this service will use to map the platform
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    63
     * breakpoint attributes to the corresponding target attributes, and vice
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    64
     * versa.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    65
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    66
    private IBreakpointAttributeTranslator fAttributeTranslator;
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    67
    
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    68
    /**
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    69
     * If the attribute translator implements the {@link IBreakpointAttributeTranslatorExtension},
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    70
     * this field will be valid, otherwise it is null.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    71
     */
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    72
    private IBreakpointAttributeTranslatorExtension fAttributeTranslator2;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    73
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    74
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    75
     * DSF Debug service for creating breakpoints.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    76
     */
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: 112
diff changeset
    77
    IBreakpoints fBreakpointsService;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    78
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    79
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    80
     * Platform breakpoint manager
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    81
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    82
    IBreakpointManager fBreakpointManager;
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    83
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    84
    /**
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    85
     * Object describing the information about a single target breakpoint  
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    86
     * corresponding to specific platform breakpoint and breakpoint target 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    87
     * context.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    88
     * 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    89
     * @since 2.1
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    90
     */
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    91
    public interface ITargetBreakpointInfo {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    92
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    93
    	/**
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    94
    	 * Returns the breakpoint attributes as returned by the attribute translator.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    95
    	 */
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    96
    	public Map<String, Object> getAttributes();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    97
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    98
    	/**
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
    99
    	 * Returns the target breakpoint context.  May be <code>null</code> if the 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   100
    	 * breakpoint failed to install on target. 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   101
    	 */
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   102
    	public IBreakpointDMContext getTargetBreakpoint();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   103
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   104
    	/**
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   105
    	 * Returns the status result of the last breakpoint operation (install/remove). 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   106
    	 */
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   107
    	public IStatus getStatus();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   108
    }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   109
    
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   110
    private static class TargetBP implements ITargetBreakpointInfo {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   111
    	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   112
    	private Map<String, Object> fAttributes;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   113
    	private IBreakpointDMContext fTargetBPContext;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   114
    	private IStatus fStatus;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   115
    	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   116
    	public TargetBP(Map<String, Object> attrs) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   117
    		fAttributes = attrs;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   118
    	}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   119
    	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   120
    	public Map<String, Object> getAttributes() {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   121
			return fAttributes;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   122
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   123
    	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   124
    	public IBreakpointDMContext getTargetBreakpoint() {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   125
			return fTargetBPContext;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   126
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   127
    	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   128
    	public IStatus getStatus() {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   129
			return fStatus;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   130
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   131
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   132
		public void setTargetBreakpoint(IBreakpointDMContext fTargetBPContext) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   133
			this.fTargetBPContext = fTargetBPContext;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   134
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   135
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   136
		public void setStatus(IStatus status) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   137
			this.fStatus = status;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   138
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   139
    }
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   140
    
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: 112
diff changeset
   141
	private class PlatformBreakpointInfo {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   142
		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: 112
diff changeset
   143
		boolean 			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: 112
diff changeset
   144
		// All attributes available from UI, including standard and extended ones.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   145
		Map<String, Object>	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: 112
diff changeset
   146
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   147
		public PlatformBreakpointInfo(IBreakpoint bp, boolean enabled, Map<String, Object> 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: 112
diff changeset
   148
			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: 112
diff changeset
   149
			breakpoint = 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: 112
diff changeset
   150
			this.enabled = 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: 112
diff changeset
   151
			this.attributes = 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: 112
diff changeset
   152
		}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
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: 112
diff changeset
   154
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   155
	///////////////////////////////////////////////////////////////////////////
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   156
    // Breakpoints tracking
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   157
    ///////////////////////////////////////////////////////////////////////////
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   158
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   159
    /**
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   160
     * Holds the set of platform breakpoints with their breakpoint information 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   161
     * structures, per context (i.e. each platform breakpoint is
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   162
     * replicated for each execution context).
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   163
     * - Context entry added/removed on start/stopTrackingBreakpoints()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   164
     * - Augmented on breakpointAdded()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   165
     * - Modified on breakpointChanged()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   166
     * - Diminished on breakpointRemoved()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   167
     */
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   168
	private Map<IBreakpointsTargetDMContext, Map<IBreakpoint, List<TargetBP>>> fPlatformBPs = 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   169
		new HashMap<IBreakpointsTargetDMContext, Map<IBreakpoint, List<TargetBP>>>();
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   170
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: 112
diff changeset
   171
	/**
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   172
	 * Holds platform breakpoints with all their attributes (standard ones and
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   173
	 * extended ones) from UI. This will be used to check what attributes have
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   174
	 * changed for a breakpoint when the breakpoint is changed. The map is <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: 112
diff changeset
   175
	 * 1. augmented in doBreakpointsAdded(); <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: 112
diff changeset
   176
	 * 2. updated in breakpointsChanged(); <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: 112
diff changeset
   177
	 * 3. diminished in breakpointsRemoved();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
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: 112
diff changeset
   179
	private Map<IBreakpoint, Map<String, Object>> fBreakpointAttributes = 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   180
		new HashMap<IBreakpoint, 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: 112
diff changeset
   181
	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   182
	private static class PendingEventInfo {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   183
		PendingEventInfo(BreakpointEventType eventType, PlatformBreakpointInfo bpInfo,
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   184
				Collection<IBreakpointsTargetDMContext> bpsTargetDmc, 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: 112
diff changeset
   185
			fEventType = 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: 112
diff changeset
   186
			fBPInfo = bpInfo;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   187
			fBPTargetContexts = bpsTargetDmc;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   188
			fRequestMonitor = 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: 112
diff changeset
   189
			fAttributeDelta = 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: 112
diff changeset
   190
		}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   191
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   192
		public PendingEventInfo(BreakpointEventType eventType, Collection<IBreakpointsTargetDMContext> updateContexts,
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   193
				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: 112
diff changeset
   194
			fEventType = 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: 112
diff changeset
   195
			fBPTargetContexts = updateContexts;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   196
			fAttributeDelta = 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: 112
diff changeset
   197
			fRequestMonitor = 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: 112
diff changeset
   198
			fBPInfo = 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: 112
diff changeset
   199
		}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   200
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   201
		PlatformBreakpointInfo fBPInfo;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   202
		RequestMonitor fRequestMonitor;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   203
		BreakpointEventType fEventType;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   204
		Collection<IBreakpointsTargetDMContext> fBPTargetContexts;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   205
		Map<String, Object>	fAttributeDelta;	// for change event only
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   206
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   207
	
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   208
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   209
     * Due to the very asynchronous nature of DSF, a new breakpoint request can
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   210
     * pop up at any time before an ongoing one is completed. The following set
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   211
     * is used to store requests until the ongoing operation completes.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   212
     */
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   213
	private Set<IBreakpoint> fRunningEvents    = new HashSet<IBreakpoint>();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   214
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   215
	private Map<IBreakpoint, LinkedList<PendingEventInfo>> fPendingEvents = 
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: 112
diff changeset
   216
			new HashMap<IBreakpoint, LinkedList<PendingEventInfo>>();
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   217
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   218
    ///////////////////////////////////////////////////////////////////////////
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   219
    // AbstractDsfService    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   220
    ///////////////////////////////////////////////////////////////////////////
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   221
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   222
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   223
	 * The service constructor
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   224
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   225
	 * @param session
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   226
	 * @param debugModelId
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   227
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   228
	public BreakpointsMediator(DsfSession session, IBreakpointAttributeTranslator attributeTranslator) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   229
        super(session);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   230
        fAttributeTranslator = attributeTranslator;
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   231
        
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   232
        fAttributeTranslator2 = null;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   233
        if (attributeTranslator instanceof IBreakpointAttributeTranslatorExtension)
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   234
        	fAttributeTranslator2 = (IBreakpointAttributeTranslatorExtension)attributeTranslator;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   235
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   236
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   237
    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   238
    public void initialize(final RequestMonitor rm) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   239
        // - Collect references for the services we interact with
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   240
        // - Register to interesting events
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   241
        // - Obtain the list of platform breakpoints   
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   242
        // - Register the service for interested parties
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   243
        super.initialize(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   244
            new RequestMonitor(getExecutor(), rm) { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   245
                @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   246
                protected void handleSuccess() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   247
                    doInitialize(rm);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   248
                }});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   249
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   250
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   251
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   252
     * Asynchronous service initialization 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   253
     * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   254
     * @param requestMonitor
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   255
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   256
    private void doInitialize(RequestMonitor rm) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   257
    	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   258
    	// Get the services references
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: 112
diff changeset
   259
        fBreakpointsService  = getServicesTracker().getService(IBreakpoints.class);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   260
        fBreakpointManager = DebugPlugin.getDefault().getBreakpointManager();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   261
        fAttributeTranslator.initialize(this);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   262
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   263
        // Register to the useful events
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   264
        fBreakpointManager.addBreakpointListener(this);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   265
        fBreakpointManager.addBreakpointManagerListener( this );
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   266
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   267
        // Register this service
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   268
        register(new String[] { BreakpointsMediator.class.getName() },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   269
				 new Hashtable<String, String>());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   270
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   271
        rm.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   272
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   273
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   274
    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   275
    public void shutdown(final RequestMonitor rm) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   276
        // - Un-register the service
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   277
        // - Stop listening to events
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   278
        // - Remove the breakpoints installed by this service
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   279
        // 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   280
        //  Since we are shutting down, there is no overwhelming need
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   281
        //  to keep the maps coherent...
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   282
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   283
        // Stop accepting requests and events
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   284
    	unregister();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   285
        fBreakpointManager.removeBreakpointListener(this);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   286
        fBreakpointManager.removeBreakpointManagerListener( this );
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   287
        fAttributeTranslator.dispose();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   288
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   289
        // Cleanup the breakpoints that are still installed by the service.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   290
        // Use a counting monitor which will call mom to complete the shutdown
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   291
        // after the breakpoints are un-installed (successfully or not).
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   292
        CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), rm) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   293
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   294
            protected void handleCompleted() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   295
                BreakpointsMediator.super.shutdown(rm);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   296
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   297
        };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   298
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   299
        // We have to make a copy of the fPlatformBPs keys because uninstallBreakpoints()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   300
        // modifies the map as it walks through it.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   301
        List<IBreakpointsTargetDMContext> platformBPKeysCopy = new ArrayList<IBreakpointsTargetDMContext>(fPlatformBPs.size());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   302
        platformBPKeysCopy.addAll(0, fPlatformBPs.keySet());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   303
        for (IBreakpointsTargetDMContext dmc : platformBPKeysCopy) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   304
            stopTrackingBreakpoints(dmc, countingRm);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   305
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   306
        countingRm.setDoneCount(platformBPKeysCopy.size());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   307
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   308
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   309
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   310
    protected BundleContext getBundleContext() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   311
        return DsfPlugin.getBundleContext();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   312
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   313
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   314
    ///////////////////////////////////////////////////////////////////////////
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   315
    // IBreakpointsManager
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   316
    ///////////////////////////////////////////////////////////////////////////
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   317
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   318
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   319
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   320
     * Install and begin tracking breakpoints for given context.  The service 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   321
     * will keep installing new breakpoints that appear in the IDE for this 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   322
     * context until {@link #uninstallBreakpoints(IDMContext)} is called for that
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   323
     * context.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   324
     * @param dmc Context to start tracking breakpoints for.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   325
     * @param rm Completion callback.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   326
     */
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   327
    public void startTrackingBreakpoints(final IBreakpointsTargetDMContext dmc, final RequestMonitor rm) {
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   328
        // - Augment the maps with the new execution context
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   329
        // - Install the platform breakpoints on the selected target
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   330
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   331
        // Make sure a mapping for this execution context does not already exist
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   332
		Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   333
		if (platformBPs != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   334
            rm.setStatus(new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, INTERNAL_ERROR, "Context already initialized", null)); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   335
            rm.done();            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   336
            return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   337
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   338
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   339
        // Create entries in the breakpoint tables for the new context. These entries should only
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   340
        // be removed when this service stops tracking breakpoints for the given context.
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   341
        fPlatformBPs.put(dmc, new HashMap<IBreakpoint, List<TargetBP>>());
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   342
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   343
        // Install the platform breakpoints (stored in fPlatformBPs) on the target.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   344
		// We need to use a background thread for this operation because we are 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   345
		// accessing the resources system to retrieve the breakpoint attributes.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   346
		// Accessing the resources system potentially requires using global locks.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   347
		// Also we will be calling IBreakpointAttributeTranslator which is prohibited
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   348
		// from being called on the session executor thread.
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   349
		new Job("Install initial breakpoint list.") { //$NON-NLS-1$
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   350
            { setSystem(true); }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   351
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   352
			// Get the stored breakpoints from the platform BreakpointManager
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   353
			// and install them on the target
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   354
        	@Override
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   355
            protected IStatus run(IProgressMonitor monitor) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   356
        		doBreakpointsAdded(DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(), dmc, rm);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   357
                return Status.OK_STATUS;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   358
            }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   359
        }.schedule();    
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   360
    }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   361
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   362
    public void stopTrackingBreakpoints(final IBreakpointsTargetDMContext dmc, final RequestMonitor rm) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   363
        // - Remove the target breakpoints for the given execution context
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   364
        // - Update the maps
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   365
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   366
    	// Remove the breakpoints for given DMC from the internal maps.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   367
        Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc);
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: 112
diff changeset
   368
        if (platformBPs == null || platformBPs.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: 112
diff changeset
   369
            rm.setStatus(new Status(IStatus.INFO /* NOT error */, DsfPlugin.PLUGIN_ID, INTERNAL_ERROR, "Breakpoints not installed for given context", null)); //$NON-NLS-1$
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   370
            rm.done();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   371
            return;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   372
        }
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: 112
diff changeset
   373
        
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   374
        // Just remove the IBreakpoints installed for the "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: 112
diff changeset
   375
        final IBreakpoint[] bps = platformBPs.keySet().toArray(new IBreakpoint[platformBPs.size()]);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   376
        
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   377
		new Job("Uninstall target breakpoints list.") { //$NON-NLS-1$
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   378
            { setSystem(true); }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   379
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   380
			// Get the stored breakpoints from the platform BreakpointManager
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   381
			// and install them on the target
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   382
        	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   383
            protected IStatus run(IProgressMonitor monitor) {
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: 112
diff changeset
   384
        		doBreakpointsRemoved(bps, dmc, rm);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   385
                return Status.OK_STATUS;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   386
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   387
        }.schedule();    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   388
    }
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   389
    
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   390
    /**
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   391
     * Find target breakpoints installed in the given context that are resolved 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   392
     * from the given platform breakpoint.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   393
     *  
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   394
     * @param dmc - context
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   395
     * @param platformBp - platform breakpoint
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   396
     * @return array of target breakpoints. 
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   397
     */
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   398
    public ITargetBreakpointInfo[] getTargetBreakpoints(IBreakpointsTargetDMContext dmc, IBreakpoint platformBp) {
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: 112
diff changeset
   399
    	assert 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: 112
diff changeset
   400
    	
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   401
        Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   402
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   403
        if (platformBPs != null)
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   404
        {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   405
        	List<TargetBP> bpInfo = platformBPs.get(platformBp);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   406
            if (bpInfo != null) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   407
            	return bpInfo.toArray(new ITargetBreakpointInfo[bpInfo.size()]);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   408
            }
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   409
        }
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   410
        return null;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   411
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   412
    
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   413
    /**
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   414
     * Find the platform breakpoint that's mapped to the given target breakpoint.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   415
     * 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   416
     * @param dmc - context of the target breakpoint, can be null.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   417
     * @param bp - target breakpoint
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   418
     * @return platform breakpoint. null if not found. 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   419
     */
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   420
    public IBreakpoint getPlatformBreakpoint(IBreakpointsTargetDMContext dmc, IBreakpointDMContext bp) {
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: 112
diff changeset
   421
    	assert 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: 112
diff changeset
   422
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   423
    	for (IBreakpointsTargetDMContext bpContext : fPlatformBPs.keySet()) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   424
    		if (dmc != null && !dmc.equals(bpContext))
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   425
    			continue;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   426
    		
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   427
	        Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(bpContext);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   428
	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   429
	        if (platformBPs != null && platformBPs.size() > 0)
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   430
	        {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   431
	            for(Map.Entry<IBreakpoint, List<TargetBP>> e: platformBPs.entrySet())
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   432
	            {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   433
	                // Stop at the first occurrence
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   434
	            	for (TargetBP tbp : e.getValue())
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   435
	            		if(tbp.getTargetBreakpoint().equals(bp))
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   436
	            			return e.getKey();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   437
	            }    
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   438
	        }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   439
    	}
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   440
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   441
    	return null;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   442
    }
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   443
    
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   444
    ///////////////////////////////////////////////////////////////////////////
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   445
    // Back-end interface functions
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   446
    ///////////////////////////////////////////////////////////////////////////
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   447
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   448
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   449
	 * Install a new platform breakpoint on the back-end. A platform breakpoint
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   450
	 * can resolve into multiple back-end breakpoints, e.g. when threads are taken
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   451
	 * into account.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   452
	 *  
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   453
	 * @param dmc
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   454
	 * @param breakpoint
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   455
	 * @param attrsList - list of attribute map, each mapping to a potential target BP.
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   456
	 * @param rm
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   457
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   458
	private void installBreakpoint(IBreakpointsTargetDMContext dmc, final IBreakpoint breakpoint,
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   459
			final List<Map<String, Object>> attrsList, final DataRequestMonitor<List<TargetBP>> rm)
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   460
	{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   461
    	// Retrieve the set of breakpoints for this context
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   462
        final Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   463
        assert platformBPs != null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   464
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   465
        // Ensure the breakpoint is not already installed
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   466
        assert !platformBPs.containsKey(breakpoint);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   467
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   468
        final ArrayList<TargetBP> targetBPsAttempted = new ArrayList<TargetBP>(attrsList.size());
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   469
        for (int i = 0; i < attrsList.size(); i++) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   470
        	targetBPsAttempted.add(new TargetBP(attrsList.get(i)));
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   471
        }
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   472
        
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   473
        final ArrayList<TargetBP> targetBPsInstalled = new ArrayList<TargetBP>(attrsList.size());
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   474
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   475
        // Update the breakpoint status when all back-end breakpoints have been installed
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   476
    	final CountingRequestMonitor installRM = new CountingRequestMonitor(getExecutor(), rm) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   477
			@Override
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   478
			protected void handleCompleted() {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   479
				// Store successful targetBPs with the platform breakpoint
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   480
				if (targetBPsInstalled.size() > 0)
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   481
					platformBPs.put(breakpoint, targetBPsInstalled);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   482
				
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   483
				// Store all targetBPs, success or failure, in the rm.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   484
				rm.setData(targetBPsAttempted);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   485
		        rm.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   486
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   487
		};
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   488
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   489
        // A back-end breakpoint needs to be installed for each specified attributes map.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   490
		installRM.setDoneCount(attrsList.size());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   491
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   492
		// Install the back-end breakpoint(s)
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   493
		for (int _i = 0; _i < attrsList.size(); _i++) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   494
			final int i = _i;
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: 112
diff changeset
   495
            fBreakpointsService.insertBreakpoint(
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   496
                dmc, attrsList.get(i), 
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   497
				new DataRequestMonitor<IBreakpointDMContext>(getExecutor(), installRM) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   498
				@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   499
                protected void handleCompleted() {
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   500
					TargetBP targetBP = targetBPsAttempted.get(i);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   501
                    if (isSuccess()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   502
						// Add the breakpoint back-end mapping
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   503
                    	targetBP.setTargetBreakpoint(getData());
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   504
                    	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   505
                    	targetBPsInstalled.add(targetBP);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   506
					} 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   507
                    targetBP.setStatus(getStatus());
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   508
                    
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   509
					installRM.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   510
                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   511
            });
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   512
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   513
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   514
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   515
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   516
     * Un-install an individual breakpoint on the back-end. For one platform
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   517
     * breakpoint, there could be multiple corresponding back-end breakpoints.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   518
     * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   519
     * @param dmc
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   520
     * @param breakpoint
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   521
     * @param drm
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   522
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   523
    private void uninstallBreakpoint(final IBreakpointsTargetDMContext dmc, final IBreakpoint breakpoint, 
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   524
        final DataRequestMonitor<List<TargetBP>> drm)
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   525
    {
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   526
		// Remove the back-end breakpoints
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   527
		final Map<IBreakpoint, List<TargetBP>> platformBPs = fPlatformBPs.get(dmc);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   528
        if (platformBPs == null) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   529
            drm.setStatus(new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid breakpoint", null)); //$NON-NLS-1$
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   530
            drm.done();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   531
            return;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   532
        }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   533
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   534
        final List<TargetBP> bpList = platformBPs.get(breakpoint);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   535
        assert bpList != null;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   536
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   537
        // Only try to remove those targetBPs that are successfully installed.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   538
        
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   539
  		// Remove completion monitor
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   540
    	final CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), drm) {
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   541
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   542
			protected void handleCompleted() {
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   543
				platformBPs.remove(breakpoint);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   544
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   545
		        // Complete the request monitor.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   546
		        drm.setData(bpList);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   547
		        drm.done();
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   548
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   549
		};
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   550
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   551
        int count = 0;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   552
        for (int i = 0; i < bpList.size(); i++) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   553
        	final TargetBP bp = bpList.get(i);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   554
        	if (bp.getTargetBreakpoint() != null) {
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: 112
diff changeset
   555
        		fBreakpointsService.removeBreakpoint(
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   556
        				bp.getTargetBreakpoint(), 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   557
        				new RequestMonitor(getExecutor(), countingRm) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   558
        					@Override
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   559
        					protected void handleCompleted() {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   560
        				        bp.setStatus(getStatus());
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   561
        				        if (isSuccess()) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   562
            						bp.setTargetBreakpoint(null);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   563
        				        } 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   564
        				        countingRm.done();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   565
        					}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   566
        				});
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   567
        		count++;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   568
        	} else {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   569
        		bp.setStatus(Status.OK_STATUS);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   570
        	}
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   571
        }
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   572
        countingRm.setDoneCount(count);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   573
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   574
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   575
    ///////////////////////////////////////////////////////////////////////////
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   576
    // IBreakpointManagerListener implementation
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   577
    ///////////////////////////////////////////////////////////////////////////
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   578
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   579
	public void breakpointManagerEnablementChanged(boolean enabled) {
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: 112
diff changeset
   580
		// do nothing. breakpointsChanged() will be called to handle the change.
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   581
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   582
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   583
	@ThreadSafe
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   584
	public void breakpointsAdded(final IBreakpoint[] bps) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   585
		doBreakpointsAdded(bps, null, null);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   586
	}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   587
	
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: 112
diff changeset
   588
	protected void doBreakpointsAdded(final IBreakpoint[] bps, final IBreakpointsTargetDMContext bpsTargetDmc, 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: 112
diff changeset
   589
		// Collect attributes (which will access system 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: 112
diff changeset
   590
		// in non DSF dispatch 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: 112
diff changeset
   591
		//
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   592
		final PlatformBreakpointInfo[] bpsInfo = collectBreakpointsInfo(bps);
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   593
		
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   594
		// Nothing to do
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: 112
diff changeset
   595
		if (bpsInfo.length == 0) {
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   596
			if (rm != null) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   597
				rm.done();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   598
			}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   599
			return;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   600
		}
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: 112
diff changeset
   601
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   602
		try {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   603
            getExecutor().execute(new DsfRunnable() {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   604
				public void run() {
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: 112
diff changeset
   605
					Collection<IBreakpointsTargetDMContext> dmcs = new ArrayList<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: 112
diff changeset
   606
					if (bpsTargetDmc == 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: 112
diff changeset
   607
						dmcs.addAll(fPlatformBPs.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: 112
diff changeset
   608
					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: 112
diff changeset
   609
						dmcs.add(bpsTargetDmc);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   610
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: 112
diff changeset
   611
					doBreakpointsAddedInExecutor(bpsInfo, dmcs, rm);
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   612
				}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   613
			});
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   614
		} catch (RejectedExecutionException e) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   615
			IStatus status = new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Request for monitor: '" + toString() + "' resulted in a rejected execution exception.", e);//$NON-NLS-1$ //$NON-NLS-2$
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   616
			if (rm != null) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   617
				rm.setStatus(status);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   618
				rm.done();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   619
			} else {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   620
				DsfPlugin.getDefault().getLog().log(status); 
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   621
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   622
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   623
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   624
	
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: 112
diff changeset
   625
	/**
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   626
	 * Collect breakpoint info. This method must not be called in DSF dispatch 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: 112
diff changeset
   627
	 * @param bps
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   628
	 * @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: 112
diff changeset
   629
	 */
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   630
    private PlatformBreakpointInfo[] collectBreakpointsInfo(IBreakpoint[] bps) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   631
		List<PlatformBreakpointInfo> bpsInfo = new ArrayList<PlatformBreakpointInfo>(bps.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: 112
diff changeset
   632
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   633
		for (IBreakpoint bp : bps) {
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   634
			if (bp.getMarker() == null)
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   635
				continue;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   636
			
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: 112
diff changeset
   637
			if (fAttributeTranslator.supportsBreakpoint(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: 112
diff changeset
   638
				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: 112
diff changeset
   639
	        		Map<String, Object> attrs = fAttributeTranslator2.getAllBreakpointAttributes(bp, fBreakpointManager.isEnabled());
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   640
	        		boolean enabled = bp.isEnabled() && fBreakpointManager.isEnabled();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   641
					bpsInfo.add(new PlatformBreakpointInfo(bp, enabled, attrs));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   642
				} 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: 112
diff changeset
   643
					DsfPlugin.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: 112
diff changeset
   644
				}
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   645
			}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   646
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   647
		
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: 112
diff changeset
   648
		return bpsInfo.toArray(new PlatformBreakpointInfo[bpsInfo.size()]);
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   649
	}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   650
118
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   651
	protected void doBreakpointsAddedInExecutor(PlatformBreakpointInfo[] bpsInfo, Collection<IBreakpointsTargetDMContext> bpTargetDMCs, final RequestMonitor rm) {
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: 112
diff changeset
   652
		final Map<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>> eventBPs =  
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   653
			new HashMap<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>>(bpsInfo.length, 1);
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   654
		
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: 112
diff changeset
   655
        CountingRequestMonitor processPendingCountingRm = new CountingRequestMonitor(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: 112
diff changeset
   656
                @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: 112
diff changeset
   657
                protected void handleCompleted() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   658
                	processPendingRequests();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   659
                	fireUpdateBreakpointsStatus(eventBPs, BreakpointEventType.ADDED);
118
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   660
                	if (rm != null)
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   661
                		// don't call this if "rm" is null as this will 
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   662
                		// log errors if any and pack Eclipse error 
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   663
                		// log view with errors useless to user. 
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   664
                		super.handleCompleted();
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: 112
diff changeset
   665
                }
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   666
            };	            	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   667
        int processPendingCountingRmCount = 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: 112
diff changeset
   668
    	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   669
    	for (final PlatformBreakpointInfo bpinfo : 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: 112
diff changeset
   670
    		final Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]> targetBPs = 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   671
    			new HashMap<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>(fPlatformBPs.size(), 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: 112
diff changeset
   672
    		eventBPs.put(bpinfo.breakpoint, targetBPs);	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   673
    	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   674
			// Remember the new attributes of the bp in our global buffer,
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   675
			// even if we cannot or fail to install the 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: 112
diff changeset
   676
			fBreakpointAttributes.put(bpinfo.breakpoint, bpinfo.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: 112
diff changeset
   677
    		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   678
			if (fRunningEvents.contains(bpinfo.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: 112
diff changeset
   679
				PendingEventInfo pendingEvent = new PendingEventInfo(BreakpointEventType.ADDED, bpinfo, bpTargetDMCs, processPendingCountingRm);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   680
				processPendingCountingRmCount++;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   681
				updatePendingRequest(bpinfo.breakpoint, pendingEvent);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   682
				continue;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   683
			}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   684
			
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   685
			processPendingCountingRmCount++;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   686
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   687
            // Mark the breakpoint as being updated and go
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   688
            fRunningEvents.add(bpinfo.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: 112
diff changeset
   689
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   690
    		final CountingRequestMonitor bpTargetsCountingRm = new CountingRequestMonitor(getExecutor(), processPendingCountingRm) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   691
				@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: 112
diff changeset
   692
				protected void handleCompleted() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   693
                	// Indicate that the running event has completed
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   694
                	fRunningEvents.remove(bpinfo.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: 112
diff changeset
   695
                	super.handleCompleted();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   696
				}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   697
    		};
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   698
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   699
			int bpTargetsCountingRmCount = 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: 112
diff changeset
   700
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   701
			// Install the breakpoint in all the execution contexts
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   702
			for (final IBreakpointsTargetDMContext dmc : bpTargetDMCs) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   703
				
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   704
                // Now ask lower level to set the 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: 112
diff changeset
   705
				//
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   706
				// if the breakpoint is disabled, ask back-end if it can set (and manage)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   707
				// disabled breakpoint. If not, just 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: 112
diff changeset
   708
				//
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   709
				if (! bpinfo.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: 112
diff changeset
   710
					Map<String, Object> attr = new HashMap<String, Object>(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: 112
diff changeset
   711
					attr.put(IBreakpoint.ENABLED, Boolean.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: 112
diff changeset
   712
					Map<String, Object> targetEnablementAttr = fAttributeTranslator2.convertAttributes(attr);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   713
					if (! fAttributeTranslator2.canUpdateAttributes(bpinfo.breakpoint, dmc, targetEnablementAttr)) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   714
						// bail out. Continue with the next dmc & 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: 112
diff changeset
   715
						continue;
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   716
					}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   717
				}
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: 112
diff changeset
   718
            	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   719
				// Now do the real work.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   720
				//
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   721
				fAttributeTranslator2.resolveBreakpoint(dmc, bpinfo.breakpoint, bpinfo.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: 112
diff changeset
   722
						new DataRequestMonitor<List<Map<String,Object>>>(getExecutor(), bpTargetsCountingRm){
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   723
							@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: 112
diff changeset
   724
							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: 112
diff changeset
   725
								installBreakpoint(
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   726
							    		dmc, bpinfo.breakpoint, 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: 112
diff changeset
   727
							    		new DataRequestMonitor<List<TargetBP>>(getExecutor(), bpTargetsCountingRm) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   728
							    			@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: 112
diff changeset
   729
											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: 112
diff changeset
   730
							    				targetBPs.put(dmc, getData().toArray(new ITargetBreakpointInfo[getData().size()]));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   731
							    				super.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: 112
diff changeset
   732
							    			};
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   733
							    		});
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   734
							}});
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   735
				
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   736
				bpTargetsCountingRmCount++;
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   737
			}
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: 112
diff changeset
   738
			
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   739
			bpTargetsCountingRm.setDoneCount(bpTargetsCountingRmCount);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   740
    	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   741
    	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   742
    	processPendingCountingRm.setDoneCount(processPendingCountingRmCount);	            	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   743
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   744
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   745
	/*
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   746
	 * Note this method must not be called in DSF dispatch 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: 112
diff changeset
   747
	 * 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   748
	 * @param bps
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   749
	 * @param deltas
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   750
	 */
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   751
	public void breakpointsChanged(IBreakpoint[] bps, IMarkerDelta[] deltas) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   752
		if (fAttributeTranslator2 == 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: 112
diff changeset
   753
			return;
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   754
		
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: 112
diff changeset
   755
		final PlatformBreakpointInfo[] bpsInfo = collectBreakpointsInfo(bps);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   756
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   757
		if (bpsInfo.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: 112
diff changeset
   758
			return; // nothing to do
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   759
		
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   760
		try {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   761
	        getExecutor().execute( new DsfRunnable() { 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   762
	            public void run() {
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: 112
diff changeset
   763
	            	Map<String, Object> tmp = new HashMap<String, Object>(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: 112
diff changeset
   764
					tmp.put(IBreakpoint.ENABLED, 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: 112
diff changeset
   765
					final String targetEnablementKey = fAttributeTranslator2.convertAttributes(tmp).keySet().iterator().next();
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   766
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: 112
diff changeset
   767
					for (PlatformBreakpointInfo bpinfo : 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: 112
diff changeset
   768
						/*
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   769
						 * We cannot depend on "deltas" for attribute change.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   770
						 * For instance, delta can be null when extended
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   771
						 * attributes (e.g. breakpoint thread filter for GDB)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   772
						 * are changed.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   773
						 */
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   774
						Map<String, Object> newAttrs = bpinfo.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: 112
diff changeset
   775
						Map<String, Object> oldAttrs = fBreakpointAttributes.get(bpinfo.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: 112
diff changeset
   776
						
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   777
						// remember the new 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: 112
diff changeset
   778
						fBreakpointAttributes.put(bpinfo.breakpoint, newAttrs);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   779
						
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   780
						final Map<String, Object> attrDelta = getAttributesDelta(oldAttrs, newAttrs);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   781
						if (attrDelta.size() == 0) 
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   782
							continue;
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: 112
diff changeset
   783
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   784
						final List<IBreakpointsTargetDMContext> reinstallContexts = new ArrayList<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: 112
diff changeset
   785
						
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   786
						List<IBreakpointsTargetDMContext> updateContexts = new ArrayList<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: 112
diff changeset
   787
						
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   788
						// Now change the breakpoint for each known 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: 112
diff changeset
   789
						//
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   790
						for (final IBreakpointsTargetDMContext btContext : fPlatformBPs.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: 112
diff changeset
   791
							
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   792
							if (! fAttributeTranslator2.canUpdateAttributes(bpinfo.breakpoint, btContext, 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: 112
diff changeset
   793
								// backend cannot handle at least one of the platform BP attribute change,
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   794
								// we'll handle the re-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: 112
diff changeset
   795
								reinstallContexts.add(btContext);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   796
							}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   797
							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: 112
diff changeset
   798
								// Backend claims it can handle the attributes change, let it do 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: 112
diff changeset
   799
								updateContexts.add(btContext);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   800
							}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   801
							
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   802
						}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   803
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   804
						final PlatformBreakpointInfo[] oneBPInfo = new PlatformBreakpointInfo[] {bpinfo};
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   805
						IBreakpoint[] oneBP = new IBreakpoint[] {bpinfo.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: 112
diff changeset
   806
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   807
						if (reinstallContexts.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: 112
diff changeset
   808
							// Check if it's only enablement change (user click enable/disable 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   809
							// button or "Skip all breakpoints" button), which is common operation.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   810
							//
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   811
							if (attrDelta.size() == 1 && attrDelta.containsKey(targetEnablementKey)) { // only enablement changed.	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   812
								if (bpinfo.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: 112
diff changeset
   813
									// change from disable to enable. Install the 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: 112
diff changeset
   814
									doBreakpointsAddedInExecutor(oneBPInfo, reinstallContexts, 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: 112
diff changeset
   815
								}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   816
								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: 112
diff changeset
   817
									// change from enable to disable. Remove the 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: 112
diff changeset
   818
									doBreakpointsRemovedInExecutor(oneBP,  reinstallContexts, 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: 112
diff changeset
   819
								}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   820
							}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   821
							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: 112
diff changeset
   822
								doBreakpointsRemovedInExecutor(oneBP, reinstallContexts, new RequestMonitor(getExecutor(), 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: 112
diff changeset
   823
									// What should we do if removal of some or all targetBP 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: 112
diff changeset
   824
									// Go on with the installation of new targetBPs and let clients (i.e. AttributeTranslators) 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   825
									// handle the errors.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   826
									@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: 112
diff changeset
   827
									protected void handleCompleted() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   828
										doBreakpointsAddedInExecutor(oneBPInfo, reinstallContexts, 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: 112
diff changeset
   829
									}});
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   830
							}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   831
						}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   832
						
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   833
						if (updateContexts.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: 112
diff changeset
   834
							modifyTargetBreakpoints(bpinfo.breakpoint, updateContexts, attrDelta);
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   835
	            	}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   836
	            }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   837
	        });
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   838
	    } catch (RejectedExecutionException e) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   839
			DsfPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Request for monitor: '" + toString() + "' resulted in a rejected execution exception.", e)); //$NON-NLS-1$ //$NON-NLS-2$
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   840
	    }
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: 112
diff changeset
   841
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   842
	}
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   843
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   844
	/**
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: 112
diff changeset
   845
	 * For the given platform BP, ask the backend to modify all its target BPs
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   846
	 * with the given attribute change. <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: 112
diff changeset
   847
	 * This must be called in DSF executor thread.
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   848
	 * 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   849
	 * @param bp
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: 112
diff changeset
   850
	 * @param updateContexts 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   851
	 * 			  target contexts in which to do the modification.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   852
	 * @param targetAttrDelta
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   853
	 *            target-recognizable attribute(s) with new values.
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   854
	 */
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: 112
diff changeset
   855
	private void modifyTargetBreakpoints(final IBreakpoint bp, Collection<IBreakpointsTargetDMContext> updateContexts, Map<String, Object> targetAttrDelta) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   856
		// If the breakpoint is currently being updated, queue the request and exit
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   857
    	if (fRunningEvents.contains(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: 112
diff changeset
   858
    		PendingEventInfo pendingEvent = new PendingEventInfo(BreakpointEventType.MODIFIED, updateContexts, targetAttrDelta);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   859
    		updatePendingRequest(bp, pendingEvent);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   860
			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: 112
diff changeset
   861
    	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   862
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   863
    	CountingRequestMonitor modifyTargetBPCRM = new CountingRequestMonitor(getExecutor(), 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: 112
diff changeset
   864
			@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: 112
diff changeset
   865
			protected void handleCompleted() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   866
				fRunningEvents.remove(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: 112
diff changeset
   867
			}};
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   868
			
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   869
    	int targetBPCount = 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: 112
diff changeset
   870
    	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   871
    	fRunningEvents.add(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: 112
diff changeset
   872
    	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   873
		for (IBreakpointsTargetDMContext context : updateContexts) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   874
			List<TargetBP> targetBPs = fPlatformBPs.get(context).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: 112
diff changeset
   875
			if (targetBPs != 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: 112
diff changeset
   876
				for (TargetBP tbp : targetBPs) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   877
					// this must be an installed 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: 112
diff changeset
   878
					assert (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: 112
diff changeset
   879
					
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   880
					targetBPCount++;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   881
					fBreakpointsService.updateBreakpoint(tbp.getTargetBreakpoint(), targetAttrDelta, modifyTargetBPCRM);
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   882
				}
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: 112
diff changeset
   883
			}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   884
		}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   885
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   886
		modifyTargetBPCRM.setDoneCount(targetBPCount);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   887
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   888
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   889
	public void breakpointsRemoved(final IBreakpoint[] bps, IMarkerDelta delta[]) {
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: 112
diff changeset
   890
		getExecutor().execute(new DsfRunnable() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   891
			public void run() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   892
				for (IBreakpoint bp : bps)
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   893
					fBreakpointAttributes.remove(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: 112
diff changeset
   894
			}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   895
		});
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   896
		
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   897
		doBreakpointsRemoved(bps, null, null);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   898
	}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   899
	
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: 112
diff changeset
   900
	protected void doBreakpointsRemoved(final IBreakpoint[] bps, final IBreakpointsTargetDMContext bpsTargetDmc, final RequestMonitor rm) {
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   901
	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   902
		final List<IBreakpoint> bpCandidates = new ArrayList<IBreakpoint>();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   903
		
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   904
		for (int i = 0; i < bps.length; i++) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   905
			IBreakpoint bp = bps[i];
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   906
			
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   907
			if (fAttributeTranslator.supportsBreakpoint(bp)) {
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: 112
diff changeset
   908
				bpCandidates.add(bp);
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   909
			}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   910
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   911
		
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   912
		if (bpCandidates.isEmpty()) { // nothing to do
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   913
			if (rm != null)
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   914
				rm.done();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   915
			return;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   916
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   917
		
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   918
		try {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   919
	        getExecutor().execute(new DsfRunnable() {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   920
	        	public void run() {
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: 112
diff changeset
   921
					Collection<IBreakpointsTargetDMContext> contexts = new ArrayList<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: 112
diff changeset
   922
					if (bpsTargetDmc == 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: 112
diff changeset
   923
						contexts.addAll(fPlatformBPs.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: 112
diff changeset
   924
					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: 112
diff changeset
   925
						contexts.add(bpsTargetDmc);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   926
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: 112
diff changeset
   927
					doBreakpointsRemovedInExecutor(bpCandidates.toArray(new IBreakpoint[bpCandidates.size()]), contexts, rm);
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   928
	        	}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   929
	        });
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   930
        } catch (RejectedExecutionException e) {
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: 112
diff changeset
   931
			IStatus status = new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   932
					"Request for monitor: '" + toString() + "' resulted in a rejected execution exception.", e);//$NON-NLS-1$ //$NON-NLS-2$
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   933
			if (rm != null) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   934
				rm.setStatus(status);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   935
				rm.done();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   936
			} else {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   937
				DsfPlugin.getDefault().getLog().log(status); 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   938
			}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   939
        }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   940
	}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
   941
	
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: 112
diff changeset
   942
	protected void doBreakpointsRemovedInExecutor(IBreakpoint[] bpCandidates, 
118
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   943
			Collection<IBreakpointsTargetDMContext> targetContexts, final RequestMonitor rm) {
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: 112
diff changeset
   944
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   945
		final Map<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>> eventBPs =  
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   946
			new HashMap<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>>(bpCandidates.length, 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: 112
diff changeset
   947
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   948
		CountingRequestMonitor processPendingCountingRm = new CountingRequestMonitor(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: 112
diff changeset
   949
			@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: 112
diff changeset
   950
			protected void handleCompleted() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   951
				processPendingRequests();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   952
            	fireUpdateBreakpointsStatus(eventBPs, BreakpointEventType.REMOVED);
118
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   953
            	if (rm != null)
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   954
            		// don't call this if "rm" is null as this will 
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   955
            		// log errors if any and pack Eclipse error 
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   956
            		// log view with errors useless to user. 
f0e9dc42b68e Don't log failure in setting breakpoint as error in Error Log view.
l12wang
parents: 117
diff changeset
   957
            		super.handleCompleted();
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: 112
diff changeset
   958
			}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   959
		};
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   960
		int processPendingCountingRmCount = 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: 112
diff changeset
   961
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   962
		for (final IBreakpoint breakpoint : bpCandidates) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   963
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   964
			// If the breakpoint is currently being updated, queue the request and exit
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   965
        	if (fRunningEvents.contains(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: 112
diff changeset
   966
        		PendingEventInfo pendingEvent = new PendingEventInfo(BreakpointEventType.REMOVED, null, targetContexts, processPendingCountingRm);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   967
                processPendingCountingRmCount++;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   968
        		updatePendingRequest(breakpoint, pendingEvent);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   969
				continue;	// handle next 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: 112
diff changeset
   970
        	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   971
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   972
            processPendingCountingRmCount++;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   973
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   974
            final Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]> targetBPs = 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   975
    			new HashMap<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>(fPlatformBPs.size(), 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: 112
diff changeset
   976
    		eventBPs.put(breakpoint, targetBPs);	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   977
	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   978
    		CountingRequestMonitor bpTargetsCountingRM = new CountingRequestMonitor(getExecutor(), processPendingCountingRm) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   979
				@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: 112
diff changeset
   980
				protected void handleCompleted() {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   981
					// Indicate that the running event has completed
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   982
                	fRunningEvents.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: 112
diff changeset
   983
                	super.handleCompleted();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   984
				}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   985
			};
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   986
            
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   987
			int bpTargetsCoutingRMCount = 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: 112
diff changeset
   988
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   989
        	// Mark the breakpoint as being updated and go
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   990
            fRunningEvents.add(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: 112
diff changeset
   991
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   992
    		// Remove the breakpoint in all the execution contexts
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   993
    		for (final IBreakpointsTargetDMContext dmc : targetContexts) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   994
    			
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   995
    			if (fPlatformBPs.get(dmc).containsKey(breakpoint)) {		// there are targetBPs 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: 112
diff changeset
   996
    				// now do time-consuming part of the work.
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   997
    				
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   998
    				uninstallBreakpoint(
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
   999
    						dmc, 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: 112
diff changeset
  1000
    						new DataRequestMonitor<List<TargetBP>>(getExecutor(), bpTargetsCountingRM) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1001
				    			@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: 112
diff changeset
  1002
								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: 112
diff changeset
  1003
				    				targetBPs.put(dmc, getData().toArray(new ITargetBreakpointInfo[getData().size()]));
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1004
				    				super.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: 112
diff changeset
  1005
				    			};
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1006
    						});
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1007
    				bpTargetsCoutingRMCount++;
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1008
    			} 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: 112
diff changeset
  1009
    				// Breakpoint not installed for given context, 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: 112
diff changeset
  1010
    			}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1011
    		}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1012
    		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1013
    		bpTargetsCountingRM.setDoneCount(bpTargetsCoutingRMCount);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1014
		}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1015
		
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1016
		processPendingCountingRm.setDoneCount(processPendingCountingRmCount);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1017
	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1018
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1019
	private void updatePendingRequest(IBreakpoint breakpoint, PendingEventInfo pendingEvent) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1020
		LinkedList<PendingEventInfo> pendingEventsList = fPendingEvents.get(breakpoint);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1021
		if (pendingEventsList == null) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1022
			pendingEventsList = new LinkedList<PendingEventInfo>();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1023
			fPendingEvents.put(breakpoint, pendingEventsList);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1024
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1025
		if (pendingEventsList.size() > 0 &&
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1026
				pendingEventsList.getLast().fEventType == BreakpointEventType.MODIFIED) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1027
			pendingEventsList.removeLast();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1028
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1029
		pendingEventsList.add(pendingEvent);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1030
	}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1031
	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1032
	private void processPendingRequests() {
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: 112
diff changeset
  1033
		/*
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1034
		 * This will process only first pending request for each 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: 112
diff changeset
  1035
		 * whose RequestMonitor (see "processPendingCountingRm" in such methods as 
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1036
		 * doBreakpointsRemovedInExecutor()) will invoke this method again.   
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1037
		 */
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1038
		if (fPendingEvents.isEmpty()) return;  // Nothing to do
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1039
		
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: 112
diff changeset
  1040
		// Make a copy to avoid ConcurrentModificationException
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1041
		// as we are deleting element in the loop.
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1042
		Set<IBreakpoint> bpsInPendingEvents = new HashSet<IBreakpoint>(fPendingEvents.keySet()); 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1043
		for (IBreakpoint bp : bpsInPendingEvents) {
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: 112
diff changeset
  1044
	    	if (! fRunningEvents.contains(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: 112
diff changeset
  1045
				LinkedList<PendingEventInfo> eventInfoList = fPendingEvents.get(bp);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1046
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: 112
diff changeset
  1047
		    	// Process the first pending request for 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: 112
diff changeset
  1048
		   		PendingEventInfo eventInfo = eventInfoList.removeFirst();
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1049
	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1050
				if (eventInfoList.isEmpty())
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1051
					fPendingEvents.remove(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: 112
diff changeset
  1052
	
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1053
				switch (eventInfo.fEventType) {
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1054
				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: 112
diff changeset
  1055
					doBreakpointsAddedInExecutor(new PlatformBreakpointInfo[] {eventInfo.fBPInfo}, eventInfo.fBPTargetContexts, eventInfo.fRequestMonitor);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1056
					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: 112
diff changeset
  1057
				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: 112
diff changeset
  1058
					modifyTargetBreakpoints(bp, eventInfo.fBPTargetContexts, eventInfo.fAttributeDelta);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1059
					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: 112
diff changeset
  1060
				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: 112
diff changeset
  1061
					doBreakpointsRemovedInExecutor(new IBreakpoint[]{bp}, eventInfo.fBPTargetContexts, eventInfo.fRequestMonitor);
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1062
					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: 112
diff changeset
  1063
				}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1064
	    	}
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1065
		}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1066
	}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1067
	
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1068
	private void fireUpdateBreakpointsStatus(final Map<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>> eventBPs, final BreakpointEventType eventType) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1069
        // Update breakpoint status
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1070
        new Job("Breakpoint status update") { //$NON-NLS-1$
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1071
            { setSystem(true); }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1072
            @Override
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1073
            protected IStatus run(IProgressMonitor monitor) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1074
            	for (IBreakpoint bp : eventBPs.keySet()) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1075
            		fAttributeTranslator.updateBreakpointStatus(bp);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1076
            	}
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1077
                
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1078
                if (fAttributeTranslator2 != null) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1079
                	fAttributeTranslator2.updateBreakpointsStatus(eventBPs, eventType);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1080
                }
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: 112
diff changeset
  1081
                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: 112
diff changeset
  1082
                	for (IBreakpoint bp : eventBPs.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: 112
diff changeset
  1083
                		fAttributeTranslator.updateBreakpointStatus(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: 112
diff changeset
  1084
                	}
09f3d307f081 Overhauled BreakpointsMediator to support both EDC and GDB properly. See Eclipse bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=292468
l12wang
parents: 112
diff changeset
  1085
                	
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1086
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1087
                return Status.OK_STATUS;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1088
            };
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1089
        }.schedule();
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1090
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1091
	}
112
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1092
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1093
    /**
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1094
     * Determine the set of modified attributes.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1095
     * 
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1096
     * @param oldAttributes old map of attributes.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1097
     * @param newAttributes new map of attributes.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1098
     * @return new and changed attribute in the new map. May be empty indicating the two maps are equal.
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1099
     */
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1100
    private Map<String, Object> getAttributesDelta(Map<String, Object> oldAttributes, Map<String, Object> newAttributes) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1101
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1102
        Map<String, Object> delta = new HashMap<String,Object>();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1103
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1104
        Set<String> oldKeySet = oldAttributes.keySet();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1105
        Set<String> newKeySet = newAttributes.keySet();
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1106
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1107
        Set<String> commonKeys  = new HashSet<String>(newKeySet); commonKeys.retainAll(oldKeySet);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1108
        Set<String> addedKeys   = new HashSet<String>(newKeySet); addedKeys.removeAll(oldKeySet);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1109
        Set<String> removedKeys = new HashSet<String>(oldKeySet); removedKeys.removeAll(newKeySet);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1110
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1111
        // Add the modified attributes
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1112
        for (String key : commonKeys) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1113
            if (!(oldAttributes.get(key).equals(newAttributes.get(key))))
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1114
                delta.put(key, newAttributes.get(key));
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1115
        }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1116
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1117
        // Add the new attributes
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1118
        for (String key : addedKeys) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1119
            delta.put(key, newAttributes.get(key));
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1120
        }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1121
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1122
        // Remove the deleted attributes
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1123
        for (String key : removedKeys) {
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1124
            delta.put(key, null);
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1125
        }
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1126
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1127
        return delta;
6b1088abccf8 Reworked BreakpointsMediator. See Eclipse bug 292468.
l12wang
parents: 104
diff changeset
  1128
    }
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1129
}