diff options
author | John Cortell | 2010-02-19 23:47:04 +0000 |
---|---|---|
committer | John Cortell | 2010-02-19 23:47:04 +0000 |
commit | adde620eafa829ee451130ca680f3dfa8cfb9314 (patch) | |
tree | 1366d2b195c394c9a464bf23d974e78bb2e1f440 /debug/org.eclipse.cdt.debug.core | |
parent | 63934dce7a50b32272e2911a391458e89e97deeb (diff) | |
download | org.eclipse.cdt-adde620eafa829ee451130ca680f3dfa8cfb9314.tar.gz org.eclipse.cdt-adde620eafa829ee451130ca680f3dfa8cfb9314.tar.xz org.eclipse.cdt-adde620eafa829ee451130ca680f3dfa8cfb9314.zip |
[248606] Add support for toggling watchpoints in the variables and expressions views.
Diffstat (limited to 'debug/org.eclipse.cdt.debug.core')
4 files changed, 140 insertions, 2 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF index b7fb53ca013..1da89911883 100644 --- a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF @@ -16,7 +16,7 @@ Export-Package: org.eclipse.cdt.debug.core, org.eclipse.cdt.debug.core.executables, org.eclipse.cdt.debug.core.model, org.eclipse.cdt.debug.core.sourcelookup, - org.eclipse.cdt.debug.internal.core;x-internal:=true, + org.eclipse.cdt.debug.internal.core;x-friends:="org.eclipse.cdt.dsf.gdb.ui", org.eclipse.cdt.debug.internal.core.breakpoints;x-friends:="org.eclipse.cdt.debug.edc", org.eclipse.cdt.debug.internal.core.executables;x-internal:=true, org.eclipse.cdt.debug.internal.core.model;x-internal:=true, diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CRequest.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CRequest.java new file mode 100644 index 00000000000..7b5c299743a --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CRequest.java @@ -0,0 +1,48 @@ +package org.eclipse.cdt.debug.internal.core; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.core.IRequest; + +/** + * Base class for request objects used in asynchronous calls in base CDT + * (non-DSF). This is used in base features that delegate a task to a backend + * that is either DSF or CDI. Since DSF is highly asynchronous, the base logic + * has to use asynchronous APIs. + */ +public class CRequest implements IRequest { + private IStatus fStatus; + private boolean fCanceled; + /* + * @see org.eclipse.debug.core.IRequest#cancel() + */ + public void cancel() { + fCanceled= true; + } + + /* + * @see org.eclipse.debug.core.IRequest#done() + */ + public void done() { + } + + /* + * @see org.eclipse.debug.core.IRequest#getStatus() + */ + public IStatus getStatus() { + return fStatus; + } + + /* + * @see org.eclipse.debug.core.IRequest#isCanceled() + */ + public boolean isCanceled() { + return fCanceled; + } + + /* + * @see org.eclipse.debug.core.IRequest#setStatus(org.eclipse.core.runtime.IStatus) + */ + public void setStatus(IStatus status) { + fStatus= status; + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.java new file mode 100644 index 00000000000..2f62f3e6fbe --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2010 Freescale Semiconductor 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: + * Freescale Semiconductor - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.core; + +import org.eclipse.debug.core.IRequest; + +/** + * View model types for which the "Add Watchpoint (C/C++)" action is applicable + * should implement this interface. The action is a popupMenu/objectContribution + * that targets this type. + * + * <p> + * Note that the action is particular to CBreakpoint, and not all CDT debugger + * solutions use CBreakpoint. + */ +public interface ICWatchpointTarget { + + /** IRequest object used in the asynchronous method {@link ICWatchpointTarget#getSize()} */ + interface GetSizeRequest extends IRequest { + int getSize(); + void setSize(int size); + }; + + interface CanCreateWatchpointRequest extends IRequest { + boolean getCanCreate(); + void setCanCreate(boolean value); + }; + + /** + * Determine if a watchpoint can be set on the element. The result does not + * guarantee an attempt to set such a watchpoint will succeed. This is + * merely a way to find out whether it makes sense to even attempt it. For + * example, an expression that's not an l-value should return false. The + * implementation may choose to go even further and check that the target + * supports watchpoints (at all or at that particular location). + */ + void canSetWatchpoint(CanCreateWatchpointRequest request); + + /** + * Get the expression or the name of the variable + */ + String getExpression(); + + /** + * Asynchronous method to retrieve the size of the variable/expression, in + * bytes. + * + * @param request + * the async request object + */ + void getSize(GetSizeRequest request); +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java index 08782f074e8..13a80a1773b 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java @@ -33,6 +33,7 @@ import org.eclipse.cdt.debug.core.model.ICDebugElementStatus; import org.eclipse.cdt.debug.core.model.ICType; import org.eclipse.cdt.debug.core.model.ICValue; import org.eclipse.cdt.debug.internal.core.CSettingsManager; +import org.eclipse.cdt.debug.internal.core.ICWatchpointTarget; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; @@ -72,7 +73,7 @@ class VariableEventListener implements ICDIEventListener { /** * Represents a variable in the CDI model. */ -public abstract class CVariable extends AbstractCVariable implements ICDIEventListener { +public abstract class CVariable extends AbstractCVariable implements ICDIEventListener, ICWatchpointTarget { interface IInternalVariable { IInternalVariable createShadow( int start, int length ) throws DebugException; @@ -878,4 +879,33 @@ public abstract class CVariable extends AbstractCVariable implements ICDIEventLi // even if the initial setup fails, we still want the complete creation to be successful } } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#getExpression() + */ + public String getExpression() { + try { + return getExpressionString(); + } catch (DebugException e) { + return ""; //$NON-NLS-1$ + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#getSize() + */ + public void getSize(ICWatchpointTarget.GetSizeRequest request) { + // CDI has synchronous APIs, so this is easy... + request.setSize(sizeof()); + request.done(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#canCreateWatchpoint(org.eclipse.cdt.debug.internal.core.IWatchpointTarget.CanCreateWatchpointRequest) + */ + public void canSetWatchpoint(ICWatchpointTarget.CanCreateWatchpointRequest request) { + // CDI has synchronous APIs, so this is easy... + request.setCanCreate(sizeof() > 0); + request.done(); + } } |