mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bugzilla entries
183188 - IRegisters write routines 186006 - Show mnemonics with values for the bit fields 193810 - All getXXXXXdmc helper routines need to target a particular service 193811 - Need to breakout formatted read routines to support multiple services. Randy
This commit is contained in:
parent
599aa1dbb7
commit
453c1f7013
4 changed files with 101 additions and 32 deletions
|
@ -6,7 +6,8 @@
|
|||
*/
|
||||
package org.eclipse.dd.dsf.debug.ui.viewmodel.register;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.dd.dsf.debug.service.IFormattedValues;
|
||||
import org.eclipse.dd.dsf.debug.service.IRegisters.IBitFieldDMContext;
|
||||
import org.eclipse.dd.dsf.debug.service.IRegisters.IBitFieldDMData;
|
||||
|
@ -14,6 +15,7 @@ import org.eclipse.dd.dsf.debug.service.IRegisters.IMnemonic;
|
|||
import org.eclipse.dd.dsf.debug.ui.viewmodel.IDebugVMConstants;
|
||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.expression.WatchExpressionCellModifier;
|
||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.formatsupport.IFormattedValuePreferenceStore;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMLayoutNode;
|
||||
|
||||
public class RegisterBitFieldLayoutCellModifier extends WatchExpressionCellModifier {
|
||||
|
||||
|
@ -35,8 +37,9 @@ public class RegisterBitFieldLayoutCellModifier extends WatchExpressionCellModif
|
|||
* Used to make sure we are dealing with a valid register.
|
||||
*/
|
||||
private IBitFieldDMContext getBitFieldDMC(Object element) {
|
||||
if (element instanceof IAdaptable) {
|
||||
return (IBitFieldDMContext)((IAdaptable)element).getAdapter(IBitFieldDMContext.class);
|
||||
if (element instanceof AbstractDMVMLayoutNode.DMVMContext) {
|
||||
IDMContext<?> dmc = ((AbstractDMVMLayoutNode.DMVMContext)element).getDMC();
|
||||
return DMContexts.getAncestorOfType(dmc, IBitFieldDMContext.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -86,7 +89,7 @@ public class RegisterBitFieldLayoutCellModifier extends WatchExpressionCellModif
|
|||
/*
|
||||
* We let the Model provider supply the current format.
|
||||
*/
|
||||
String value = fDataAccess.getFormattedValue(fElement, fFormatPrefStore.getDefaultFormatId());
|
||||
String value = fDataAccess.getFormattedBitFieldValue(fElement, fFormatPrefStore.getDefaultFormatId());
|
||||
|
||||
if ( value == null ) { value = "..."; } //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ public class RegisterBitFieldLayoutNode extends AbstractExpressionLayoutNode<IBi
|
|||
* Private data access routine which performs the extra level of data access needed to
|
||||
* get the formatted data value for a specific register.
|
||||
*/
|
||||
private void updateFormattedRegisterValue(final ILabelUpdate update, final int labelIndex, final IBitFieldDMContext dmc)
|
||||
private void updateFormattedRegisterValue(final ILabelUpdate update, final int labelIndex, final IBitFieldDMContext dmc, final IBitFieldDMData data)
|
||||
{
|
||||
final IRegisters regService = getServicesTracker().getService(IRegisters.class);
|
||||
|
||||
|
@ -249,7 +249,14 @@ public class RegisterBitFieldLayoutNode extends AbstractExpressionLayoutNode<IBi
|
|||
/*
|
||||
* Fill the label/column with the properly formatted data value.
|
||||
*/
|
||||
update.setLabel(getData().getFormattedValue() , labelIndex);
|
||||
IMnemonic mnemonic = data.getCurrentMnemonicValue();
|
||||
if ( mnemonic != null ) {
|
||||
String mnemstr = mnemonic.getLongName() + " - " + getData().getFormattedValue(); //$NON-NLS-1$
|
||||
update.setLabel(mnemstr , labelIndex);
|
||||
}
|
||||
else {
|
||||
update.setLabel(getData().getFormattedValue() , labelIndex);
|
||||
}
|
||||
update.done();
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +336,7 @@ public class RegisterBitFieldLayoutNode extends AbstractExpressionLayoutNode<IBi
|
|||
} else {
|
||||
for (int idx = 0; idx < localColumns.length; idx++) {
|
||||
if (IDebugVMConstants.COLUMN_ID__VALUE.equals(localColumns[idx])) {
|
||||
updateFormattedRegisterValue(update, idx, dmc);
|
||||
updateFormattedRegisterValue(update, idx, dmc, getData() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,14 @@
|
|||
package org.eclipse.dd.dsf.debug.ui.viewmodel.register;
|
||||
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterDMContext;
|
||||
import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterDMData;
|
||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.IDebugVMConstants;
|
||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.expression.WatchExpressionCellModifier;
|
||||
import org.eclipse.dd.dsf.debug.ui.viewmodel.formatsupport.IFormattedValuePreferenceStore;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMLayoutNode;
|
||||
|
||||
public class RegisterLayoutValueCellModifier extends WatchExpressionCellModifier {
|
||||
|
||||
|
@ -31,12 +33,17 @@ public class RegisterLayoutValueCellModifier extends WatchExpressionCellModifier
|
|||
public SyncRegisterDataAccess getRegisterDataAccess() {
|
||||
return fDataAccess;
|
||||
}
|
||||
|
||||
public IFormattedValuePreferenceStore getPreferenceStore() {
|
||||
return fFormattedValuePreferenceStore;
|
||||
}
|
||||
/*
|
||||
* Used to make sure we are dealing with a valid register.
|
||||
*/
|
||||
private IRegisterDMContext getRegisterDMC(Object element) {
|
||||
if (element instanceof IAdaptable) {
|
||||
return (IRegisterDMContext)((IAdaptable)element).getAdapter(IRegisterDMContext.class);
|
||||
protected IRegisterDMContext getRegisterDMC(Object element) {
|
||||
if (element instanceof AbstractDMVMLayoutNode.DMVMContext) {
|
||||
IDMContext<?> dmc = ((AbstractDMVMLayoutNode.DMVMContext)element).getDMC();
|
||||
return DMContexts.getAncestorOfType(dmc, IRegisterDMContext.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -52,7 +59,6 @@ public class RegisterLayoutValueCellModifier extends WatchExpressionCellModifier
|
|||
/*
|
||||
* Make sure we are are dealing with a valid set of information.
|
||||
*/
|
||||
|
||||
if ( getRegisterDMC(element) == null ) return false;
|
||||
|
||||
/*
|
||||
|
@ -79,13 +85,7 @@ public class RegisterLayoutValueCellModifier extends WatchExpressionCellModifier
|
|||
/*
|
||||
* Make sure we are working on the editable areas.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Write the value in the currently requested format. Since they could
|
||||
* have freeformed typed in any format this is just a guess and may not
|
||||
* really accomplish anything.
|
||||
*/
|
||||
String value = fDataAccess.getFormattedValue(element, fFormattedValuePreferenceStore.getDefaultFormatId());
|
||||
String value = fDataAccess.getFormattedRegisterValue(element, fFormattedValuePreferenceStore.getDefaultFormatId());
|
||||
|
||||
if ( value == null ) { return "..."; } //$NON-NLS-1$
|
||||
else { return value; }
|
||||
|
|
|
@ -13,12 +13,13 @@ package org.eclipse.dd.dsf.debug.ui.viewmodel.register;
|
|||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.dd.dsf.concurrent.Query;
|
||||
import org.eclipse.dd.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
|
||||
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.dd.dsf.debug.service.IRegisters;
|
||||
import org.eclipse.dd.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
||||
import org.eclipse.dd.dsf.debug.service.IFormattedValues.FormattedValueDMData;
|
||||
|
@ -33,6 +34,7 @@ import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterGroupDMData;
|
|||
import org.eclipse.dd.dsf.debug.ui.DsfDebugUIPlugin;
|
||||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.dsf.service.IDsfService;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMLayoutNode;
|
||||
import org.osgi.framework.InvalidSyntaxException;
|
||||
import org.osgi.util.tracker.ServiceTracker;
|
||||
|
||||
|
@ -137,8 +139,9 @@ public class SyncRegisterDataAccess {
|
|||
}
|
||||
|
||||
public IBitFieldDMContext getBitFieldDMC(Object element) {
|
||||
if (element instanceof IAdaptable) {
|
||||
return (IBitFieldDMContext) ((IAdaptable) element).getAdapter(IBitFieldDMContext.class);
|
||||
if (element instanceof AbstractDMVMLayoutNode.DMVMContext) {
|
||||
IDMContext<?> dmc = ((AbstractDMVMLayoutNode.DMVMContext)element).getDMC();
|
||||
return DMContexts.getAncestorOfType(dmc, IBitFieldDMContext.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -392,22 +395,26 @@ public class SyncRegisterDataAccess {
|
|||
}
|
||||
|
||||
public IRegisterGroupDMContext getRegisterGroupDMC(Object element) {
|
||||
if (element instanceof IAdaptable) {
|
||||
return (IRegisterGroupDMContext) ((IAdaptable) element).getAdapter(IRegisterGroupDMContext.class);
|
||||
if (element instanceof AbstractDMVMLayoutNode.DMVMContext) {
|
||||
IDMContext<?> dmc = ((AbstractDMVMLayoutNode.DMVMContext)element).getDMC();
|
||||
return DMContexts.getAncestorOfType(dmc, IRegisterGroupDMContext.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IRegisterDMContext getRegisterDMC(Object element) {
|
||||
if (element instanceof IAdaptable) {
|
||||
return (IRegisterDMContext) ((IAdaptable) element).getAdapter(IRegisterDMContext.class);
|
||||
if (element instanceof AbstractDMVMLayoutNode.DMVMContext) {
|
||||
IDMContext<?> dmc = ((AbstractDMVMLayoutNode.DMVMContext)element).getDMC();
|
||||
return DMContexts.getAncestorOfType(dmc, IRegisterDMContext.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IFormattedDataDMContext<?> getFormattedDMC(Object element) {
|
||||
if (element instanceof IAdaptable) {
|
||||
return (IFormattedDataDMContext<?>) ((IAdaptable) element).getAdapter(IFormattedDataDMContext.class);
|
||||
if (element instanceof AbstractDMVMLayoutNode.DMVMContext) {
|
||||
IDMContext<?> dmc = ((AbstractDMVMLayoutNode.DMVMContext)element).getDMC();
|
||||
IRegisterDMContext regdmc = DMContexts.getAncestorOfType(dmc, IRegisterDMContext.class);
|
||||
return DMContexts.getAncestorOfType(regdmc, IFormattedDataDMContext.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -772,7 +779,13 @@ public class SyncRegisterDataAccess {
|
|||
* Get the DMC and the session. If element is not an register DMC, or
|
||||
* session is stale, then bail out.
|
||||
*/
|
||||
IFormattedDataDMContext<?> dmc = getFormattedDMC(element);
|
||||
IFormattedDataDMContext<?> dmc = null;
|
||||
if (element instanceof AbstractDMVMLayoutNode.DMVMContext) {
|
||||
IDMContext<?> vmcdmc = ((AbstractDMVMLayoutNode.DMVMContext)element).getDMC();
|
||||
IRegisterDMContext regdmc = DMContexts.getAncestorOfType(vmcdmc, IRegisterDMContext.class);
|
||||
dmc = DMContexts.getAncestorOfType(regdmc, IFormattedDataDMContext.class);
|
||||
}
|
||||
|
||||
if (dmc == null) return null;
|
||||
DsfSession session = DsfSession.getSession(dmc.getSessionId());
|
||||
if (session == null) return null;
|
||||
|
@ -799,7 +812,7 @@ public class SyncRegisterDataAccess {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class GetFormattedValueValueQuery extends Query<Object> {
|
||||
|
||||
private IFormattedDataDMContext<?> fDmc;
|
||||
|
@ -864,13 +877,59 @@ public class SyncRegisterDataAccess {
|
|||
}
|
||||
}
|
||||
|
||||
public String getFormattedValue(Object element, String formatId) {
|
||||
public String getFormattedRegisterValue(Object element, String formatId) {
|
||||
|
||||
/*
|
||||
* Get the DMC and the session. If element is not an register DMC, or
|
||||
* session is stale, then bail out.
|
||||
*/
|
||||
IFormattedDataDMContext<?> dmc = getFormattedDMC(element);
|
||||
IFormattedDataDMContext<?> dmc = null;
|
||||
if (element instanceof AbstractDMVMLayoutNode.DMVMContext) {
|
||||
IDMContext<?> vmcdmc = ((AbstractDMVMLayoutNode.DMVMContext)element).getDMC();
|
||||
IRegisterDMContext regdmc = DMContexts.getAncestorOfType(vmcdmc, IRegisterDMContext.class);
|
||||
dmc = DMContexts.getAncestorOfType(regdmc, IFormattedDataDMContext.class);
|
||||
}
|
||||
|
||||
if (dmc == null) return null;
|
||||
DsfSession session = DsfSession.getSession(dmc.getSessionId());
|
||||
if (session == null) return null;
|
||||
|
||||
/*
|
||||
* Create the query to write the value to the service. Note: no need to
|
||||
* guard agains RejectedExecutionException, because
|
||||
* DsfSession.getSession() above would only return an active session.
|
||||
*/
|
||||
GetFormattedValueValueQuery query = new GetFormattedValueValueQuery(dmc, formatId);
|
||||
session.getExecutor().execute(query);
|
||||
|
||||
/*
|
||||
* Now we have the data, go and get it. Since the call is completed now
|
||||
* the ".get()" will not suspend it will immediately return with the
|
||||
* data.
|
||||
*/
|
||||
try {
|
||||
return (String) query.get();
|
||||
} catch (InterruptedException e) {
|
||||
assert false;
|
||||
return null;
|
||||
} catch (ExecutionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getFormattedBitFieldValue(Object element, String formatId) {
|
||||
|
||||
/*
|
||||
* Get the DMC and the session. If element is not an register DMC, or
|
||||
* session is stale, then bail out.
|
||||
*/
|
||||
IFormattedDataDMContext<?> dmc = null;
|
||||
if (element instanceof AbstractDMVMLayoutNode.DMVMContext) {
|
||||
IDMContext<?> vmcdmc = ((AbstractDMVMLayoutNode.DMVMContext)element).getDMC();
|
||||
IBitFieldDMContext bitfielddmc = DMContexts.getAncestorOfType(vmcdmc, IBitFieldDMContext.class);
|
||||
dmc = DMContexts.getAncestorOfType(bitfielddmc, IFormattedDataDMContext.class);
|
||||
}
|
||||
|
||||
if (dmc == null) return null;
|
||||
DsfSession session = DsfSession.getSession(dmc.getSessionId());
|
||||
if (session == null) return null;
|
||||
|
|
Loading…
Add table
Reference in a new issue