|
Lines 9-14
Link Here
|
| 9 |
* Wind River Systems - initial API and implementation |
9 |
* Wind River Systems - initial API and implementation |
| 10 |
* Freescale Semiconductor - refactoring |
10 |
* Freescale Semiconductor - refactoring |
| 11 |
* Patrick Chuong (Texas Instruments) - Bug 323279 |
11 |
* Patrick Chuong (Texas Instruments) - Bug 323279 |
|
|
12 |
* Patrick Chuong (Texas Instruments) - Bug fix (329682) |
| 12 |
*******************************************************************************/ |
13 |
*******************************************************************************/ |
| 13 |
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; |
14 |
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; |
| 14 |
|
15 |
|
|
Lines 29-34
Link Here
|
| 29 |
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; |
30 |
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; |
| 30 |
import org.eclipse.cdt.dsf.concurrent.DsfExecutor; |
31 |
import org.eclipse.cdt.dsf.concurrent.DsfExecutor; |
| 31 |
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; |
32 |
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; |
|
|
33 |
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; |
| 32 |
import org.eclipse.cdt.dsf.concurrent.Query; |
34 |
import org.eclipse.cdt.dsf.concurrent.Query; |
| 33 |
import org.eclipse.cdt.dsf.datamodel.DMContexts; |
35 |
import org.eclipse.cdt.dsf.datamodel.DMContexts; |
| 34 |
import org.eclipse.cdt.dsf.datamodel.IDMContext; |
36 |
import org.eclipse.cdt.dsf.datamodel.IDMContext; |
|
Lines 61-66
Link Here
|
| 61 |
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; |
63 |
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; |
| 62 |
import org.eclipse.core.runtime.IAdaptable; |
64 |
import org.eclipse.core.runtime.IAdaptable; |
| 63 |
import org.eclipse.core.runtime.IStatus; |
65 |
import org.eclipse.core.runtime.IStatus; |
|
|
66 |
import org.eclipse.core.runtime.Status; |
| 64 |
import org.eclipse.jface.dialogs.ErrorDialog; |
67 |
import org.eclipse.jface.dialogs.ErrorDialog; |
| 65 |
import org.eclipse.jface.text.BadLocationException; |
68 |
import org.eclipse.jface.text.BadLocationException; |
| 66 |
import org.eclipse.jface.text.Position; |
69 |
import org.eclipse.jface.text.Position; |
|
Lines 861-917
Link Here
|
| 861 |
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#gotoSymbol(java.lang.String) |
864 |
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#gotoSymbol(java.lang.String) |
| 862 |
*/ |
865 |
*/ |
| 863 |
public void gotoSymbol(final String symbol) { |
866 |
public void gotoSymbol(final String symbol) { |
| 864 |
final DsfExecutor executor= getSession().getExecutor(); |
867 |
evaluateSymbolAddress(symbol, false, new DataRequestMonitor<BigInteger>(getSession().getExecutor(), null) { |
| 865 |
executor.execute(new DsfRunnable() { |
868 |
@Override |
| 866 |
public void run() { |
869 |
protected void handleSuccess() { |
| 867 |
final IExpressions expressions= getService(IExpressions.class); |
870 |
final BigInteger address = getData(); |
| 868 |
if (expressions == null) { |
871 |
if (address != null) { |
| 869 |
return; |
872 |
fCallback.asyncExec(new Runnable() { |
|
|
873 |
public void run() { |
| 874 |
fCallback.gotoAddress(address); |
| 875 |
}}); |
| 870 |
} |
876 |
} |
| 871 |
final IExpressionDMContext exprDmc= expressions.createExpression(fTargetContext, symbol); |
877 |
} |
| 872 |
// first, try to get l-value address |
878 |
}); |
| 873 |
expressions.getExpressionAddressData(exprDmc, new DataRequestMonitor<IExpressionDMAddress>(executor, null) { |
879 |
} |
|
|
880 |
|
| 881 |
/* |
| 882 |
* (non-Javadoc) |
| 883 |
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#evaluateSymbolAddress(java.lang.String, boolean) |
| 884 |
*/ |
| 885 |
public BigInteger evaluateSymbolAddress(final String symbol, final boolean suppressError) { |
| 886 |
Query<BigInteger> query = new Query<BigInteger>() { |
| 887 |
@Override |
| 888 |
protected void execute(DataRequestMonitor<BigInteger> rm) { |
| 889 |
evaluateSymbolAddress(symbol, suppressError, rm); |
| 890 |
} |
| 891 |
}; |
| 892 |
getSession().getExecutor().execute(query); |
| 893 |
try { |
| 894 |
return query.get(); |
| 895 |
} catch (Exception e) { |
| 896 |
return null; |
| 897 |
} |
| 898 |
} |
| 899 |
|
| 900 |
private void evaluateSymbolAddress(final String symbol, final boolean suppressError, final DataRequestMonitor<BigInteger> rm) { |
| 901 |
final IExpressions expressions= getService(IExpressions.class); |
| 902 |
if (expressions == null) { |
| 903 |
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.REQUEST_FAILED, "", null)); //$NON-NLS-1$ |
| 904 |
rm.done(); |
| 905 |
return; |
| 906 |
} |
| 907 |
|
| 908 |
final IExpressionDMContext exprDmc= expressions.createExpression(fTargetContext, symbol); |
| 909 |
// first, try to get l-value address |
| 910 |
expressions.getExpressionAddressData(exprDmc, new DataRequestMonitor<IExpressionDMAddress>(getSession().getExecutor(), null) { |
| 911 |
@Override |
| 912 |
protected void handleSuccess() { |
| 913 |
IExpressionDMAddress data = getData(); |
| 914 |
IAddress address = data.getAddress(); |
| 915 |
rm.setData(address.getValue()); |
| 916 |
rm.done(); |
| 917 |
} |
| 918 |
@Override |
| 919 |
protected void handleError() { |
| 920 |
// not an l-value, evaluate expression |
| 921 |
final FormattedValueDMContext valueDmc= expressions.getFormattedValueContext(exprDmc, IFormattedValues.HEX_FORMAT); |
| 922 |
expressions.getFormattedExpressionValue(valueDmc, new DataRequestMonitor<FormattedValueDMData>(getSession().getExecutor(), null) { |
| 874 |
@Override |
923 |
@Override |
| 875 |
protected void handleSuccess() { |
924 |
protected void handleSuccess() { |
| 876 |
IExpressionDMAddress data = getData(); |
925 |
FormattedValueDMData data= getData(); |
| 877 |
final IAddress address = data.getAddress(); |
926 |
String value= data.getFormattedValue(); |
| 878 |
if (address != null) { |
927 |
BigInteger address= null; |
| 879 |
fCallback.asyncExec(new Runnable() { |
928 |
try { |
| 880 |
public void run() { |
929 |
address = DisassemblyUtils.decodeAddress(value); |
| 881 |
fCallback.gotoAddress(address.getValue()); |
930 |
} catch (final Exception e) { |
| 882 |
}}); |
931 |
// "value" can be empty i.e *fooX, where fooX is a variable. |
|
|
932 |
// Not sure if this is a bug or not. So, fail the request instead. |
| 933 |
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.REQUEST_FAILED, "", null)); //$NON-NLS-1$ |
| 934 |
|
| 935 |
if (!suppressError) { |
| 936 |
fCallback.asyncExec(new Runnable() { |
| 937 |
public void run() { |
| 938 |
ErrorDialog.openError(fCallback.getSite().getShell(), "Error", null, //$NON-NLS-1$ |
| 939 |
new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.REQUEST_FAILED, |
| 940 |
"Symbol does not evaluate to an address (" + e.getMessage() + ")", null)); //$NON-NLS-1$ //$NON-NLS-2$ |
| 941 |
}}); |
| 942 |
} |
| 883 |
} |
943 |
} |
|
|
944 |
rm.setData(address); |
| 945 |
rm.done(); |
| 884 |
} |
946 |
} |
| 885 |
@Override |
947 |
@Override |
| 886 |
protected void handleError() { |
948 |
protected void handleError() { |
| 887 |
// not an l-value, evaluate expression |
949 |
if (!suppressError) { |
| 888 |
final FormattedValueDMContext valueDmc= expressions.getFormattedValueContext(exprDmc, IFormattedValues.HEX_FORMAT); |
950 |
fCallback.asyncExec(new Runnable() { |
| 889 |
expressions.getFormattedExpressionValue(valueDmc, new DataRequestMonitor<FormattedValueDMData>(executor, null) { |
951 |
public void run() { |
| 890 |
@Override |
952 |
ErrorDialog.openError(fCallback.getSite().getShell(), "Error", null, getStatus()); //$NON-NLS-1$ |
| 891 |
protected void handleSuccess() { |
953 |
}}); |
| 892 |
FormattedValueDMData data= getData(); |
954 |
} |
| 893 |
final String value= data.getFormattedValue(); |
955 |
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.REQUEST_FAILED, "", null)); //$NON-NLS-1$ |
| 894 |
final BigInteger address= DisassemblyUtils.decodeAddress(value); |
956 |
rm.done(); |
| 895 |
if (address != null) { |
|
|
| 896 |
fCallback.asyncExec(new Runnable() { |
| 897 |
public void run() { |
| 898 |
fCallback.gotoAddress(address); |
| 899 |
}}); |
| 900 |
} |
| 901 |
} |
| 902 |
@Override |
| 903 |
protected void handleError() { |
| 904 |
fCallback.asyncExec(new Runnable() { |
| 905 |
public void run() { |
| 906 |
ErrorDialog.openError(fCallback.getSite().getShell(), "Error", null, getStatus()); //$NON-NLS-1$ |
| 907 |
}}); |
| 908 |
} |
| 909 |
}); |
| 910 |
} |
957 |
} |
| 911 |
}); |
958 |
}); |
| 912 |
}}); |
959 |
} |
|
|
960 |
}); |
| 913 |
} |
961 |
} |
| 914 |
|
962 |
|
| 915 |
/* (non-Javadoc) |
963 |
/* (non-Javadoc) |
| 916 |
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#retrieveDisassembly(java.lang.String, int, java.math.BigInteger, boolean, boolean, boolean) |
964 |
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#retrieveDisassembly(java.lang.String, int, java.math.BigInteger, boolean, boolean, boolean) |
| 917 |
*/ |
965 |
*/ |