15 import java.util.Arrays; |
15 import java.util.Arrays; |
16 import java.util.List; |
16 import java.util.List; |
17 import java.util.Map; |
17 import java.util.Map; |
18 import java.util.concurrent.RejectedExecutionException; |
18 import java.util.concurrent.RejectedExecutionException; |
19 |
19 |
20 import org.eclipse.cdt.core.IAddress; |
|
21 import org.eclipse.cdt.debug.internal.ui.CDebugImages; |
20 import org.eclipse.cdt.debug.internal.ui.CDebugImages; |
22 import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor; |
21 import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor; |
23 import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; |
22 import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; |
24 import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; |
23 import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; |
25 import org.eclipse.cdt.dsf.concurrent.DsfExecutor; |
24 import org.eclipse.cdt.dsf.concurrent.DsfExecutor; |
26 import org.eclipse.cdt.dsf.concurrent.DsfRunnable; |
25 import org.eclipse.cdt.dsf.concurrent.DsfRunnable; |
27 import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; |
26 import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; |
28 import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; |
27 import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; |
29 import org.eclipse.cdt.dsf.concurrent.MultiRequestMonitor; |
|
30 import org.eclipse.cdt.dsf.concurrent.RequestMonitor; |
28 import org.eclipse.cdt.dsf.concurrent.RequestMonitor; |
31 import org.eclipse.cdt.dsf.datamodel.DMContexts; |
29 import org.eclipse.cdt.dsf.datamodel.DMContexts; |
32 import org.eclipse.cdt.dsf.datamodel.IDMContext; |
30 import org.eclipse.cdt.dsf.datamodel.IDMContext; |
33 import org.eclipse.cdt.dsf.debug.service.IExpressions; |
31 import org.eclipse.cdt.dsf.debug.service.IExpressions; |
34 import org.eclipse.cdt.dsf.debug.service.IFormattedValues; |
32 import org.eclipse.cdt.dsf.debug.service.IFormattedValues; |
35 import org.eclipse.cdt.dsf.debug.service.IStack; |
33 import org.eclipse.cdt.dsf.debug.service.IStack; |
36 import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionChangedDMEvent; |
34 import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionChangedDMEvent; |
37 import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress; |
35 import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress; |
38 import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; |
36 import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; |
39 import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData; |
37 import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData; |
|
38 import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMLocation; |
40 import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent; |
39 import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent; |
41 import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent; |
40 import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent; |
42 import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; |
41 import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; |
43 import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMContext; |
42 import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMContext; |
44 import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMData; |
43 import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMData; |
49 import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueLabelText; |
48 import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueLabelText; |
50 import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueVMUtil; |
49 import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueVMUtil; |
51 import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IFormattedValueVMContext; |
50 import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IFormattedValueVMContext; |
52 import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; |
51 import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; |
53 import org.eclipse.cdt.dsf.service.DsfSession; |
52 import org.eclipse.cdt.dsf.service.DsfSession; |
|
53 import org.eclipse.cdt.dsf.ui.concurrent.ViewerCountingRequestMonitor; |
54 import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor; |
54 import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor; |
55 import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta; |
55 import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta; |
56 import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider; |
56 import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider; |
57 import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; |
57 import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; |
58 import org.eclipse.cdt.dsf.ui.viewmodel.properties.IElementPropertiesProvider; |
58 import org.eclipse.cdt.dsf.ui.viewmodel.properties.IElementPropertiesProvider; |
373 // address value changes. |
373 // address value changes. |
374 provider.setColumnInfo( |
374 provider.setColumnInfo( |
375 IDebugVMConstants.COLUMN_ID__ADDRESS, |
375 IDebugVMConstants.COLUMN_ID__ADDRESS, |
376 new LabelColumnInfo(new LabelAttribute[] { |
376 new LabelColumnInfo(new LabelAttribute[] { |
377 new LabelText( |
377 new LabelText( |
378 MessagesForVariablesVM.VariableVMNode_Address_column__text_format, |
378 MessagesForVariablesVM.VariableVMNode_Location_column__text_format, |
379 new String[] { PROP_VARIABLE_ADDRESS }), |
379 new String[] { PROP_VARIABLE_ADDRESS }), |
380 new LabelText(MessagesForVariablesVM.VariableVMNode_Address_column__Error__text_format, new String[] {}), |
380 new LabelText(MessagesForVariablesVM.VariableVMNode_Location_column__Error__text_format, new String[] {}), |
381 new LabelBackground( |
381 new LabelBackground( |
382 DebugUITools.getPreferenceColor(IDebugUIConstants.PREF_CHANGED_VALUE_BACKGROUND).getRGB()) |
382 DebugUITools.getPreferenceColor(IDebugUIConstants.PREF_CHANGED_VALUE_BACKGROUND).getRGB()) |
383 { |
383 { |
384 { setPropertyNames(new String[] { PROP_VARIABLE_ADDRESS, PROP_VARIABLE_ADDRESS_CHANGED}); } |
384 { setPropertyNames(new String[] { PROP_VARIABLE_ADDRESS, PROP_VARIABLE_ADDRESS_CHANGED}); } |
385 |
385 |
704 * get the formatted data value for a specific register. |
704 * get the formatted data value for a specific register. |
705 */ |
705 */ |
706 @ConfinedToDsfExecutor("getSession().getExecutor()") |
706 @ConfinedToDsfExecutor("getSession().getExecutor()") |
707 protected void fillAddressDataProperties(IPropertiesUpdate update, IExpressionDMAddress address) |
707 protected void fillAddressDataProperties(IPropertiesUpdate update, IExpressionDMAddress address) |
708 { |
708 { |
709 IExpressionDMAddress expression = address; |
709 if (address instanceof IExpressionDMLocation) |
710 Object expAddress = expression.getAddress(); |
710 update.setProperty(PROP_VARIABLE_ADDRESS, ((IExpressionDMLocation)address).getLocation()); |
711 |
711 else |
712 String addrString = ""; //$NON-NLS-1$ |
712 update.setProperty(PROP_VARIABLE_ADDRESS, "0x" + address.getAddress().toString(16)); //$NON-NLS-1$ |
713 if (expAddress instanceof IAddress) |
|
714 addrString = "0x" + ((IAddress)expAddress).toString(16); //$NON-NLS-1$ |
|
715 else if (expAddress instanceof String) |
|
716 addrString = (String)expAddress; |
|
717 |
|
718 update.setProperty(PROP_VARIABLE_ADDRESS, addrString); |
|
719 } |
713 } |
720 |
714 |
721 public CellEditor getCellEditor(IPresentationContext context, String columnId, Object element, Composite parent) { |
715 public CellEditor getCellEditor(IPresentationContext context, String columnId, Object element, Composite parent) { |
722 if (IDebugVMConstants.COLUMN_ID__VALUE.equals(columnId)) { |
716 if (IDebugVMConstants.COLUMN_ID__VALUE.equals(columnId)) { |
723 return new TextCellEditor(parent); |
717 return new TextCellEditor(parent); |
896 |
890 |
897 final List<IVariableDMData> localsDMData = new ArrayList<IVariableDMData>(); |
891 final List<IVariableDMData> localsDMData = new ArrayList<IVariableDMData>(); |
898 |
892 |
899 // Create the MultiRequestMonitor to handle completion of the set of getModelData() calls. |
893 // Create the MultiRequestMonitor to handle completion of the set of getModelData() calls. |
900 |
894 |
901 final MultiRequestMonitor<DataRequestMonitor<IVariableDMData>> mrm = |
895 final CountingRequestMonitor crm = new ViewerCountingRequestMonitor(dsfExecutor, update) { |
902 new MultiRequestMonitor<DataRequestMonitor<IVariableDMData>>(dsfExecutor, null) { |
896 @Override |
903 @Override |
897 public void handleCompleted() { |
904 public void handleCompleted() { |
898 // Now that all the calls to getModelData() are complete, we create an |
905 // Now that all the calls to getModelData() are complete, we create an |
899 // IExpressionDMContext object for each local variable name, saving them all |
906 // IExpressionDMContext object for each local variable name, saving them all |
900 // in an array. |
907 // in an array. |
901 |
908 |
902 if (!isSuccess()) { |
909 if (!isSuccess()) { |
903 handleFailedUpdate(update); |
910 handleFailedUpdate(update); |
904 return; |
911 return; |
|
912 } |
|
913 |
|
914 IExpressionDMContext[] expressionDMCs = new IExpressionDMContext[localsDMData.size()]; |
|
915 |
|
916 int i = 0; |
|
917 |
|
918 for (IVariableDMData localDMData : localsDMData) { |
|
919 expressionDMCs[i++] = expressionService.createExpression(frameDmc, localDMData.getName()); |
|
920 } |
|
921 |
|
922 // Lastly, we fill the update from the array of view model context objects |
|
923 // that reference the ExpressionDMC objects for the local variables. This is |
|
924 // the last code to run for a given call to updateElementsInSessionThread(). |
|
925 // We can now leave anonymous-inner-class hell. |
|
926 |
|
927 fillUpdateWithVMCs(update, expressionDMCs); |
|
928 update.done(); |
|
929 } |
905 } |
|
906 |
|
907 IExpressionDMContext[] expressionDMCs = new IExpressionDMContext[localsDMData.size()]; |
|
908 |
|
909 int i = 0; |
|
910 for (IVariableDMData localDMData : localsDMData) { |
|
911 expressionDMCs[i++] = expressionService.createExpression(frameDmc, localDMData.getName()); |
|
912 } |
|
913 |
|
914 // Lastly, we fill the update from the array of view model context objects |
|
915 // that reference the ExpressionDMC objects for the local variables. This is |
|
916 // the last code to run for a given call to updateElementsInSessionThread(). |
|
917 // We can now leave anonymous-inner-class hell. |
|
918 |
|
919 fillUpdateWithVMCs(update, expressionDMCs); |
|
920 update.done(); |
|
921 } |
930 }; |
922 }; |
|
923 int countRM = 0; |
931 |
924 |
932 // Perform a set of getModelData() calls, one for each local variable's data model |
925 // Perform a set of getModelData() calls, one for each local variable's data model |
933 // context object. In the handleCompleted() method of the DataRequestMonitor, add the |
926 // context object. In the handleCompleted() method of the DataRequestMonitor, add the |
934 // IVariableDMData object to the localsDMData List for later processing (see above). |
927 // IVariableDMData object to the localsDMData List for later processing (see above). |
935 |
928 |
936 for (IVariableDMContext localDMC : localsDMCs) { |
929 for (IVariableDMContext localDMC : localsDMCs) { |
937 DataRequestMonitor<IVariableDMData> rm = |
930 DataRequestMonitor<IVariableDMData> rm = |
938 new ViewerDataRequestMonitor<IVariableDMData>(dsfExecutor, update) { |
931 new DataRequestMonitor<IVariableDMData>(dsfExecutor, crm) { |
939 @Override |
932 @Override |
940 public void handleCompleted() { |
933 public void handleSuccess() { |
941 localsDMData.add(getData()); |
934 localsDMData.add(getData()); |
942 mrm.requestMonitorDone(this); |
935 crm.done(); |
943 } |
936 } |
944 }; |
937 }; |
945 |
938 |
946 mrm.add(rm); |
|
947 |
|
948 stackFrameService.getVariableData(localDMC, rm); |
939 stackFrameService.getVariableData(localDMC, rm); |
949 } |
940 countRM++; |
|
941 } |
|
942 crm.setDoneCount(countRM); |
950 } |
943 } |
951 }; |
944 }; |
952 |
945 |
953 // Make the asynchronous call to IStack.getLocals(). The results are processed in the |
946 // Make the asynchronous call to IStack.getLocals(). The results are processed in the |
954 // DataRequestMonitor.handleCompleted() above. |
947 // DataRequestMonitor.handleCompleted() above. |
978 e instanceof IMemoryChangedEvent || |
970 e instanceof IMemoryChangedEvent || |
979 e instanceof IExpressionChangedDMEvent || |
971 e instanceof IExpressionChangedDMEvent || |
980 (e instanceof PropertyChangeEvent && |
972 (e instanceof PropertyChangeEvent && |
981 ((PropertyChangeEvent)e).getProperty() == IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE) ) |
973 ((PropertyChangeEvent)e).getProperty() == IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE) ) |
982 { |
974 { |
983 // Create a delta that the whole register group has changed. |
|
984 parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT); |
975 parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT); |
985 } |
976 } |
986 |
977 |
987 requestMonitor.done(); |
978 requestMonitor.done(); |
988 } |
979 } |