Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 248606 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-14 / +13 lines)
Lines 724-729 Link Here
724
         </action>
724
         </action>
725
      </objectContribution>
725
      </objectContribution>
726
      <objectContribution
726
      <objectContribution
727
            objectClass="org.eclipse.cdt.debug.internal.core.ICWatchpointTarget"
728
            id="org.eclipse.cdt.debug.ui.WatchpointActions">
729
         <action
730
               class="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnVariableActionDelegate"
731
               enablesFor="1"
732
               icon="icons/elcl16/watchpoint_co.gif"
733
               id="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnVariableActionDelegate"
734
               label="%AddWatchpoint.label"
735
               menubarPath="additions"
736
               tooltip="%AddWatchpoint.tooltip">
737
         </action>
738
      </objectContribution>
739
      <objectContribution
727
            objectClass="org.eclipse.cdt.core.model.IVariable"
740
            objectClass="org.eclipse.cdt.core.model.IVariable"
728
            id="org.eclipse.cdt.debug.ui.WatchpointActions">
741
            id="org.eclipse.cdt.debug.ui.WatchpointActions">
729
         <action
742
         <action
Lines 808-827 Link Here
808
                  class="org.eclipse.cdt.debug.core.model.ICVariable">
821
                  class="org.eclipse.cdt.debug.core.model.ICVariable">
809
            </selection>
822
            </selection>
810
         </action>
823
         </action>
811
         <action
812
               class="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnVariableActionDelegate"
813
               enablesFor="1"
814
               icon="icons/elcl16/watchpoint_co.gif"
815
               id="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnVariableActionDelegate"
816
               label="%AddWatchpoint.label"
817
               menubarPath="additions"
818
               tooltip="%AddWatchpoint.tooltip">
819
               <enablement>
820
                  <pluginState
821
                     value="activated"
822
                     id="org.eclipse.cdt.debug.ui"/>
823
               </enablement>
824
         </action>
825
      </viewerContribution>
824
      </viewerContribution>
826
      <viewerContribution
825
      <viewerContribution
827
            targetID="org.eclipse.debug.ui.RegisterView"
826
            targetID="org.eclipse.debug.ui.RegisterView"
(-)src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java (-44 / +102 lines)
Lines 11-94 Link Here
11
package org.eclipse.cdt.debug.internal.ui.actions;
11
package org.eclipse.cdt.debug.internal.ui.actions;
12
12
13
13
14
import org.eclipse.cdt.debug.internal.core.model.CVariable;
14
import org.eclipse.cdt.debug.internal.core.CRequest;
15
import org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointDialog;
15
import org.eclipse.cdt.debug.internal.core.ICWatchpointTarget;
16
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
16
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
17
import org.eclipse.debug.core.DebugException;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.Status;
20
import org.eclipse.debug.core.DebugPlugin;
18
import org.eclipse.jface.action.IAction;
21
import org.eclipse.jface.action.IAction;
19
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.ISelection;
20
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.jface.viewers.StructuredSelection;
21
import org.eclipse.jface.viewers.TreeSelection;
24
import org.eclipse.jface.viewers.TreeSelection;
22
import org.eclipse.jface.window.Window;
25
import org.eclipse.jface.window.Window;
23
import org.eclipse.ui.IActionDelegate;
24
import org.eclipse.ui.IObjectActionDelegate;
26
import org.eclipse.ui.IObjectActionDelegate;
25
import org.eclipse.ui.IWorkbenchPart;
27
import org.eclipse.ui.IWorkbenchPart;
28
import org.eclipse.ui.progress.WorkbenchJob;
26
29
30
/**
31
 * Invoked when user right clicks on an element in the Variables or Expressions
32
 * view and selects 'Add Watchpoint (C/C++)'
33
 */
34
public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDelegate implements IObjectActionDelegate {
27
35
28
public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDelegate {
29
30
	/**
36
	/**
31
	 * Constructor for Action1.
37
	 * The target variable/expression
38
	 */
39
	private ICWatchpointTarget fVar;
40
	
41
	/**
42
	 * Constructor
32
	 */
43
	 */
33
	public AddWatchpointOnVariableActionDelegate() {
44
	public AddWatchpointOnVariableActionDelegate() {
34
		super();
45
		super();
35
	}
46
	}
36
47
37
	/**
48
	/* (non-Javadoc)
38
	 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
49
	 * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
39
	 */
50
	 */
40
	public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
51
	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
52
		// Don't care. Our logic is agnostic to the view we're invoked from.
53
	}
41
54
42
	/**
55
	private static class GetSizeRequest extends CRequest implements ICWatchpointTarget.GetSizeRequest {
43
	 * @see IActionDelegate#run(IAction)
56
		int fSize;
57
		public int getSize() {
58
			return fSize;
59
		}
60
		public void setSize(int size) {
61
			fSize = size;
62
		}
63
	};
64
	
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointActionDelegate#run(org.eclipse.jface.action.IAction)
44
	 */
67
	 */
45
	public void run(IAction action) {
68
	public void run(IAction action) {
46
		IStructuredSelection selection = getSelection();
69
		if (fVar == null) {
47
		
48
		if (selection == null || selection.isEmpty()) {
49
			return;
70
			return;
50
		}
71
		}
51
		
72
		
52
		Object obj = ((TreeSelection)selection).getFirstElement();
73
		final String expr = fVar.getExpression();
53
		if (obj != null && obj instanceof CVariable) {
74
		if (expr == null) {
54
			CVariable var = (CVariable)obj;
75
			assert false : "how are we getting an empty expression?"; //$NON-NLS-1$
55
76
			return;
56
			String expr = "";
57
			 
58
			try {
59
				expr = var.getExpressionString();
60
			} catch (DebugException e) {}
61
			 
62
			AddWatchpointDialog dlg = new AddWatchpointDialog(CDebugUIPlugin.getActiveWorkbenchShell(), 
63
					getMemorySpaceManagement()); //$NON-NLS-1$
64
			dlg.setExpression(expr);
65
			dlg.initializeRange(false, Integer.toString(var.sizeof()));
66
			if (dlg.open() == Window.OK) {
67
				addWatchpoint(dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange());
68
			}
69
		}
77
		}
78
79
		// Getting the size of the variable/expression is an asynchronous
80
		// operation...or at least the API is (the CDI implementation reacts
81
		// synchronously)
82
		final ICWatchpointTarget.GetSizeRequest request = new GetSizeRequest() {
83
			public void done() {
84
				// Now that we have the size, put up a dialog to create the watchpoint
85
				final int size = getSize();
86
				assert size > 0 : "unexpected variale/expression size"; //$NON-NLS-1$
87
				WorkbenchJob job = new WorkbenchJob("open watchpoint dialog") { //$NON-NLS-1$
88
					@Override
89
					public IStatus runInUIThread(IProgressMonitor monitor) {
90
						AddWatchpointDialog dlg = new AddWatchpointDialog(CDebugUIPlugin.getActiveWorkbenchShell(), 
91
								getMemorySpaceManagement());
92
						dlg.setExpression(expr);
93
						dlg.initializeRange(false, Integer.toString(size));
94
						if (dlg.open() == Window.OK) {
95
							addWatchpoint(dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange());
96
						}
97
						return Status.OK_STATUS;
98
					}
99
				};
100
				job.setSystem(true);
101
				job.schedule();
102
			}
103
104
		};
105
		fVar.getSize(request);
70
	}
106
	}
71
	
107
	
108
	private class CanCreateWatchpointRequest extends CRequest implements ICWatchpointTarget.CanCreateWatchpointRequest {
109
		boolean fCanCreate;
110
		public boolean getCanCreate() {
111
			return fCanCreate;
112
		}
113
		public void setCanCreate(boolean value) {
114
			fCanCreate = value;
115
		}
116
	};
117
72
	/**
118
	/**
73
	 * @see IActionDelegate#selectionChanged(IAction, ISelection)
119
	 * Record the target variable/expression.
120
	 * 
121
	 * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
122
	 *      org.eclipse.jface.viewers.ISelection)
74
	 */
123
	 */
75
	public void selectionChanged(IAction action, ISelection selection) {
124
	public void selectionChanged(final IAction action, ISelection selection) {
76
		if (selection == null || selection.isEmpty()) {
125
		if (selection == null || selection.isEmpty()) {
77
			action.setEnabled(false);
126
			action.setEnabled(false);
78
			return;
127
			return;
79
		}
128
		}
80
		if (selection instanceof TreeSelection) {
129
		if (selection instanceof TreeSelection) {
81
			Object obj = ((TreeSelection)selection).getFirstElement();
130
			Object obj = ((TreeSelection)selection).getFirstElement();
82
			if (obj != null && obj instanceof CVariable) {
131
			fVar = (ICWatchpointTarget)DebugPlugin.getAdapter(obj, ICWatchpointTarget.class);
83
				action.setEnabled(true);
132
			if (fVar != null) {
84
			} else {
133
				final ICWatchpointTarget.CanCreateWatchpointRequest request = new CanCreateWatchpointRequest() {
85
				action.setEnabled(false);
134
					public void done() {
135
						action.setEnabled(getCanCreate());
136
					}
137
				};
138
				fVar.canSetWatchpoint(request);
139
				return;
86
			}
140
			}
141
			assert false : "action should not have been available for object " + obj; //$NON-NLS-1$
87
		}
142
		}
143
		else if (selection instanceof StructuredSelection) {
144
			// Not sure why, but sometimes we get an extraneous empty StructuredSelection. Seems harmless enough
145
			assert ((StructuredSelection)selection).getFirstElement() == null : "action installed in unexpected type of view/part"; //$NON-NLS-1$
146
		}
147
		else {
148
			assert false : "action installed in unexpected type of view/part"; //$NON-NLS-1$
149
		}
150
		action.setEnabled(false);
88
	}
151
	}
89
90
	private IStructuredSelection getSelection() {
91
		return (IStructuredSelection)getView().getViewSite().getSelectionProvider().getSelection();
92
	}
93
94
}
152
}
(-)src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/DisassemblyBackendCdi.java (-3 / +16 lines)
Lines 25-30 Link Here
25
import org.eclipse.cdt.debug.core.model.ICType;
25
import org.eclipse.cdt.debug.core.model.ICType;
26
import org.eclipse.cdt.debug.core.model.ICValue;
26
import org.eclipse.cdt.debug.core.model.ICValue;
27
import org.eclipse.cdt.debug.core.model.IDisassemblyBlock;
27
import org.eclipse.cdt.debug.core.model.IDisassemblyBlock;
28
import org.eclipse.cdt.debug.internal.core.CRequest;
28
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
29
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
29
import org.eclipse.cdt.debug.internal.core.model.CExpression;
30
import org.eclipse.cdt.debug.internal.core.model.CExpression;
30
import org.eclipse.cdt.debug.internal.core.model.CStackFrame;
31
import org.eclipse.cdt.debug.internal.core.model.CStackFrame;
Lines 179-184 Link Here
179
		fFrameLevel = 0;
180
		fFrameLevel = 0;
180
	}
181
	}
181
182
183
	private class AddressRequest extends CRequest implements IDisassemblyRetrieval.AddressRequest {
184
		private BigInteger fAddress;
185
		public BigInteger getAddress() { return fAddress; }
186
		public void setAddress(BigInteger address) { fAddress = address; }
187
	};
188
182
	/* (non-Javadoc)
189
	/* (non-Javadoc)
183
	 * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#retrieveFrameAddress(int)
190
	 * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#retrieveFrameAddress(int)
184
	 */
191
	 */
Lines 190-196 Link Here
190
				return;
197
				return;
191
			}
198
			}
192
			IStackFrame stackFrame= stackFrames[targetFrame];
199
			IStackFrame stackFrame= stackFrames[targetFrame];
193
			fDisassemblyRetrieval.asyncGetFrameAddress(stackFrame, new IDisassemblyRetrieval.AddressRequest() {
200
			fDisassemblyRetrieval.asyncGetFrameAddress(stackFrame, new AddressRequest() {
194
				@Override
201
				@Override
195
				public void done() {
202
				public void done() {
196
					fCallback.setUpdatePending(false);
203
					fCallback.setUpdatePending(false);
Lines 238-243 Link Here
238
		return fTargetFrameContext.getFrameLineNumber();		
245
		return fTargetFrameContext.getFrameLineNumber();		
239
	}
246
	}
240
247
248
	private class DisassemblyRequest extends CRequest implements IDisassemblyRetrieval.DisassemblyRequest {
249
		private IDisassemblyBlock fBlock;
250
		public IDisassemblyBlock getDisassemblyBlock() { return fBlock;	}
251
		public void setDisassemblyBlock(IDisassemblyBlock block) { fBlock = block; }
252
	};
253
	
241
	/* (non-Javadoc)
254
	/* (non-Javadoc)
242
	 * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyBackend#retrieveDisassembly(java.math.BigInteger, java.math.BigInteger, java.lang.String, boolean, boolean, boolean, int, int, int)
255
	 * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyBackend#retrieveDisassembly(java.math.BigInteger, java.math.BigInteger, java.lang.String, boolean, boolean, boolean, int, int, int)
243
	 */
256
	 */
Lines 253-259 Link Here
253
			endAddress= startAddress.add(addressLength);
266
			endAddress= startAddress.add(addressLength);
254
		}
267
		}
255
		final BigInteger finalEndAddress= endAddress;
268
		final BigInteger finalEndAddress= endAddress;
256
		final IDisassemblyRetrieval.DisassemblyRequest disassemblyRequest= new IDisassemblyRetrieval.DisassemblyRequest() {
269
		final IDisassemblyRetrieval.DisassemblyRequest disassemblyRequest= new DisassemblyRequest() {
257
			@Override
270
			@Override
258
			public void done() {
271
			public void done() {
259
				if (!isCanceled() && getDisassemblyBlock() != null) {
272
				if (!isCanceled() && getDisassemblyBlock() != null) {
Lines 365-371 Link Here
365
	public void retrieveDisassembly(String file, int lines,
378
	public void retrieveDisassembly(String file, int lines,
366
			BigInteger endAddress, final boolean mixed, final boolean showSymbols,
379
			BigInteger endAddress, final boolean mixed, final boolean showSymbols,
367
			final boolean showDisassembly) {
380
			final boolean showDisassembly) {
368
		final IDisassemblyRetrieval.DisassemblyRequest disassemblyRequest= new IDisassemblyRetrieval.DisassemblyRequest() {
381
		final IDisassemblyRetrieval.DisassemblyRequest disassemblyRequest= new DisassemblyRequest() {
369
			@Override
382
			@Override
370
			public void done() {
383
			public void done() {
371
				if (!isCanceled() && getDisassemblyBlock() != null) {
384
				if (!isCanceled() && getDisassemblyBlock() != null) {
(-)src/org/eclipse/cdt/debug/internal/ui/disassembly/dsf/IDisassemblyRetrieval.java (-74 / +6 lines)
Lines 14-102 Link Here
14
import java.math.BigInteger;
14
import java.math.BigInteger;
15
15
16
import org.eclipse.cdt.debug.core.model.IDisassemblyBlock;
16
import org.eclipse.cdt.debug.core.model.IDisassemblyBlock;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.debug.core.IRequest;
17
import org.eclipse.debug.core.IRequest;
19
import org.eclipse.debug.core.model.IStackFrame;
18
import org.eclipse.debug.core.model.IStackFrame;
20
19
21
/**
20
/**
22
 */
21
 */
23
public interface IDisassemblyRetrieval {
22
public interface IDisassemblyRetrieval {
24
	/**
25
	 */
26
	public static class Request implements IRequest {
27
		private IStatus fStatus;
28
		private boolean fCanceled;
29
		/*
30
		 * @see org.eclipse.debug.core.IRequest#cancel()
31
		 */
32
		public void cancel() {
33
			fCanceled= true;
34
		}
35
36
		/*
37
		 * @see org.eclipse.debug.core.IRequest#done()
38
		 */
39
		public void done() {
40
		}
41
42
		/*
43
		 * @see org.eclipse.debug.core.IRequest#getStatus()
44
		 */
45
		public IStatus getStatus() {
46
			return fStatus;
47
		}
48
49
		/*
50
		 * @see org.eclipse.debug.core.IRequest#isCanceled()
51
		 */
52
		public boolean isCanceled() {
53
			return fCanceled;
54
		}
55
56
		/*
57
		 * @see org.eclipse.debug.core.IRequest#setStatus(org.eclipse.core.runtime.IStatus)
58
		 */
59
		public void setStatus(IStatus status) {
60
			fStatus= status;
61
		}
62
23
24
	interface AddressRequest extends IRequest {
25
		BigInteger getAddress();
26
		void setAddress(BigInteger address);
63
	}
27
	}
64
28
65
	/**
29
	interface DisassemblyRequest extends IRequest {
66
	 */
30
		IDisassemblyBlock getDisassemblyBlock();
67
	public static class AddressRequest extends Request {
31
		void setDisassemblyBlock(IDisassemblyBlock disassemblyBlock);
68
		private BigInteger fAddress;
69
		/**
70
		 * @return the address
71
		 */
72
		public BigInteger getAddress() {
73
			return fAddress;
74
		}
75
76
		/**
77
		 * @param address the address to set
78
		 */
79
		public void setAddress(BigInteger address) {
80
			fAddress= address;
81
		}
82
	}
83
84
	public static class DisassemblyRequest extends Request {
85
		IDisassemblyBlock fDisassemblyBlock;
86
87
		/**
88
		 * @return the disassemblyBlock
89
		 */
90
		public IDisassemblyBlock getDisassemblyBlock() {
91
			return fDisassemblyBlock;
92
		}
93
94
		/**
95
		 * @param disassemblyBlock the disassemblyBlock to set
96
		 */
97
		public void setDisassemblyBlock(IDisassemblyBlock disassemblyBlock) {
98
			fDisassemblyBlock= disassemblyBlock;
99
		}
100
	}
32
	}
101
33
102
	/**
34
	/**
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbExpressionVMProvider.java (+115 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Freescale Semiconductor. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Freescale Semiconductor - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel;
12
13
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
14
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionManagerVMNode;
15
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
16
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.IExpressionVMNode;
17
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.SingleExpressionVMNode;
18
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterBitFieldVMNode;
19
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterGroupVMNode;
20
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterVMNode;
21
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.SyncRegisterDataAccess;
22
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.SyncVariableDataAccess;
23
import org.eclipse.cdt.dsf.service.DsfSession;
24
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMAdapter;
25
import org.eclipse.cdt.dsf.ui.viewmodel.IRootVMNode;
26
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
27
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.RootDMVMNode;
28
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
29
30
/**
31
 * A specialization of ExpressionVMProvider that uses a GDB-specific variable VM
32
 * node. To understand why this is necessary, see GdbVariableVMNode.
33
 */
34
public class GdbExpressionVMProvider extends ExpressionVMProvider {
35
36
	/**
37
	 * Constructor (passthru)
38
	 */
39
	public GdbExpressionVMProvider(AbstractVMAdapter adapter,
40
			IPresentationContext context, DsfSession session) {
41
		super(adapter, context, session);
42
	}
43
44
	/**
45
	 * The only difference between this and our super implementation is that we
46
	 * create a GdbVariableVMNode instead of a VariableVMNode. 
47
	 * 
48
	 * @see org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider#configureLayout()
49
	 */
50
    @Override
51
	protected void configureLayout() {
52
    	
53
        /*
54
         *  Allocate the synchronous data providers.
55
         */
56
        SyncRegisterDataAccess syncRegDataAccess = new SyncRegisterDataAccess(getSession());
57
        SyncVariableDataAccess syncvarDataAccess = new SyncVariableDataAccess(getSession()) ;
58
        
59
        /*
60
         *  Create the top level node which provides the anchor starting point.
61
         */
62
        IRootVMNode rootNode = new RootDMVMNode(this); 
63
        
64
        /*
65
         * Now the Over-arching management node.
66
         */
67
        if (IDsfDebugUIConstants.ID_EXPRESSION_HOVER.equals(getPresentationContext().getId())) {
68
        	SingleExpressionVMNode expressionManagerNode = new SingleExpressionVMNode(this);
69
        	addChildNodes(rootNode, new IVMNode[] { expressionManagerNode });
70
        } else {
71
            ExpressionManagerVMNode expressionManagerNode = new ExpressionManagerVMNode(this);
72
            addChildNodes(rootNode, new IVMNode[] {expressionManagerNode});
73
        }
74
        
75
        /*
76
         *  The expression view wants to support fully all of the components of the register view.
77
         */
78
        IExpressionVMNode registerGroupNode = new RegisterGroupVMNode(this, getSession(), syncRegDataAccess);
79
        
80
        IExpressionVMNode registerNode = new RegisterVMNode(this, getSession(), syncRegDataAccess);
81
        addChildNodes(registerGroupNode, new IExpressionVMNode[] {registerNode});
82
        
83
        /*
84
         * Create the next level which is the bit-field level.
85
         */
86
        IVMNode bitFieldNode = new RegisterBitFieldVMNode(this, getSession(), syncRegDataAccess);
87
        addChildNodes(registerNode, new IVMNode[] { bitFieldNode });
88
        
89
        /*
90
         *  Create the support for the SubExpressions. Anything which is brought into the expressions
91
         *  view comes in as a fully qualified expression so we go directly to the SubExpression layout
92
         *  node.
93
         */
94
        IExpressionVMNode variableNode =  new GdbVariableVMNode(this, getSession(), syncvarDataAccess);
95
        addChildNodes(variableNode, new IExpressionVMNode[] {variableNode});
96
        
97
        /*
98
         *  Tell the expression node which sub-nodes it will directly support.  It is very important
99
         *  that the variables node be the last in this chain.  The model assumes that there is some
100
         *  form of metalanguage expression syntax which each  of the nodes evaluates and decides if
101
         *  they are dealing with it or not. The variables node assumes that the expression is fully
102
         *  qualified and there is no analysis or subdivision of the expression it will parse. So it
103
         *  it currently the case that the location of the nodes within the array being passed in is
104
         *  the order of search/evaluation. Thus variables wants to be last. Otherwise it would just
105
         *  assume what it was passed was for it and the real node which wants to handle it would be
106
         *  left out in the cold.
107
         */
108
        setExpressionNodes(new IExpressionVMNode[] {registerGroupNode, variableNode});
109
        
110
        /*
111
         *  Let the work know which is the top level node.
112
         */
113
        setRootNode(rootNode);
114
    }
115
}
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java (+148 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Freescale Semiconductor. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Freescale Semiconductor - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel;
12
13
import org.eclipse.cdt.debug.internal.core.ICWatchpointTarget;
14
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
15
import org.eclipse.cdt.dsf.datamodel.DMContexts;
16
import org.eclipse.cdt.dsf.datamodel.IDMContext;
17
import org.eclipse.cdt.dsf.debug.service.IExpressions;
18
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
19
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
20
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.SyncVariableDataAccess;
21
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMNode;
22
import org.eclipse.cdt.dsf.service.DsfSession;
23
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
24
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
25
26
/**
27
 * Specialization of DSF's VariableVMNode. See
28
 * {@link GdbVariableVMNode#createVMContext(IDMContext)} for why this is needed.
29
 */
30
public class GdbVariableVMNode extends VariableVMNode {
31
32
	/**
33
	 * Specialization of VariableVMNode.VariableExpressionVMC that participates
34
	 * in the "Add Watchpoint" object contribution action.
35
	 */
36
	public class GdbVariableExpressionVMC extends VariableVMNode.VariableExpressionVMC implements ICWatchpointTarget {
37
        
38
		/**
39
		 * Constructor (passthru)
40
		 */
41
		public GdbVariableExpressionVMC(IDMContext dmc) {
42
            super(dmc);
43
        }
44
        
45
		/* (non-Javadoc)
46
		 * @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#getExpression()
47
		 */
48
		public String getExpression() {
49
			final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), IExpressionDMContext.class);
50
			if (exprDmc != null) {
51
				return exprDmc.getExpression();
52
			}
53
								
54
			return ""; //$NON-NLS-1$
55
		}
56
57
		/* (non-Javadoc)
58
		 * @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#getSize()
59
		 */
60
		public void getSize(final ICWatchpointTarget.GetSizeRequest request) {
61
			final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), IExpressionDMContext.class);
62
			if (exprDmc != null) {
63
	            getSession().getExecutor().execute(new Runnable() {
64
	                public void run() {
65
	                    final IExpressions expressionService = getServicesTracker().getService(IExpressions.class);
66
	                    if (expressionService != null) {
67
	                    	final DataRequestMonitor<IExpressionDMAddress> drm = new DataRequestMonitor<IExpressionDMAddress>(getSession().getExecutor(), null) {
68
                                @Override
69
								public void handleSuccess() {
70
                                    request.setSize(getData().getSize());
71
                                    request.done();
72
                                }
73
	                    	};
74
	                    	
75
	                        expressionService.getExpressionAddressData(exprDmc, drm);
76
	                    }
77
	                }
78
	            });
79
			}
80
			else {
81
				request.setSize(-1);
82
				request.done();
83
			}
84
		}
85
86
		/* (non-Javadoc)
87
		 * @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#canCreateWatchpoint(org.eclipse.cdt.debug.internal.core.IWatchpointTarget.CanCreateWatchpointRequest)
88
		 */
89
		public void canSetWatchpoint(final ICWatchpointTarget.CanCreateWatchpointRequest request) {
90
			// If the expression is an l-value, then we say it supports a
91
			// watchpoint. The logic here is basically the same as what's in
92
			// getSize(), as the same DSF service method tells us (a) if it's an
93
			// lvalue, and (b) its size.
94
			final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), IExpressionDMContext.class);
95
			if (exprDmc != null) {
96
	            getSession().getExecutor().execute(new Runnable() {
97
	                public void run() {
98
	                    final IExpressions expressionService = getServicesTracker().getService(IExpressions.class);
99
	                    if (expressionService != null) {
100
	                    	final DataRequestMonitor<IExpressionDMAddress> drm = new DataRequestMonitor<IExpressionDMAddress>(getSession().getExecutor(), null) {
101
                                @Override
102
								public void handleCompleted() {
103
                                	if (isSuccess()) {
104
	                                	assert getData().getSize() > 0;
105
	                                    request.setCanCreate(true);
106
                                	}
107
                                	else {
108
                                		request.setCanCreate(false);
109
                                	}
110
	                                request.done();
111
                                }
112
	                    	};
113
	                    	
114
	                        expressionService.getExpressionAddressData(exprDmc, drm);
115
	                    }
116
	                }
117
	            });
118
			}
119
			else {
120
				request.setCanCreate(false);
121
				request.done();
122
			}
123
		}
124
		
125
	};
126
	
127
	/**
128
	 * Constructor (passthru)
129
	 */
130
	public GdbVariableVMNode(AbstractDMVMProvider provider, DsfSession session,
131
			SyncVariableDataAccess syncVariableDataAccess) {
132
		super(provider, session, syncVariableDataAccess);
133
	}
134
135
	/**
136
	 * The primary reason for the specialization of VariableVMNode is to create
137
	 * a GDB-specific VM context that implements ICWatchpointTarget, so that the
138
	 * "Add Watchpoint" context menu appears for variables and expressions in
139
	 * GDB-DSF sessions but not necessarily other DSF-based sessions [bugzilla
140
	 * 248606]
141
	 * 
142
	 * @see org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMNode#createVMContext(org.eclipse.cdt.dsf.datamodel.IDMContext)
143
	 */
144
    @Override
145
    protected IDMVMContext createVMContext(IDMContext dmc) {
146
        return new GdbVariableExpressionVMC(dmc);
147
    }
148
}
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMProvider.java (+56 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Freescale Semiconductor. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Freescale Semiconductor - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel;
12
13
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.SyncVariableDataAccess;
14
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMProvider;
15
import org.eclipse.cdt.dsf.service.DsfSession;
16
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMAdapter;
17
import org.eclipse.cdt.dsf.ui.viewmodel.IRootVMNode;
18
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
19
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.RootDMVMNode;
20
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
21
22
/**
23
 * A specialization of VariableVMProvider that uses a GDB-specific variable VM
24
 * node. To understand why this is necessary, see GdbVariableVMNode.
25
 */
26
public class GdbVariableVMProvider extends VariableVMProvider {
27
28
	/**
29
	 * Constructor (passthru)
30
	 */
31
	public GdbVariableVMProvider(AbstractVMAdapter adapter,
32
			IPresentationContext context, DsfSession session) {
33
		super(adapter, context, session);
34
	}
35
36
    /* (non-Javadoc)
37
     * @see org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMProvider#configureLayout(org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.SyncVariableDataAccess)
38
     */
39
    @Override
40
	protected void configureLayout() {
41
        // Create the variable data access routines.
42
        SyncVariableDataAccess varAccess = new SyncVariableDataAccess(getSession()) ;
43
    	
44
        // Create the top level node to deal with the root selection.
45
        IRootVMNode rootNode = new RootDMVMNode(this);
46
        setRootNode(rootNode);
47
        
48
        // Create the next level which represents members of structs/unions/enums and elements of arrays.
49
        IVMNode subExpressioNode = new GdbVariableVMNode(this, getSession(), varAccess);
50
        addChildNodes(rootNode, new IVMNode[] { subExpressioNode });
51
52
        // Configure the sub-expression node to be a child of itself.  This way the content
53
        // provider will recursively drill-down the variable hierarchy.
54
        addChildNodes(subExpressioNode, new IVMNode[] { subExpressioNode });
55
    }
56
}
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbViewModelAdapter.java (-4 / +2 lines)
Lines 13-22 Link Here
13
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
13
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
14
import org.eclipse.cdt.dsf.debug.ui.viewmodel.AbstractDebugVMAdapter;
14
import org.eclipse.cdt.dsf.debug.ui.viewmodel.AbstractDebugVMAdapter;
15
import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController;
15
import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController;
16
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
17
import org.eclipse.cdt.dsf.debug.ui.viewmodel.modules.ModulesVMProvider;
16
import org.eclipse.cdt.dsf.debug.ui.viewmodel.modules.ModulesVMProvider;
18
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterVMProvider;
17
import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterVMProvider;
19
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMProvider;
20
import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.breakpoints.GdbBreakpointVMProvider;
18
import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.breakpoints.GdbBreakpointVMProvider;
21
import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch.LaunchVMProvider;
19
import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch.LaunchVMProvider;
22
import org.eclipse.cdt.dsf.service.DsfSession;
20
import org.eclipse.cdt.dsf.service.DsfSession;
Lines 47-57 Link Here
47
        if ( IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId()) ) {
45
        if ( IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId()) ) {
48
            return new LaunchVMProvider(this, context, getSession()); 
46
            return new LaunchVMProvider(this, context, getSession()); 
49
        } else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId()) ) {
47
        } else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId()) ) {
50
            return new VariableVMProvider(this, context, getSession());
48
            return new GdbVariableVMProvider(this, context, getSession());
51
        } else if (IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId()) ) {
49
        } else if (IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId()) ) {
52
            return new RegisterVMProvider(this, context, getSession());
50
            return new RegisterVMProvider(this, context, getSession());
53
        } else if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId()) ) {
51
        } else if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId()) ) {
54
            return new ExpressionVMProvider(this, context, getSession());
52
            return new GdbExpressionVMProvider(this, context, getSession());
55
        } else if (IDebugUIConstants.ID_MODULE_VIEW.equals(context.getId()) ) {
53
        } else if (IDebugUIConstants.ID_MODULE_VIEW.equals(context.getId()) ) {
56
            return new ModulesVMProvider(this, context, getSession());
54
            return new ModulesVMProvider(this, context, getSession());
57
        } else if (IDebugUIConstants.ID_BREAKPOINT_VIEW.equals(context.getId()) ) {
55
        } else if (IDebugUIConstants.ID_BREAKPOINT_VIEW.equals(context.getId()) ) {
(-)src/org/eclipse/cdt/dsf/debug/ui/viewmodel/variable/VariableVMNode.java (-3 / +3 lines)
Lines 146-153 Link Here
146
            fExpression = expression;
146
            fExpression = expression;
147
        }
147
        }
148
        
148
        
149
        @Override
149
        @SuppressWarnings("rawtypes")
150
        @SuppressWarnings("rawtype") 
150
		@Override
151
        public Object getAdapter(Class adapter) {
151
        public Object getAdapter(Class adapter) {
152
            if (fExpression != null && adapter.isAssignableFrom(fExpression.getClass())) {
152
            if (fExpression != null && adapter.isAssignableFrom(fExpression.getClass())) {
153
                return fExpression;
153
                return fExpression;
Lines 750-756 Link Here
750
                        IExpressionDMContext expressionDMC = expressionService.createExpression(
750
                        IExpressionDMContext expressionDMC = expressionService.createExpression(
751
                            createCompositeDMVMContext(update), 
751
                            createCompositeDMVMContext(update), 
752
                            update.getExpression().getExpressionText());
752
                            update.getExpression().getExpressionText());
753
                        VariableExpressionVMC variableVmc = new VariableExpressionVMC(expressionDMC);
753
                        VariableExpressionVMC variableVmc = (VariableExpressionVMC)createVMContext(expressionDMC);
754
                        variableVmc.setExpression(update.getExpression());
754
                        variableVmc.setExpression(update.getExpression());
755
                        
755
                        
756
                        update.setExpressionElement(variableVmc);
756
                        update.setExpressionElement(variableVmc);
(-)src/org/eclipse/cdt/dsf/debug/ui/viewmodel/variable/VariableVMProvider.java (-18 / +21 lines)
Lines 69-88 Link Here
69
        store.addPropertyChangeListener(fPreferencesListener);
69
        store.addPropertyChangeListener(fPreferencesListener);
70
        setDelayEventHandleForViewUpdate(store.getBoolean(IDsfDebugUIConstants.PREF_WAIT_FOR_VIEW_UPDATE_AFTER_STEP_ENABLE));
70
        setDelayEventHandleForViewUpdate(store.getBoolean(IDsfDebugUIConstants.PREF_WAIT_FOR_VIEW_UPDATE_AFTER_STEP_ENABLE));
71
71
72
        /*
72
        configureLayout();
73
         *  Create the variable data access routines.
73
	}
74
         */
74
	
75
        SyncVariableDataAccess varAccess = new SyncVariableDataAccess(session) ;
75
    @Override
76
76
    public void dispose() {
77
        /*
77
        DsfDebugUITools.getPreferenceStore().removePropertyChangeListener(fPreferencesListener);
78
         *  Create the top level node to deal with the root selection.
78
        getPresentationContext().removePropertyChangeListener(fPresentationContextListener);
79
         */
79
        super.dispose();
80
    }
81
82
    /**
83
     * Configures the nodes of this provider.  This method may be over-ridden by
84
     * sub classes to create an alternate configuration in this provider.
85
     */
86
    protected void configureLayout() {
87
88
        // Create the variable data access routines.
89
        SyncVariableDataAccess varAccess = new SyncVariableDataAccess(getSession()) ;
90
91
        // Create the top level node to deal with the root selection.
80
        IRootVMNode rootNode = new RootDMVMNode(this);
92
        IRootVMNode rootNode = new RootDMVMNode(this);
81
        setRootNode(rootNode);
93
        setRootNode(rootNode);
82
        
94
        
83
        /*
95
        // Create the next level which represents members of structs/unions/enums and elements of arrays.
84
         * Create the next level which represents members of structs/unions/enums and elements of arrays.
85
         */
86
        IVMNode subExpressioNode = new VariableVMNode(this, getSession(), varAccess);
96
        IVMNode subExpressioNode = new VariableVMNode(this, getSession(), varAccess);
87
        addChildNodes(rootNode, new IVMNode[] { subExpressioNode });
97
        addChildNodes(rootNode, new IVMNode[] { subExpressioNode });
88
98
Lines 90-102 Link Here
90
        // provider will recursively drill-down the variable hierarchy.
100
        // provider will recursively drill-down the variable hierarchy.
91
        addChildNodes(subExpressioNode, new IVMNode[] { subExpressioNode });
101
        addChildNodes(subExpressioNode, new IVMNode[] { subExpressioNode });
92
    }
102
    }
93
	
94
    @Override
95
    public void dispose() {
96
        DsfDebugUITools.getPreferenceStore().removePropertyChangeListener(fPreferencesListener);
97
        getPresentationContext().removePropertyChangeListener(fPresentationContextListener);
98
        super.dispose();
99
    }
100
103
101
    @Override
104
    @Override
102
    public IColumnPresentation createColumnPresentation(IPresentationContext context, Object element) {
105
    public IColumnPresentation createColumnPresentation(IPresentationContext context, Object element) {

Return to bug 248606