1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 292468 - [breakpoints] Cannot update breakpoint status properly with current IBreakpointAttributeTranslator

This commit is contained in:
Pawel Piech 2010-01-08 18:45:28 +00:00
parent 3e8602621d
commit 3c3cbab6e7
4 changed files with 1350 additions and 9 deletions

View file

@ -48,7 +48,21 @@ import org.eclipse.debug.core.model.IBreakpoint;
import org.osgi.framework.BundleContext;
/**
* Breakpoints mediator is a DSF service which synchronizes breakpoints in the
* IDE and breakpoints in the debugger. The IDE breakpoints are managed by the
* {@link IBreakpointManager} while the debugger breakpoints are accessed
* through the {@link IBreakpoints} service.
* <p>
* This class is not intended to be extended by clients. Instead clients should
* implement the {@link IBreakpointAttributeTranslator} interface which is used
* to translate breakpoint attributes between the IDE and debugger breakpoints.
* <p>
* Note: This breakpoint mediator implementation has been superseded by a more
* powerful {@link BreakpointsMediator2} implementation.
*
* @since 1.0
* @see IBreakpointAttributeTranslator
* @see BreakpointsMediator2
*/
public class BreakpointsMediator extends AbstractDsfService implements IBreakpointManagerListener, IBreakpointListener
{

View file

@ -13,29 +13,62 @@ package org.eclipse.cdt.dsf.debug.service;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.model.IBreakpoint;
/**
* Breakpoint attribute translator interface
* Breakpoint attribute translator is used by the {@link BreakpointsMediator}
* to map IDE breakpoint attributes to debugger breakpoint attributes.
* <p>
* Note: The attribute translator is expected to access IDE breakpoint manager
* objects which are synchronized using the resource system. Therefore all the
* translator methods are called using background threads. When the attribute
* translator needs to access DSF services, it needs to schedule a runnable using
* the DSF session executable.
*
* @see BreakpointMediator
* @since 1.0
*/
@ThreadSafeAndProhibitedFromDsfExecutor("")
public interface IBreakpointAttributeTranslator {
public void initialize(BreakpointsMediator mediator);
public void dispose();
public List<Map<String, Object>> getBreakpointAttributes(IBreakpoint breakpoint, boolean bpManagerEnabled) throws CoreException;
public boolean canUpdateAttributes(IBreakpointDMContext bp, Map<String, Object> delta);
/**
* Initializes the translator. This method is called by the breakpoint
* mediator service, when the mediator service is initialized.
*/
@ConfinedToDsfExecutor("")
public void initialize(BreakpointsMediator mediator);
/**
* Disposes the translator. Also called by the mediator upon service
* shutdown.
*/
@ConfinedToDsfExecutor("")
public void dispose();
/**
* Returns whether the given IDE breakpoint is supported by this debugger.
*/
public boolean supportsBreakpoint(IBreakpoint bp);
/**
* Returns the target breakpoint attributes for the given IDE breakpoint.
*/
public List<Map<String, Object>> getBreakpointAttributes(IBreakpoint breakpoint, boolean bpManagerEnabled) throws CoreException;
/**
* Based on the given change in IDE breakpoint attributes, this method returns
* whether the given target breakpoint can be modified using
* {@link IBreakpoints#updateBreakpoint(IBreakpointDMContext, Map, org.eclipse.cdt.dsf.concurrent.RequestMonitor)}
* method.
*/
public boolean canUpdateAttributes(IBreakpointDMContext bp, Map<String, Object> delta);
/**
* Notifies the translator to update the given IDE breakpoint's status.
*/
public void updateBreakpointStatus(IBreakpoint bp);
}

View file

@ -0,0 +1,154 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
* Nokia - enhanced to work for both GDB and EDC. Nov. 2009.
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.service;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2.BreakpointEventType;
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2.ITargetBreakpointInfo;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.model.IBreakpoint;
/**
* Breakpoint attribute translator is used by the {@link BreakpointsMediator2}
* to map IDE breakpoint attributes to debugger breakpoint attributes.
* <p>
* Note: The attribute translator is expected to access IDE breakpoint manager
* objects which are synchronized using the resource system. It may also need to
* access DSF services using the DSF session executor. Therefore, the
* implementation needs to pay special attention to the synchronization
* annotations on each method of the interface.
*
* @see BreakpointMediator
* @since 2.1
*/
public interface IBreakpointAttributeTranslator2 {
/**
* Initializes the translator. This method is called by the breakpoint
* mediator service, when the mediator service is initialized.
*/
@ConfinedToDsfExecutor("")
public void initialize(BreakpointsMediator2 mediator);
/**
* Disposes the translator. Also called by the mediator upon service
* shutdown.
*/
@ConfinedToDsfExecutor("")
public void dispose();
/**
* Returns whether the given IDE breakpoint is supported by this debugger.
*/
@ThreadSafeAndProhibitedFromDsfExecutor("")
public boolean supportsBreakpoint(IBreakpoint bp);
/**
* Resolve the breakpoint in given context. A platform BP may be mapped to
* ont or more target BPs, e.g. a breakpoint in an in-line function may be
* mapped to several target BPs, or a thread-specific BP may be mapped to
* several target BPs each of which is for one thread. This method will get
* the list of attribute maps each of which corresponds to one target BP.
* <p>
* This method is and must be called in DSF execution thread.
*
* @param context
* - a IBreakpointsTargetDMContext object (which could be a
* process or a loaded module) in which we locate target BPs for
* the platform BP. Cannot be null.
* @param breakpoint
* - platform breakpoint.
* @param bpAttributes
* - all attributes of the breakpoint, usually output from
* {@link #getAllBreakpointAttributes(IBreakpoint, boolean)}.
* @param drm
* - on completion of the request, the DataRequestMonitor
* contains one or more attribute maps each of which
* corresponding to one target breakpoint.
* @throws CoreException
*/
@ConfinedToDsfExecutor("")
public void resolveBreakpoint(IBreakpointsTargetDMContext context, IBreakpoint breakpoint,
Map<String, Object> bpAttributes, DataRequestMonitor<List<Map<String, Object>>> drm);
/**
* Get all platform defined attributes for a breakpoint plus all attributes
* defined by any breakpoint extension such as ICBreakpointExtension in CDT.
* In other words, get all attributes available from UI.
* <p>
* The attributes returned are independent of runtime context (process,
* module, etc), whereas attributes from
* {@link #resolveBreakpoint(IBreakpointsTargetDMContext, IBreakpoint, Map, DataRequestMonitor)}
* are context sensitive.
* <p>
* Note this method must not be called in DSF dispatch thread because we are
* accessing the resources system to retrieve the breakpoint attributes.
* Accessing the resources system potentially requires using global locks.
*
* @param platformBP
* @param bpManagerEnabled
* @return list of target (debugger implementation) recognizable attributes.
* @throws CoreException
*/
@ThreadSafeAndProhibitedFromDsfExecutor("")
public Map<String, Object> getAllBreakpointAttributes(IBreakpoint platformBP, boolean bpManagerEnabled) throws CoreException;
/**
* Convert platform breakpoint attributes to target attributes. This usually
* involves changing attributes keys to target recognizable ones. For
* instance, GDB integration has its own breakpoint attribute keys.
* <p>
* This method overlaps somewhat with the {@link #resolveBreakpoint}
* method. However, this method is currently only used by the mediator in
* conjunction with the {@link #canUpdateAttributes} method.
*
* @param platformBPAttr
* @return
*/
@ThreadSafe
public Map<String, Object> convertAttributes(Map<String, Object> platformBPAttr);
/**
* Update platform about breakpoint status change, e.g. breakpoint installed on target successfully or breakpoint
* removed from target successfully.
* <p>
* Note this method is not and must not be called in DSF dispatch thread.
*
* @param bpsInfo
* @param eventType
*/
@ThreadSafeAndProhibitedFromDsfExecutor("")
public void updateBreakpointsStatus(Map<IBreakpoint, Map<IBreakpointsTargetDMContext, ITargetBreakpointInfo[]>> bpsInfo, BreakpointEventType eventType);
/**
* This is enhanced version of
* {@link #canUpdateAttributes(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext, Map)}
* in that this API gives more context parameters so that client can make
* decision on a finer granularity when needed.
* <p>
* This will be called in DSF dispatch thread.
*
* @param bp platform breakpoint.
* @param context
* @param attributes target-recognizable attributes.
* @return false as long as one of the attributes cannot be updated by client, otherwise true.
*/
@ConfinedToDsfExecutor("")
public boolean canUpdateAttributes(IBreakpoint bp, IBreakpointsTargetDMContext context, Map<String, Object> attributes);
}