1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-07-11 12:01:16 -04:00
commit 747755991f
104 changed files with 3136 additions and 780 deletions

View file

@ -127,6 +127,14 @@ public class MingwEnvironmentVariableSupplier implements IConfigurationEnvironme
return mingwBinDir;
}
// Check for MinGW-w64 on Windows 64 bit, see http://mingw-w64.sourceforge.net/
if (Platform.ARCH_X86_64.equals(Platform.getOSArch())) {
IPath gcc64Loc = PathUtil.findProgramLocation("x86_64-w64-mingw32-gcc.exe", envPathValueCached); //$NON-NLS-1$
if (gcc64Loc != null) {
return gcc64Loc.removeLastSegments(1);
}
}
// Look in PATH values. Look for mingw32-gcc.exe
// TODO: Since this dir is already in the PATH, why are we adding it here?
// This is really only to support isToolchainAvail. Must be a better way.

View file

@ -68,6 +68,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
@ -132,6 +133,17 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
try {
treeRoot = option.getTreeRoot();
TreeSelectionDialog dlg = new TreeSelectionDialog(getShell(), treeRoot, nameStr, contextId);
String name = getStringValue();
if (name != null) {
String treeId = option.getId(name);
if (treeId != null) {
ITreeOption node = treeRoot.findNode(treeId);
if (node != null) {
dlg.setSelection(node);
}
}
}
if (dlg.open() == Window.OK) {
ITreeOption selected = dlg.getSelection();
return selected.getName();
@ -1073,7 +1085,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
}
/**
* @since 8.1
* @since 8.2
*/
public static class TreeSelectionDialog extends TitleAreaDialog {
private final ITreeRoot treeRoot;
@ -1081,6 +1093,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
private final String name;
private String contextId;
private String baseMessage = ""; //$NON-NLS-1$
private TreeViewer viewer;
public TreeSelectionDialog(Shell parentShell, ITreeRoot root, String name, String contextId) {
super(parentShell);
@ -1117,7 +1130,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
FilteredTree tree = new FilteredTree(control,
SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER,
filter, true);
final TreeViewer viewer = tree.getViewer();
viewer = tree.getViewer();
viewer.setContentProvider(new ITreeContentProvider() {
@Override
@ -1276,10 +1289,42 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
return control;
}
@Override
public void create() {
super.create();
// Need to update selection after the dialog has been created
// so that we trigger the listener and correctly update the label
// and buttons
setUISelection();
}
public ITreeOption getSelection() {
return selected;
}
public void setSelection(ITreeOption option) {
if (treeRoot == getRoot(option)) { // only work in the same tree
selected = option;
setUISelection();
}
}
private void setUISelection() {
if (viewer != null && selected != null) viewer.setSelection(new StructuredSelection(selected), true);
}
private static ITreeRoot getRoot(ITreeOption option) {
if (option != null) {
ITreeOption parent = option.getParent();
while (parent != null) {
option = parent;
parent = option.getParent();
}
return option instanceof ITreeRoot? (ITreeRoot) option : null;
}
return null;
}
private Image createImage(String icon) {
if (icon != null) {
URL url = null;

View file

@ -18,22 +18,19 @@ package org.eclipse.cdt.core.dom.ast;
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class DOMException extends Exception {
private static final long serialVersionUID = 0;
IProblemBinding problemBinding;
/**
* @param problem
* binding for throwing
*
* @param problem the binding for throwing
*/
public DOMException(IProblemBinding problem) {
problemBinding = problem;
}
/**
* Get the problem associated w/this exception.
* Returns the problem associated w/this exception.
*
* @return problem
*/

View file

@ -8,20 +8,18 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
/**
* C++ specific initializer clause
* C++ specific initializer clause.
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @since 5.5
*/
public interface ICPPASTInitializerClause extends IASTInitializerClause {
/**
* Returns the evaluation object for this expression.
* @noreference This method is not intended to be referenced by clients.

View file

@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
/**
* Base interface for methods, also used for constructors.
*
@ -18,7 +17,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPMethod extends ICPPFunction, ICPPMember {
public static final ICPPMethod [] EMPTY_CPPMETHOD_ARRAY = new ICPPMethod[0];
public static final ICPPMethod[] EMPTY_CPPMETHOD_ARRAY = {};
/**
* Returns whether this method is declared to be virtual. Does not detect whether
@ -27,9 +26,9 @@ public interface ICPPMethod extends ICPPFunction, ICPPMember {
public boolean isVirtual();
/**
* is this a destructor
* Is this a destructor?
*
* returns true if its name starts with '~'
* Returns true if its name starts with '~'
*/
public boolean isDestructor();

View file

@ -21,12 +21,12 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
*/
public interface ICPPNamespace extends ICPPBinding {
/**
* get the scope object associated with this namespace
* Returns the scope object associated with this namespace
*/
public ICPPNamespaceScope getNamespaceScope();
/**
* get an array of the all the bindings declared in this namespace.
* Returns an array of the all the bindings declared in this namespace.
*/
public IBinding[] getMemberBindings();

View file

@ -17,10 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPNamespaceAlias extends ICPPNamespace {
/**
* get the binding of the original namespace.
* Returns the binding of the original namespace.
*/
public IBinding getBinding();
}

View file

@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
/**
* A namespace scope is either a block-scope or a namespace-scope or global scope.
*
@ -19,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast.cpp;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPNamespaceScope extends ICPPScope {
/**
* @since 5.3
*/

View file

@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IParameter;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPParameter extends IParameter, ICPPVariable {
/**
* @since 5.2
*/

View file

@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
* @since 5.2
*/
public interface ICPPParameterPackType extends IType {
/**
* Returns the pattern for the pack-expansion
*/

View file

@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPReferenceType extends IType {
/**
* Returns the type that this is a reference of
*/

View file

@ -17,5 +17,4 @@ import org.eclipse.cdt.core.dom.ast.IScope;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPScope extends IScope {
}

View file

@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
/**
* Base interface for all template definitions including explicit (partial) specializations.
*
@ -19,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast.cpp;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPTemplateDefinition extends ICPPBinding {
/**
* Returns an array of the template parameters.
* In the case of a specialization, the array will be empty,

View file

@ -9,7 +9,6 @@
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.IType;

View file

@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
* @noextend This interface is not intended to be extended by clients.
*/
public interface ICPPTemplateNonTypeParameter extends ICPPTemplateParameter, ICPPVariable {
/**
* @deprecated, use {@link ICPPTemplateParameter#getDefaultValue()}.
*/

View file

@ -18,7 +18,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPTemplateParameter extends ICPPBinding {
public static final ICPPTemplateParameter[] EMPTY_TEMPLATE_PARAMETER_ARRAY = new ICPPTemplateParameter[0];
public static final ICPPTemplateParameter[] EMPTY_TEMPLATE_PARAMETER_ARRAY = {};
/**
* Returns the zero-based position of this parameter within the template parameter list it belongs to.

View file

@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
/**
* Models the mapping of template parameters to values, or pack-expansions.
*
@ -19,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast.cpp;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPTemplateParameterMap {
/**
* Returns the value for the template parameter with the given id.
* @see ICPPTemplateParameter#getParameterID()
@ -32,7 +30,6 @@ public interface ICPPTemplateParameterMap {
*/
public ICPPTemplateArgument getArgument(ICPPTemplateParameter param);
/**
* Returns the values for the template parameter pack with the given id in the map,
* or <code>null</code> if the parameter is not mapped or is not a parameter pack.

View file

@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPTemplateTemplateParameter extends ICPPTemplateParameter, ICPPClassTemplate {
@Override
public ICPPTemplateParameter[] getTemplateParameters();

View file

@ -18,17 +18,15 @@ import org.eclipse.cdt.core.dom.ast.IType;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPTemplateTypeParameter extends ICPPTemplateParameter, IType {
/**
* The default type for this parameter. May be null
*
* The default type for this parameter. May be {@code null}.
*/
public IType getDefault() throws DOMException;
/**
* Types containing template parameters need to be compared even before it is known to which
* binding the template parameter belongs to. Therefore {@link #isSameType(IType)} compares the
* kind and the parameter position of the template parameter, only. The name and the owner
* binding the template parameter belongs to. Therefore {@link #isSameType(IType)} compares
* the kind and the parameter position of the template parameter, only. The name and the owner
* is ignored.
*
* @since 5.1

View file

@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPUsingDeclaration extends ICPPBinding {
/**
* Return an array of bindings that were declared by this using declaration.
* Each of these bindings delegates to some previously declared binding to which it

View file

@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPUsingDirective {
ICPPUsingDirective[] EMPTY_ARRAY = new ICPPUsingDirective[0];
ICPPUsingDirective[] EMPTY_ARRAY = {};
/**
* Returns the scope of the namespace that is nominated by this

View file

@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPVariable extends IVariable, ICPPBinding {
/**
* does this variable have the mutable storage class specifier
*/

View file

@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
* Provides additional methods for internal use by the name resolution.
*/
public interface IASTInternalNameOwner extends IASTNameOwner {
/**
* Get the role for the name. If the name needs to be resolved to determine that and
* <code>allowResolution</code> is set to <code>false</code>, then {@link IASTNameOwner#r_unclear}

View file

@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
* Internal interface for bindings in the ast that have values.
*/
public interface IInternalVariable extends IVariable {
/**
* Returns the value of the variable, or <code>null</code>.
* If the recursion depth is reached {@link Value#UNKNOWN} will be returned.

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.core.runtime.CoreException;
/**
* Interface for marshalling types for storage in the index.
*/

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.core.runtime.CoreException;
/**
* Interface for marshalling types for storage in the index.
*/

View file

@ -18,12 +18,12 @@ import org.eclipse.cdt.core.dom.ast.IType;
*/
public interface ITypeContainer extends IType {
/**
* get the type this contains
* Returns the type this container contains.
*/
IType getType();
/**
* set the type this contains
* Sets the type this container contains.
*/
void setType(IType type);
}

View file

@ -63,6 +63,7 @@ public interface ITypeMarshalBuffer {
ISerializableEvaluation unmarshalEvaluation() throws CoreException;
int getByte() throws CoreException;
int getShort() throws CoreException;
int getInt() throws CoreException;
long getLong() throws CoreException;
char[] getCharArray() throws CoreException;
@ -72,6 +73,7 @@ public interface ITypeMarshalBuffer {
void marshalEvaluation(ISerializableEvaluation eval, boolean includeValue) throws CoreException;
void putByte(byte data);
void putShort(short data);
void putInt(int data);
void putLong(long data);
void putCharArray(char[] data);
}

View file

@ -8,14 +8,12 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.parser.AbstractParserLogService;
import org.eclipse.cdt.core.parser.IParserLogService;
public class ParserLogServiceWrapper extends AbstractParserLogService {
private IParserLogService fDelegate;
public ParserLogServiceWrapper(IParserLogService log) {

View file

@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
import org.eclipse.core.runtime.CoreException;
/**
* Implementation of problem types.
*/

View file

@ -45,8 +45,8 @@ import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
import org.eclipse.core.runtime.CoreException;
/**
* Represents values of variables, enumerators or expressions. The primary purpose of the representation
* is to support instantiation of templates with non-type template parameters.
* Represents values of variables, enumerators or expressions. The primary purpose of
* the representation is to support instantiation of templates with non-type template parameters.
*/
public class Value implements IValue {
public static final int MAX_RECURSION_DEPTH = 25;
@ -94,7 +94,7 @@ public class Value implements IValue {
fMap= map;
}
public void nextSeperator() throws UnknownValueException {
public void nextSeparator() throws UnknownValueException {
final char[] expression = fExpression;
final int len = expression.length;
int idx = pos;
@ -158,7 +158,7 @@ public class Value implements IValue {
return parseLong(fExpression);
}
public void marshall(TypeMarshalBuffer buf) throws CoreException {
public void marshall(ITypeMarshalBuffer buf) throws CoreException {
if (UNKNOWN == this) {
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG1));
} else {
@ -183,7 +183,7 @@ public class Value implements IValue {
}
}
public static IValue unmarshal(TypeMarshalBuffer buf) throws CoreException {
public static IValue unmarshal(ITypeMarshalBuffer buf) throws CoreException {
int firstByte= buf.getByte();
if (firstByte == TypeMarshalBuffer.NULL_TYPE)
return null;
@ -783,17 +783,17 @@ public class Value implements IValue {
switch (c) {
case BINARY_OP_CHAR:
int op= parseNonNegative(buf, idx + 1);
reeval.nextSeperator();
reeval.nextSeparator();
Object o1= reevaluate(reeval, maxdepth);
Object o2= reevaluate(reeval, maxdepth);
return combineBinary(op, o1, o2);
case UNARY_OP_CHAR:
op= parseNonNegative(buf, idx + 1);
reeval.nextSeperator();
reeval.nextSeparator();
o1= reevaluate(reeval, maxdepth);
return combineUnary(op, o1);
case CONDITIONAL_CHAR:
reeval.nextSeperator();
reeval.nextSeparator();
Object cond= reevaluate(reeval, maxdepth);
Object po= reevaluate(reeval, maxdepth);
Object neg= reevaluate(reeval, maxdepth);
@ -811,12 +811,12 @@ public class Value implements IValue {
final IBinding[] resolvedUnknowns= reeval.fResolvedUnknown;
if (num >= resolvedUnknowns.length)
throw UNKNOWN_EX;
reeval.nextSeperator();
reeval.nextSeparator();
return evaluateBinding(resolvedUnknowns[num], reeval.fUnknownSigs, reeval.fUnknowns, maxdepth);
case TEMPLATE_PARAM_CHAR:
num= parseHex(buf, idx + 1);
reeval.nextSeperator();
reeval.nextSeparator();
ICPPTemplateArgument arg = reeval.fMap.getArgument(num);
if (arg != null) {
IValue val= arg.getNonTypeValue();
@ -828,7 +828,7 @@ public class Value implements IValue {
case TEMPLATE_PARAM_PACK_CHAR:
num= parseHex(buf, idx + 1);
reeval.nextSeperator();
reeval.nextSeparator();
arg= null;
if (reeval.fPackOffset >= 0) {
ICPPTemplateArgument[] args= reeval.fMap.getPackExpansion(num);
@ -845,7 +845,7 @@ public class Value implements IValue {
return createTemplateParamExpression(num, true);
default:
reeval.nextSeperator();
reeval.nextSeparator();
return parseLong(buf, idx);
}
}
@ -993,7 +993,7 @@ public class Value implements IValue {
}
public static IValue create(ICPPEvaluation eval, IASTNode point) {
// compute value of evaluation
// Compute value of evaluation
return Value.UNKNOWN;
}
}

View file

@ -59,13 +59,9 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
@Override
public CPPASTLiteralExpression copy(CopyStyle style) {
CPPASTLiteralExpression copy = new CPPASTLiteralExpression(kind,
value == null ? null : value.clone());
copy.setOffsetAndLength(this);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
CPPASTLiteralExpression copy =
new CPPASTLiteralExpression(kind, value == null ? null : value.clone());
return copy(copy, style);
}
@Override

View file

@ -57,11 +57,11 @@ public class CPPClassSpecialization extends CPPSpecialization
private ObjectMap specializationMap= ObjectMap.EMPTY_MAP;
private final ThreadLocal<Set<IBinding>> fInProgress= new ThreadLocal<Set<IBinding>>();
public CPPClassSpecialization(ICPPClassType specialized, IBinding owner, ICPPTemplateParameterMap argumentMap) {
public CPPClassSpecialization(ICPPClassType specialized, IBinding owner,
ICPPTemplateParameterMap argumentMap) {
super(specialized, owner, argumentMap);
}
@Override
public ICPPClassType getSpecializedBinding() {
return (ICPPClassType) super.getSpecializedBinding();
@ -233,9 +233,6 @@ public class CPPClassSpecialization extends CPPSpecialization
return specScope;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
@Override
public boolean isSameType(IType type) {
if (type == this)
@ -251,7 +248,6 @@ public class CPPClassSpecialization extends CPPSpecialization
@Override
public Object clone() {
// TODO Auto-generated method stub
return this;
}

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
@ -24,10 +23,40 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
boolean isInitializerList();
boolean isFunctionSet();
/**
* Returns {@code true} if the type of the expression depends on template parameters.
*/
boolean isTypeDependent();
/**
* Returns {@code true} if the value of the expression depends on template parameters.
*/
boolean isValueDependent();
/**
* TODO Add description
*
* @param point determines the scope for name lookups
*/
IType getTypeOrFunctionSet(IASTNode point);
/**
* TODO Add description
*
* @param point determines the scope for name lookups
*/
IValue getValue(IASTNode point);
/**
* TODO Add description
*
* @param point determines the scope for name lookups
*/
ValueCategory getValueCategory(IASTNode point);
/**
* Returns a signature uniquely identifying the evaluation. Two evaluations with identical
* signatures are guaranteed to produce the same results.
*/
char[] getSignature();
}

View file

@ -0,0 +1,228 @@
/*******************************************************************************
* Copyright (c) 2012 Google, Inc 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.core.runtime.CoreException;
public abstract class CPPEvaluation implements ICPPEvaluation {
private static class SignatureBuilder implements ITypeMarshalBuffer {
private static final byte NULL_TYPE= 0;
private static final byte UNSTORABLE_TYPE= (byte) -1;
private static final char[] HEX_DIGITS =
{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
private final StringBuilder fBuffer;
private boolean hexMode;
/**
* Constructor for input buffer.
*/
public SignatureBuilder() {
fBuffer= new StringBuilder();
}
@Override
public String toString() {
return fBuffer.toString();
}
@Override
public void marshalBinding(IBinding binding) throws CoreException {
if (binding instanceof ISerializableType) {
((ISerializableType) binding).marshal(this);
} else if (binding == null) {
putByte(NULL_TYPE);
} else {
appendSeparator();
IBinding owner= binding.getOwner();
if (owner instanceof IType) {
ASTTypeUtil.appendType((IType) owner, true, fBuffer);
fBuffer.append("::"); //$NON-NLS-1$
}
fBuffer.append(binding.getName());
}
}
@Override
public void marshalType(IType type) throws CoreException {
if (type instanceof ISerializableType) {
((ISerializableType) type).marshal(this);
} else if (type == null) {
putByte(NULL_TYPE);
} else if (type instanceof IBinding) {
marshalBinding((IBinding) type);
} else {
assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
putByte(UNSTORABLE_TYPE);
}
}
@Override
public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException {
if (eval == null) {
putByte(NULL_TYPE);
} else {
eval.marshal(this, includeValues);
}
}
@Override
public void marshalValue(IValue value) throws CoreException {
if (value instanceof Value) {
((Value) value).marshall(this);
} else {
putByte(NULL_TYPE);
}
}
@Override
public void putByte(byte b) {
appendHexDigit(b >> 4);
appendHexDigit(b);
}
@Override
public void putShort(short value) {
appendHexDigit(value >> 12);
appendHexDigit(value >> 8);
appendHexDigit(value >> 4);
appendHexDigit(value);
}
@Override
public void putInt(int value) {
appendHexDigit(value >> 28);
appendHexDigit(value >> 24);
appendHexDigit(value >> 20);
appendHexDigit(value >> 16);
appendHexDigit(value >> 12);
appendHexDigit(value >> 8);
appendHexDigit(value >> 4);
appendHexDigit(value);
}
@Override
public void putLong(long value) {
appendHexDigit((int) (value >> 60));
appendHexDigit((int) (value >> 56));
appendHexDigit((int) (value >> 52));
appendHexDigit((int) (value >> 48));
appendHexDigit((int) (value >> 44));
appendHexDigit((int) (value >> 40));
appendHexDigit((int) (value >> 36));
appendHexDigit((int) (value >> 32));
appendHexDigit((int) (value >> 28));
appendHexDigit((int) (value >> 24));
appendHexDigit((int) (value >> 20));
appendHexDigit((int) (value >> 16));
appendHexDigit((int) (value >> 12));
appendHexDigit((int) (value >> 8));
appendHexDigit((int) (value >> 4));
appendHexDigit((int) value);
}
@Override
public void putCharArray(char[] chars) {
appendSeparator();
for (char c : chars) {
fBuffer.append(c);
}
}
private void appendHexDigit(int val) {
if (hexMode) {
appendSeparator();
fBuffer.append("0x"); //$NON-NLS-1$
hexMode = true;
}
fBuffer.append(HEX_DIGITS[val & 0xF]);
}
private void appendSeparator() {
if (fBuffer.length() != 0)
fBuffer.append(' ');
hexMode = false;
}
@Override
public IBinding unmarshalBinding() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public IType unmarshalType() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public ISerializableEvaluation unmarshalEvaluation() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public IValue unmarshalValue() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public int getByte() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public CoreException unmarshallingError() {
throw new UnsupportedOperationException();
}
@Override
public int getShort() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public int getInt() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public long getLong() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public char[] getCharArray() throws CoreException {
throw new UnsupportedOperationException();
}
}
@Override
public char[] getSignature() {
SignatureBuilder buf = new SignatureBuilder();
try {
marshal(buf, true);
} catch (CoreException e) {
CCorePlugin.log(e);
return new char[] { '?' };
}
return buf.toString().toCharArray();
}
}

View file

@ -1,10 +1,13 @@
/*
* CPPFunctionSet.java
* Created on Sep 13, 2010
/*******************************************************************************
* Copyright (c) 2010 Wind River Systems, Inc. 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
*
* Copyright 2010 Wind River Systems, Inc. All rights reserved.
*/
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import org.eclipse.cdt.core.dom.ILinkage;
@ -25,7 +28,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPTwoPhaseBinding;
* The actual function can be resolved in certain contexts.
*/
public class CPPFunctionSet implements ICPPTwoPhaseBinding {
private final ICPPFunction[] fBindings;
private final IASTName fName;
private final ICPPTemplateArgument[] fTemplateArguments;

View file

@ -857,7 +857,8 @@ public class CPPTemplates {
}
}
public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, int maxdepth, IASTNode point) {
public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
if (value == null)
return null;
IBinding[] unknowns= value.getUnknownBindings();
@ -1144,7 +1145,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM
}
/**
* Instantiates the given type with the provided map and packoffset.
* Instantiates the given type with the provided map and packОffset.
* The context is used to replace templates with their specialization, where appropriate.
* @param point
*/

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -44,7 +43,7 @@ import org.eclipse.core.runtime.CoreException;
/**
* Performs evaluation of an expression.
*/
public class EvalBinary implements ICPPEvaluation {
public class EvalBinary extends CPPEvaluation {
public final static int op_arrayAccess= Byte.MAX_VALUE;
private final int fOperator;
@ -206,7 +205,6 @@ public class EvalBinary implements ICPPEvaluation {
return ExpressionTypes.restoreTypedefs(type, originalType1, originalType2);
}
switch (fOperator) {
case op_arrayAccess:
if (type1 instanceof IPointerType) {

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
@ -24,13 +23,12 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.core.runtime.CoreException;
/**
* Performs evaluation of an expression.
*/
public class EvalBinaryTypeId implements ICPPEvaluation {
public class EvalBinaryTypeId extends CPPEvaluation {
private final Operator fOperator;
private final IType fType1, fType2;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType;
@ -28,11 +27,10 @@ import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.core.runtime.CoreException;
public class EvalBinding implements ICPPEvaluation {
public class EvalBinding extends CPPEvaluation {
private final IBinding fBinding;
private final boolean fFixedType;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall;
@ -26,7 +25,7 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.core.runtime.CoreException;
public class EvalComma implements ICPPEvaluation {
public class EvalComma extends CPPEvaluation {
private static final ICPPFunction[] NO_FUNCTIONS = {};
private final ICPPEvaluation[] fArguments;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
@ -26,7 +25,7 @@ import org.eclipse.core.runtime.CoreException;
/**
* Performs evaluation of an expression.
*/
public class EvalCompound implements ICPPEvaluation {
public class EvalCompound extends CPPEvaluation {
private final ICPPEvaluation fDelegate;
public EvalCompound(ICPPEvaluation delegate) {

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
@ -42,7 +41,7 @@ import org.eclipse.core.runtime.CoreException;
/**
* Performs evaluation of an expression.
*/
public class EvalConditional implements ICPPEvaluation {
public class EvalConditional extends CPPEvaluation {
private final ICPPEvaluation fCondition, fPositive, fNegative;
private final boolean fPositiveThrows, fNegativeThrows;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -29,9 +28,9 @@ import org.eclipse.core.runtime.CoreException;
/**
* Performs evaluation of an expression.
*/
public class EvalFixed implements ICPPEvaluation {
public static final ICPPEvaluation INCOMPLETE = new EvalFixed(
ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, Value.UNKNOWN);
public class EvalFixed extends CPPEvaluation {
public static final ICPPEvaluation INCOMPLETE =
new EvalFixed(ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, Value.UNKNOWN);
private final IType fType;
private final IValue fValue;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType;
@ -37,7 +36,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
import org.eclipse.core.runtime.CoreException;
public class EvalFunctionCall implements ICPPEvaluation {
public class EvalFunctionCall extends CPPEvaluation {
private final ICPPEvaluation[] fArguments;
private ICPPFunction fOverload= CPPFunction.UNINITIALIZED_FUNCTION;
private IType fType;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
@ -22,14 +21,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.core.runtime.CoreException;
/**
* Performs evaluation of an expression.
*/
public class EvalFunctionSet implements ICPPEvaluation {
public class EvalFunctionSet extends CPPEvaluation {
private final CPPFunctionSet fFunctionSet;
private final boolean fAddressOf;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -44,7 +43,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.core.runtime.CoreException;
public class EvalID implements ICPPEvaluation {
public class EvalID extends CPPEvaluation {
private final ICPPEvaluation fFieldOwner;
private final char[] fName;
private final IBinding fNameOwner;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
@ -26,7 +25,7 @@ import org.eclipse.core.runtime.CoreException;
/**
* Performs evaluation of an expression.
*/
public class EvalInitList implements ICPPEvaluation {
public class EvalInitList extends CPPEvaluation {
private final ICPPEvaluation[] fClauses;
public EvalInitList(ICPPEvaluation[] clauses) {

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -47,7 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
import org.eclipse.core.runtime.CoreException;
public class EvalMemberAccess implements ICPPEvaluation {
public class EvalMemberAccess extends CPPEvaluation {
private final IType fOwnerType;
private final IBinding fMember;
private final ValueCategory fOwnerValueCategory;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType;
@ -27,7 +26,7 @@ import org.eclipse.core.runtime.CoreException;
/**
* Performs evaluation of an expression.
*/
public class EvalTypeId implements ICPPEvaluation {
public class EvalTypeId extends CPPEvaluation {
private final IType fInputType;
private final ICPPEvaluation[] fArguments;
private IType fOutputType;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -40,7 +39,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
import org.eclipse.core.runtime.CoreException;
public class EvalUnary implements ICPPEvaluation {
public class EvalUnary extends CPPEvaluation {
private static final ICPPEvaluation ZERO_EVAL = new EvalFixed(CPPSemantics.INT_TYPE, PRVALUE, Value.create(0));
private final int fOperator;

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -24,10 +23,9 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.core.runtime.CoreException;
public class EvalUnaryTypeID implements ICPPEvaluation {
public class EvalUnaryTypeID extends CPPEvaluation {
private final int fOperator;
private final IType fOrigType;
private IType fType;

View file

@ -12,7 +12,10 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.TypeSelection.PARAMETERS;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.TypeSelection.RETURN_TYPE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;

View file

@ -1,10 +1,13 @@
/*
* FunctionSetType.java
* Created on Sep 14, 2010
/*******************************************************************************
* Copyright (c) 2010 Wind River Systems, Inc. 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
*
* Copyright 2010 Wind River Systems, Inc. All rights reserved.
*/
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -22,7 +25,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.Rank;
* Used during overload resolution as a place-holder for function sets.
*/
public class FunctionSetType implements IType {
private final CPPFunctionSet fFunctionSet;
private final boolean fPointerType;

View file

@ -33,7 +33,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalScope;
* Utility class to populate scope with friend declarations hidden in nested classes
*/
class NamespaceTypeCollector extends ASTVisitor {
private final ICPPASTInternalScope fScope;
public NamespaceTypeCollector(ICPPASTInternalScope scope) {

View file

@ -11,7 +11,13 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getCVQualifier;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getSimplifiedType;
import java.util.ArrayList;
import java.util.Arrays;
@ -69,9 +75,8 @@ public class TemplateArgumentDeduction {
* @param point
*/
static ICPPTemplateArgument[] deduceForFunctionCall(ICPPFunctionTemplate template,
ICPPTemplateArgument[] tmplArgs, List<IType> fnArgs, List<ValueCategory> argIsLValue, CPPTemplateParameterMap map, IASTNode point)
throws DOMException {
ICPPTemplateArgument[] tmplArgs, List<IType> fnArgs, List<ValueCategory> argIsLValue,
CPPTemplateParameterMap map, IASTNode point) throws DOMException {
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
if (tmplArgs != null && !addExplicitArguments(tmplParams, tmplArgs, map, point))
@ -87,13 +92,14 @@ public class TemplateArgumentDeduction {
* Deduces the mapping for the template parameters from the function parameters,
* returns <code>false</code> if there is no mapping.
*/
static boolean deduceFromFunctionArgs(ICPPFunctionTemplate template, List<IType> fnArgs, List<ValueCategory> argCats,
CPPTemplateParameterMap map, IASTNode point) {
static boolean deduceFromFunctionArgs(ICPPFunctionTemplate template, List<IType> fnArgs,
List<ValueCategory> argCats, CPPTemplateParameterMap map, IASTNode point) {
try {
IType[] fnPars = template.getType().getParameterTypes();
final int fnParCount = fnPars.length;
final ICPPTemplateParameter[] tmplPars = template.getTemplateParameters();
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplPars, map, new CPPTemplateParameterMap(fnParCount), 0);
TemplateArgumentDeduction deduct=
new TemplateArgumentDeduction(tmplPars, map, new CPPTemplateParameterMap(fnParCount), 0);
IType fnParPack= null;
argLoop: for (int j= 0; j < fnArgs.size(); j++) {
IType par;
@ -474,7 +480,6 @@ public class TemplateArgumentDeduction {
return result.toArray(new ICPPTemplateArgument[result.size()]);
}
/**
* 14.8.2.1.3 If P is a class and has the form template-id, then A can be a derived class of the deduced A.
*/
@ -543,7 +548,9 @@ public class TemplateArgumentDeduction {
* Deduces the template parameter mapping from pairs of template arguments.
* @param point
*/
public static boolean fromTemplateArguments(final ICPPTemplateParameter[] pars, final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map, IASTNode point) throws DOMException {
public static boolean fromTemplateArguments(final ICPPTemplateParameter[] pars,
final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map,
IASTNode point) throws DOMException {
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(pars, null, map, 0);
final int len= a.length;
if (p == null || p.length != len) {
@ -663,7 +670,6 @@ public class TemplateArgumentDeduction {
return fromType(p.getTypeValue(), a.getTypeValue(), false, point);
}
private boolean fromType(IType p, IType a, boolean allowCVQConversion, IASTNode point) throws DOMException {
while (p != null) {
while (a instanceof ITypedef)

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import org.eclipse.cdt.core.dom.ast.IType;

View file

@ -1,10 +1,13 @@
/*
* UniqueType.java
* Created on 04.10.2010
/*******************************************************************************
* Copyright (c) 2010 Wind River Systems, Inc. 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
*
* Copyright 2010 Wind River Systems, Inc. All rights reserved.
*/
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import org.eclipse.cdt.core.dom.ast.IType;
@ -13,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
* Used for computing the partial ordering of function templates.
*/
class UniqueType implements IType {
private boolean fForParameterPack;
public UniqueType(boolean forParameterPack) {

View file

@ -29,13 +29,13 @@ import org.eclipse.core.runtime.CoreException;
* For marshalling types to byte arrays.
*/
public class TypeMarshalBuffer implements ITypeMarshalBuffer {
public final static byte[] EMPTY= { 0, 0, 0, 0, 0, 0 };
public final static byte NULL_TYPE= 0;
public final static byte INDIRECT_TYPE= (byte) -1;
public final static byte BINDING_TYPE= (byte) -2;
public final static byte UNSTORABLE_TYPE= (byte) -3;
public static final byte[] EMPTY= { 0, 0, 0, 0, 0, 0 };
public static final byte NULL_TYPE= 0;
public static final byte INDIRECT_TYPE= (byte) -1;
public static final byte BINDING_TYPE= (byte) -2;
public static final byte UNSTORABLE_TYPE= (byte) -3;
public final static IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
public static final IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
static {
assert EMPTY.length == Database.TYPE_SIZE;
@ -218,6 +218,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
public CoreException unmarshallingError() {
return new CoreException(CCorePlugin.createStatus("Unmarshalling error")); //$NON-NLS-1$
}
public CoreException marshallingError() {
return new CoreException(CCorePlugin.createStatus("Marshalling error")); //$NON-NLS-1$
}
@ -238,6 +239,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
return (((byte1 << 8) | (byte2 & 0xff)));
}
@Override
public void putInt(int value) {
request(4);
fPos += 4;
@ -248,6 +250,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
fBuffer[--p]= (byte) (value);
}
@Override
public int getInt() throws CoreException {
if (fPos + 4 > fBuffer.length)
throw unmarshallingError();

View file

@ -13,11 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
@ -119,6 +114,11 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
/**
* Container for c++-entities.
*/

View file

@ -470,10 +470,15 @@ public class CMainTab extends CAbstractMainTab {
if (exePath.isAbsolute()) {
// For absolute paths, we don't need a project, we can debug the binary directly
// as long as it exists
if (!exePath.toFile().exists()) {
File executable = exePath.toFile();
if (!executable.exists()) {
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
return false;
}
if (!executable.isFile()) {
setErrorMessage(LaunchMessages.getString("CMainTab.Selection_must_be_file")); //$NON-NLS-1$
return false;
}
} else {
// For relative paths, we need a proper project
String projectName = fProjText.getText().trim();

View file

@ -0,0 +1,848 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.CompositeDMContext;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.ICachingService;
import org.eclipse.cdt.dsf.debug.service.IExpressions;
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
import org.eclipse.cdt.dsf.debug.service.IExpressions3;
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
import org.eclipse.cdt.dsf.debug.service.IRegisters;
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext;
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterGroupDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMData;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.mi.service.IGDBPatternMatchingExpressions;
import org.eclipse.cdt.dsf.mi.service.IMIExpressions;
import org.eclipse.cdt.dsf.mi.service.MIRegisters.MIRegisterDMC;
import org.eclipse.cdt.dsf.service.AbstractDsfService;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;
import com.ibm.icu.text.MessageFormat;
/**
* Expressions service added as a layer above the standard Expressions service.
* This layer allows to support group-expressions and glob-pattern matching.
* Group-expressions give the user the ability to create a comma-separated
* list of expressions in a single entry.
* Glob-patterns are a way to specify a set of expressions that match the
* pattern.
* @since 4.2
*/
public class GDBPatternMatchingExpressions extends AbstractDsfService implements IGDBPatternMatchingExpressions, ICachingService {
/**
* A regex representing each character that can be used to separate
* the different expressions contained in a group-expression.
* The [] are not part the characters, but are used in the regex format.
* Note that we don't allow a space separator because spaces are valid within
* an expression (e.g., i + 1)
*/
private final static String GROUP_EXPRESSION_SEPARATORS_REGEXP = "[,;]"; //$NON-NLS-1$
/**
* A group-expression is an expression that requires expansion into a (potentially empty)
* list of sub-expressions. Using a group-expression allows the user to create groups
* of expressions very quickly.
*
* We support two aspects for group-expressions:
* 1- The glob syntax (http://www.kernel.org/doc/man-pages/online/pages/man7/glob.7.html)
* This allows to user to specify glob-patterns to match different expressions.
* 2- Comma-separated expressions, each potentially using the glob-syntax
*/
protected static class GroupExpressionDMC implements IExpressionDMContext {
/**
* The expression context, as created by the main Expression service.
* We delegate the handling of the expression to it.
*/
private IExpressionDMContext fExprDelegate;
/**
* The set of expressions making up the group expression.
* This list is the result of splitting the original expression
* and then trimming each resulting expression.
*/
private List<String> fExpressionsInGroup = null;
public GroupExpressionDMC(IExpressionDMContext exprDmc) {
fExprDelegate = exprDmc;
}
@Override
public String getExpression() {
return fExprDelegate.getExpression();
}
/**
* Returns an array representing the different expressions
* that make up this group-expression.
*/
public List<String> getExpressionsInGroup() {
if (fExpressionsInGroup == null) {
// Split the list
String[] splitExpressions = getExpression().split(GROUP_EXPRESSION_SEPARATORS_REGEXP);
// Remove any extra whitespace from each resulting expression,
// and ignore any empty expressions.
fExpressionsInGroup = new ArrayList<String>(splitExpressions.length);
for (String expr : splitExpressions) {
expr = expr.trim();
if (!expr.isEmpty()) {
fExpressionsInGroup.add(expr);
}
}
}
return fExpressionsInGroup;
}
@Override
public String getSessionId() {
return fExprDelegate.getSessionId();
}
@Override
public IDMContext[] getParents() {
return fExprDelegate.getParents();
};
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class adapterType) {
return fExprDelegate.getAdapter(adapterType);
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof GroupExpressionDMC)) return false;
return ((GroupExpressionDMC)obj).fExprDelegate.equals(fExprDelegate);
}
@Override
public int hashCode() {
return fExprDelegate.hashCode();
}
}
/**
* The model data interface for group-expressions
*/
protected static class GroupExpressionDMData implements IExpressionDMDataExtension {
private final String fRelativeExpression;
private final int fNumChildren;
public GroupExpressionDMData(String expr, int numChildren) {
assert expr != null;
fRelativeExpression = expr;
fNumChildren = numChildren;
}
@Override
public String getName() {
return fRelativeExpression;
}
@Override
public BasicType getBasicType() {
return IExpressionDMData.BasicType.array;
}
@Override
public String getTypeName() {
return Messages.GroupPattern;
}
@Override
public String getEncoding() {
return null;
}
@Override
public String getTypeId() {
return null;
}
@Override
public Map<String, Integer> getEnumerations() {
return new HashMap<String, Integer>();
}
@Override
public IRegisterDMContext getRegister() {
return null;
}
@Override
public boolean hasChildren() {
return fNumChildren > 0;
}
@Override
public boolean equals(Object other) {
if (this == other) return true;
if (!(other instanceof GroupExpressionDMData)) return false;
return fRelativeExpression.equals(((GroupExpressionDMData)other).fRelativeExpression);
}
@Override
public int hashCode() {
return fRelativeExpression.hashCode();
}
@Override
public String toString() {
return "GroupExpr: " + fRelativeExpression; //$NON-NLS-1$
}
}
/**
* The base expression service to which we delegate all non-group-expression logic.
*/
private IMIExpressions fDelegate;
public GDBPatternMatchingExpressions(DsfSession session, IExpressions delegate) {
super(session);
fDelegate = (IMIExpressions)delegate;
}
@Override
public void initialize(final RequestMonitor requestMonitor) {
super.initialize(
new ImmediateRequestMonitor(requestMonitor) {
@Override
public void handleSuccess() {
doInitialize(requestMonitor);
}});
}
private void doInitialize(final RequestMonitor requestMonitor) {
// Our delegate should not be initialized yet, as we have no
// good way to unregister it.
assert !fDelegate.isRegistered();
// We must first register this service to let the original
// expression service know that it should not register itself.
register(new String[] { IExpressions.class.getName(),
IExpressions2.class.getName(),
IExpressions3.class.getName(),
IMIExpressions.class.getName() },
new Hashtable<String, String>());
// Second, we initialize the delegate so it can perform its duties
fDelegate.initialize(requestMonitor);
}
@Override
public void shutdown(final RequestMonitor requestMonitor) {
fDelegate.shutdown(new RequestMonitor(getExecutor(), requestMonitor) {
@Override
protected void handleSuccess() {
unregister();
GDBPatternMatchingExpressions.super.shutdown(requestMonitor);
}
});
}
@Override
protected BundleContext getBundleContext() {
return GdbPlugin.getBundleContext();
}
@Override
public IExpressionDMContext createExpression(IDMContext ctx, String expression) {
IExpressionDMContext expressionDmc = fDelegate.createExpression(ctx, expression);
if (isGroupExpression(expression)) {
return new GroupExpressionDMC(expressionDmc);
} else {
return expressionDmc;
}
}
@Override
public ICastedExpressionDMContext createCastedExpression(IExpressionDMContext context, CastInfo castInfo) {
// Cannot cast a GroupExpression
assert (!(context instanceof GroupExpressionDMC));
return fDelegate.createCastedExpression(context, castInfo);
}
@Override
public void getExpressionDataExtension(final IExpressionDMContext dmc, final DataRequestMonitor<IExpressionDMDataExtension> rm) {
if (dmc instanceof GroupExpressionDMC) {
getSubExpressionCount(dmc, new ImmediateDataRequestMonitor<Integer>(rm) {
@Override
protected void handleSuccess() {
rm.done(new GroupExpressionDMData(((GroupExpressionDMC)dmc).getExpression(), getData()));
}
});
return;
}
fDelegate.getExpressionDataExtension(dmc, rm);
}
@Override
public void getExpressionData(final IExpressionDMContext dmc, final DataRequestMonitor<IExpressionDMData> rm) {
if (dmc instanceof GroupExpressionDMC) {
getSubExpressionCount(dmc, new ImmediateDataRequestMonitor<Integer>(rm) {
@Override
protected void handleSuccess() {
rm.done(new GroupExpressionDMData(((GroupExpressionDMC)dmc).getExpression(), getData()));
}
});
return;
}
fDelegate.getExpressionData(dmc, rm);
}
@Override
public void getExpressionAddressData(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMAddress> rm) {
// A GroupExpression does not have an address
if (dmc instanceof GroupExpressionDMC) {
rm.done(new IExpressionDMLocation() {
@Override
public IAddress getAddress() {
return IExpressions.IExpressionDMLocation.INVALID_ADDRESS;
}
@Override
public int getSize() {
return 0;
}
@Override
public String getLocation() {
return ""; //$NON-NLS-1$
}
});
return;
}
fDelegate.getExpressionAddressData(dmc, rm);
}
@Override
public void getSubExpressions(IExpressionDMContext exprCtx, DataRequestMonitor<IExpressionDMContext[]> rm) {
if (exprCtx instanceof GroupExpressionDMC) {
matchGroupExpression((GroupExpressionDMC)exprCtx, -1, -1, rm);
} else {
fDelegate.getSubExpressions(exprCtx, rm);
}
}
@Override
public void getSubExpressions(IExpressionDMContext exprCtx, int startIndex, int length, DataRequestMonitor<IExpressionDMContext[]> rm) {
if (exprCtx instanceof GroupExpressionDMC) {
matchGroupExpression((GroupExpressionDMC)exprCtx, startIndex, length, rm);
} else {
fDelegate.getSubExpressions(exprCtx, startIndex, length, rm);
}
}
@Override
public void getSubExpressionCount(IExpressionDMContext dmc, final DataRequestMonitor<Integer> rm) {
if (dmc instanceof GroupExpressionDMC) {
matchGroupExpression((GroupExpressionDMC)dmc, -1, -1, new ImmediateDataRequestMonitor<IExpressionDMContext[]>(rm) {
@Override
protected void handleSuccess() {
rm.done(getData().length);
}
});
} else {
fDelegate.getSubExpressionCount(dmc, rm);
}
}
@Override
public void getSubExpressionCount(IExpressionDMContext dmc, int maxNumberOfChildren, final DataRequestMonitor<Integer> rm) {
if (dmc instanceof GroupExpressionDMC) {
// No need to worry about maxNumberOfChildren for the case of a group-expression, since there won't be
// a very large amount of them.
matchGroupExpression((GroupExpressionDMC)dmc, -1, -1, new ImmediateDataRequestMonitor<IExpressionDMContext[]>(rm) {
@Override
protected void handleSuccess() {
rm.done(getData().length);
}
});
} else {
fDelegate.getSubExpressionCount(dmc, maxNumberOfChildren, rm);
}
}
@Override
public void getBaseExpressions(IExpressionDMContext exprContext, DataRequestMonitor<IExpressionDMContext[]> rm) {
rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
}
@Override
public void canWriteExpression(IExpressionDMContext dmc, DataRequestMonitor<Boolean> rm) {
// A GroupExpression's value cannot be modified
if (dmc instanceof GroupExpressionDMC) {
rm.done(false);
return;
}
fDelegate.canWriteExpression(dmc, rm);
}
@Override
public void writeExpression(IExpressionDMContext dmc, String expressionValue, String formatId, RequestMonitor rm) {
// A GroupExpression's value cannot be modified
assert !(dmc instanceof GroupExpressionDMC);
fDelegate.writeExpression(dmc, expressionValue, formatId, rm);
}
@Override
public void getAvailableFormats(IFormattedDataDMContext dmc, DataRequestMonitor<String[]> rm) {
//For a group expression, we only show the NATURAL format
if (dmc instanceof GroupExpressionDMC) {
rm.done(new String[] { IFormattedValues.NATURAL_FORMAT });
return;
}
fDelegate.getAvailableFormats(dmc, rm);
}
@Override
public FormattedValueDMContext getFormattedValueContext(IFormattedDataDMContext dmc, String formatId) {
// No special handling for GroupExpressions
return fDelegate.getFormattedValueContext(dmc, formatId);
}
@Override
public void getFormattedExpressionValue(FormattedValueDMContext dmc, final DataRequestMonitor<FormattedValueDMData> rm) {
GroupExpressionDMC groupExpr = DMContexts.getAncestorOfType(dmc, GroupExpressionDMC.class);
if (groupExpr != null) {
getSubExpressionCount(groupExpr, new ImmediateDataRequestMonitor<Integer>(rm) {
@Override
protected void handleSuccess() {
int numChildren = getData();
String value;
if (numChildren == 0) {
value = Messages.NoMatches;
} else if (numChildren == 1) {
value = MessageFormat.format(Messages.UniqueMatch, numChildren);
} else {
value = MessageFormat.format(Messages.UniqueMatches, numChildren);
}
rm.done(new FormattedValueDMData(value));
}
});
return;
}
fDelegate.getFormattedExpressionValue(dmc, rm);
}
@Override
public void safeToAskForAllSubExpressions(IExpressionDMContext dmc, DataRequestMonitor<Boolean> rm) {
// Always safe to ask for all sub-expression of a group expression, since we don't expect large
// amounts of children
if (dmc instanceof GroupExpressionDMC) {
rm.done(true);
return;
}
fDelegate.safeToAskForAllSubExpressions(dmc, rm);
}
@Override
public void flushCache(IDMContext context) {
if (fDelegate instanceof ICachingService) {
((ICachingService)fDelegate).flushCache(context);
}
}
/**
* Verify if we are dealing with a group expression.
* @param expr The expression to verify
* @return True if expr is a group expression. A group
* expression is either a comma-separated list of
* expressions, or an expression using a glob-pattern
*/
protected boolean isGroupExpression(String expr) {
// First check for a comma separated list of expression
// We want to re-use the regex that defines our separators, and we need to check
// if the expression contains that regex. I didn't find a method that
// checks if a string contains a regex, so instead we all any character before
// and after the regex, which achieves what we want.
// Note that checking if expr.split(regex) is bigger than 1, will not notice
// an expression that has a separator only at the end.
if (expr.matches(".*" + GROUP_EXPRESSION_SEPARATORS_REGEXP +".*")) { //$NON-NLS-1$ //$NON-NLS-2$
// We are dealing with a group expression.
// It may not be a valid one, but it is one nonetheless.
return true;
}
// Not a comma-separated list. Check if we are dealing with a glob-pattern.
return isGlobPattern(expr);
}
/**
* Verify if we are dealing with a glob-pattern.
* We support the expression * which will match all local variables.
* We support glob-patterns for registers (must start with $)
* @param expr The expression to verify
* @return True if expr is a glob-pattern we support.
*/
protected boolean isGlobPattern(String expr) {
// Get rid of useless whitespace
expr = expr.trim();
// We support the glob-pattern '*' to indicate all local variables
if (expr.equals("*")) { //$NON-NLS-1$
return true;
}
// We only support glob-expressions for registers at this time
if (expr.startsWith("$")) { //$NON-NLS-1$
// see: 'man glob'
if (expr.indexOf('*') != -1 || expr.indexOf('?') != -1 || expr.indexOf('[') != -1) {
return true;
}
}
return false;
}
/**
* Find all expressions that match the specified group-expression.
* This method retains the order of the expressions in the group-expression, to show them
* in the same order as the one specified by the user. The match of each expression in the group
* is sorted alphabetically however.
*
* @param groupExprDmc The group-expression context for which we want the matches (sub-expressions)
* @param startIndex The beginning of the range of matches (-1 means all matches)
* @param length The length of the range of matches (-1 means all matches)
* @param rm RequestMonitor that will contain the range of found matches.
*/
protected void matchGroupExpression(final GroupExpressionDMC groupExprDmc, int startIndex, int length,
final DataRequestMonitor<IExpressionDMContext[]> rm) {
// First separate the group into different expressions.
// We need to create a new list, as we will modify it during our processing.
final List<String> exprList = new ArrayList<String>(groupExprDmc.getExpressionsInGroup());
// List to store the final result, which is all the sub-expressions of this group
final ArrayList<IExpressionDMContext> subExprList = new ArrayList<IExpressionDMContext>();
final int startIndex1 = (startIndex < 0) ? 0 : startIndex;
final int length1 = (length < 0) ? Integer.MAX_VALUE : length;
matchExpressionList(exprList, subExprList, groupExprDmc, new ImmediateRequestMonitor(rm) {
@Override
protected void handleSuccess() {
// It would be nice to allow identical elements, so that the user
// can control their positioning. For example, the pattern $eax, $*, would show
// the $eax first, followed by all other registers sorted alphabetically. In that case
// $eax will be shown again within $*, but that would be ok.
// However, the platform does not handle the same element being there twice.
// Not only does selecting the element jump back and forth between the duplicates,
// but children of duplicated elements are not always right. Because of this, we
// remove all duplicates here.
LinkedHashSet<IExpressionDMContext> uniqueSubExprSet = new LinkedHashSet<IExpressionDMContext>(subExprList);
subExprList.clear();
subExprList.addAll(uniqueSubExprSet);
// Extract the range of interest from the final list
int endIndex = Math.min(startIndex1 + length1, subExprList.size());
List<IExpressionDMContext> subExprRangeList = subExprList.subList(startIndex1, endIndex);
IExpressionDMContext[] subExprRange = subExprRangeList.toArray(new IExpressionDMContext[subExprRangeList.size()]);
rm.done(subExprRange);
}
});
}
/**
* We use this recursive method to serialize the request for matches. Once one request is done,
* we create a new one. This allows us to guarantee that the resulting matches will
* be ordered in the same way every time.
*/
private void matchExpressionList(final List<String> exprList, final List<IExpressionDMContext> subExprList, final IDMContext parentDmc,
final RequestMonitor rm) {
// We've finished parsing the list
if (exprList.isEmpty()) {
rm.done();
return;
}
// Remove the next element from the list and process it. We handle glob-pattern matching if needed
// and sort the result alphabetically in that case.
String expr = exprList.remove(0);
if (isGlobPattern(expr)) {
IExpressionDMContext exprDmc = createExpression(parentDmc, expr);
matchGlobExpression(exprDmc, new ImmediateDataRequestMonitor<List<IExpressionDMContext>>(rm) {
@Override
protected void handleSuccess() {
List<IExpressionDMContext> matches = getData();
// Sort the matches to be more user-friendly
Collections.sort(matches, new Comparator<IExpressionDMContext>() {
@Override
public int compare(IExpressionDMContext o1, IExpressionDMContext o2) {
return o1.getExpression().compareTo(o2.getExpression());
}
});
subExprList.addAll(matches);
// Match the next expression from the list
matchExpressionList(exprList, subExprList, parentDmc, rm);
}
});
} else {
// Just a normal expression
subExprList.add(createExpression(parentDmc, expr));
// Match the next expression from the list
matchExpressionList(exprList, subExprList, parentDmc, rm);
}
}
/**
* Find all expressions that match the specified glob-pattern.
*
* @param exprDmc The expression context for which we want the matches (sub-expressions)
* @param rm RequestMonitor that will contain the matches.
*/
protected void matchGlobExpression(final IExpressionDMContext exprDmc, final DataRequestMonitor<List<IExpressionDMContext>> rm) {
final String fullExpr = exprDmc.getExpression().trim();
if (fullExpr.equals("*")) { //$NON-NLS-1$
matchLocals(exprDmc, rm);
return;
}
// Currently, we only support glob-expressions for registers, so
// we only need to match the glob-expression with register names.
// We should not arrive here if we are not handling a register
assert fullExpr.startsWith("$"); //$NON-NLS-1$
final IRegisters registerService = getServicesTracker().getService(IRegisters.class);
if (registerService == null) {
rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Register service unavailable", null)); //$NON-NLS-1$
return;
}
registerService.getRegisterGroups(exprDmc, new ImmediateDataRequestMonitor<IRegisterGroupDMContext[]>(rm) {
@Override
protected void handleSuccess() {
registerService.getRegisters(
new CompositeDMContext(new IDMContext[] { getData()[0], exprDmc } ),
new ImmediateDataRequestMonitor<IRegisterDMContext[]>(rm) {
@Override
protected void handleSuccess() {
assert getData() instanceof MIRegisterDMC[];
ArrayList<IExpressionDMContext> matches = new ArrayList<IExpressionDMContext>();
for (MIRegisterDMC register : (MIRegisterDMC[])getData()) {
String potentialMatch = "$"+register.getName(); //$NON-NLS-1$
if (globMatches(fullExpr, potentialMatch)) {
matches.add(createExpression(exprDmc, potentialMatch));
}
}
rm.done(matches);
}
});
}
});
}
/**
* Find all local variables that match the specified glob-pattern.
* We currently only support matching all local variables using the '*' pattern.
*
* @param globDmc The glob-expression context for which we want the matches (sub-expressions)
* @param rm RequestMonitor that will contain the matches.
*/
protected void matchLocals(final IExpressionDMContext globDmc, final DataRequestMonitor<List<IExpressionDMContext>> rm) {
// We only support '*' for local variables at this time
assert globDmc.getExpression().equals("*"); //$NON-NLS-1$
final IStack stackService = getServicesTracker().getService(IStack.class);
if (stackService == null) {
rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Stack service unavailable", null)); //$NON-NLS-1$
return;
}
IFrameDMContext frameCtx = DMContexts.getAncestorOfType(globDmc, IFrameDMContext.class);
if (frameCtx == null) {
rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Stack frame unavailable", null)); //$NON-NLS-1$
return;
}
stackService.getLocals(frameCtx, new ImmediateDataRequestMonitor<IVariableDMContext[]>(rm) {
@Override
protected void handleSuccess() {
IVariableDMContext[] localsDMCs = getData();
final IVariableDMData[] localsDMData = new IVariableDMData[localsDMCs.length];
final CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm) {
@Override
public void handleSuccess() {
ArrayList<IExpressionDMContext> expressionDMCs = new ArrayList<IExpressionDMContext>(localsDMData.length);
for (IVariableDMData localDMData : localsDMData) {
expressionDMCs.add(createExpression(globDmc, localDMData.getName()));
}
rm.done(expressionDMCs);
}
};
int countRM = 0;
for (int index=0; index < localsDMCs.length; index++) {
final int finalIndex = index;
stackService.getVariableData(localsDMCs[finalIndex], new ImmediateDataRequestMonitor<IVariableDMData>(crm) {
@Override
public void handleSuccess() {
localsDMData[finalIndex] = getData();
crm.done();
}
});
countRM++;
}
crm.setDoneCount(countRM);
}
});
}
/**
* Verify if the potentialMatch variable matches the glob-pattern.
*
* @param globPattern The glob-pattern to match
* @param potentialMatch The string that must match globPattern.
* @return True of potentialMatch does match globPattern.
*/
protected boolean globMatches(String globPattern, String potentialMatch) {
// Convert the glob-pattern into java regex to do the matching
boolean inBrackets = false;
char[] patternArray = globPattern.toCharArray();
char[] resultArray = new char[patternArray.length * 2 + 2];
int pos = 0;
// Must match from the very beginning
resultArray[pos++] = '^';
for (int i = 0; i < patternArray.length; i++) {
switch(patternArray[i]) {
case '?':
if (inBrackets) {
resultArray[pos++] = '?';
} else {
resultArray[pos++] = '.';
}
break;
case '*':
if (!inBrackets) {
resultArray[pos++] = '.';
}
resultArray[pos++] = '*';
break;
case '-':
if (!inBrackets) {
resultArray[pos++] = '\\';
}
resultArray[pos++] = '-';
break;
case '[':
inBrackets = true;
resultArray[pos++] = '[';
if (i < patternArray.length - 1) {
switch (patternArray[i+1]) {
case '!':
case '^':
resultArray[pos++] = '^';
i++;
break;
case ']':
resultArray[pos++] = ']';
i++;
break;
}
}
break;
case ']':
resultArray[pos++] = ']';
inBrackets = false;
break;
case '\\':
if (i == 0 && patternArray.length > 1 && patternArray[1] == '~') {
resultArray[pos++] = '~';
++i;
} else {
resultArray[pos++] = '\\';
if (i < patternArray.length - 1 && "*?[]".indexOf(patternArray[i+1]) != -1) { //$NON-NLS-1$
resultArray[pos++] = patternArray[++i];
} else {
resultArray[pos++] = '\\';
}
}
break;
default:
// We must escape characters that are not digits or arrays
// specifically, "^$.{}()+|<>"
if (!Character.isLetterOrDigit(patternArray[i])) {
resultArray[pos++] = '\\';
}
resultArray[pos++] = patternArray[i];
break;
}
}
// Must match until the very end
resultArray[pos++] = '$';
try {
Pattern pattern = Pattern.compile(new String(resultArray, 0, pos), Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(potentialMatch);
return matcher.find();
} catch(Exception e) {
// If the user put an invalid pattern, we just ignore it
return false;
}
}
}

View file

@ -151,7 +151,12 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
@Override
protected IExpressions createExpressionService(DsfSession session) {
return new MIExpressions(session);
// Replace the standard Expressions service with a version that supports pattern matching.
// Pass in the original service which will be used as a delegate.
// This way of doing things allows to keep the pattern matching aspect isolated
// and easy to remove.
IExpressions originialExpressionService = new MIExpressions(session);
return new GDBPatternMatchingExpressions(session, originialExpressionService);
}
@Override

View file

@ -20,6 +20,10 @@ class Messages extends NLS {
public static String Tracing_not_supported_error;
public static String Invalid_post_mortem_type_error;
public static String Cannot_get_post_mortem_file_path_error;
public static String GroupPattern;
public static String NoMatches;
public static String UniqueMatch;
public static String UniqueMatches;
static {
// initialize resource bundle

View file

@ -12,3 +12,7 @@
Tracing_not_supported_error=Tracing not supported
Invalid_post_mortem_type_error=Invalid post-mortem type
Cannot_get_post_mortem_file_path_error=Cannot get post mortem file path
GroupPattern=Group-pattern
NoMatches=No matches
UniqueMatch={0} unique match
UniqueMatches={0} unique matches

View file

@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service;
/**
* Interface that will indicate that the implementing service supports
* Glob-style expression pattern matching.
* @since 4.2
*/
public interface IGDBPatternMatchingExpressions extends IMIExpressions {
}

View file

@ -30,6 +30,7 @@ import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.ICachingService;
import org.eclipse.cdt.dsf.debug.service.IExpressions;
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
import org.eclipse.cdt.dsf.debug.service.IExpressions3;
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext;
@ -836,11 +837,17 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
// Register to receive service events for this session.
getSession().addServiceEventListener(this, null);
// Register this service.
// Register this service, but only if we don't already have an
// IExpression service present. This allows another expression
// service to be used, while delegating calls to this service.
if (getServicesTracker().getService(IExpressions.class) == null) {
register(new String[] { IExpressions.class.getName(),
IExpressions2.class.getName(),
IExpressions3.class.getName(),
IMIExpressions.class.getName(),
MIExpressions.class.getName() },
new Hashtable<String, String>());
}
// Create the expressionService-specific CommandControl which is our
// variable object manager.

View file

@ -0,0 +1,18 @@
int foo(int firstarg, bool secondarg) {
bool firstvar = true;
int secondvar = 18;
return 0;
}
int main (int argc, char *argv[])
{
int intvar = 80;
bool boolvar = true;
char chararray[201];
foo(15, true);
return 0;
}

View file

@ -0,0 +1,914 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Query;
import org.eclipse.cdt.dsf.datamodel.CompositeDMContext;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IExpressions;
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMLocation;
import org.eclipse.cdt.dsf.debug.service.IExpressions3.IExpressionDMDataExtension;
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
import org.eclipse.cdt.dsf.debug.service.IRegisters;
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext;
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterGroupDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.cdt.dsf.mi.service.ClassAccessor.MIExpressionDMCAccessor;
import org.eclipse.cdt.dsf.mi.service.IGDBPatternMatchingExpressions;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIExpressions;
import org.eclipse.cdt.dsf.mi.service.MIRegisters.MIRegisterDMC;
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.Platform;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBPatternMatchingExpressionsTest extends BaseTestCase {
private DsfSession fSession;
private DsfServicesTracker fServicesTracker;
protected IMIExpressions fExpService;
protected IRegisters fRegService;
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/PatternMatchingExpressionsTestApp.exe");
}
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() {
@Override
public void run() {
fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
fExpService = fServicesTracker.getService(IMIExpressions.class);
assertTrue(fExpService instanceof IGDBPatternMatchingExpressions);
fRegService = fServicesTracker.getService(IRegisters.class);
}
};
fSession.getExecutor().submit(runnable).get();
}
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
fExpService = null;
fServicesTracker.dispose();
}
//**************************************************************************************
// Utility methods
//**************************************************************************************
protected List<String> get_X86_REGS() {
// Because we are dealing with expressions for the registers, we must prefix them with '$'
List<String> list = new LinkedList<String>(Arrays.asList("$eax","$ecx","$edx","$ebx","$esp","$ebp","$esi","$edi","$eip","$eflags",
"$cs","$ss","$ds","$es","$fs","$gs","$st0","$st1","$st2","$st3",
"$st4","$st5","$st6","$st7","$fctrl","$fstat","$ftag","$fiseg","$fioff","$foseg",
"$fooff","$fop","$xmm0","$xmm1","$xmm2","$xmm3","$xmm4","$xmm5","$xmm6","$xmm7",
"$mxcsr","$orig_eax","$mm0","$mm1","$mm2","$mm3","$mm4","$mm5","$mm6","$mm7"));
// On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux
if (Platform.getOS().equals(Platform.OS_WIN32)) {
list.remove("$orig_eax");
}
return list;
}
protected void checkChildrenCount(final IExpressionDMContext parentDmc, final int expectedCount) throws Throwable {
Query<Integer> query = new Query<Integer>() {
@Override
protected void execute(final DataRequestMonitor<Integer> rm) {
fExpService.getSubExpressionCount(parentDmc, rm);
}
};
fSession.getExecutor().execute(query);
int count = query.get();
assertTrue(String.format("Expected %d but got %d", expectedCount, count), count == expectedCount);
}
protected String getRegisterValue(final String regName, final IMIExecutionDMContext threadDmc) throws Exception {
Query<String> query = new Query<String>() {
@Override
protected void execute(final DataRequestMonitor<String> rm) {
fRegService.getRegisterGroups(threadDmc, new ImmediateDataRequestMonitor<IRegisterGroupDMContext[]>(rm) {
@Override
protected void handleSuccess() {
fRegService.getRegisters(
new CompositeDMContext(new IDMContext[] { getData()[0], threadDmc } ),
new ImmediateDataRequestMonitor<IRegisterDMContext[]>(rm) {
@Override
protected void handleSuccess() {
assert getData() instanceof MIRegisterDMC[];
for (MIRegisterDMC register : (MIRegisterDMC[])getData()) {
if (register.getName().equals(regName)) {
final FormattedValueDMContext valueDmc = fRegService.getFormattedValueContext(register, IFormattedValues.HEX_FORMAT);
fRegService.getFormattedExpressionValue(valueDmc, new ImmediateDataRequestMonitor<FormattedValueDMData>(rm) {
@Override
protected void handleSuccess() {
rm.done(getData().getFormattedValue());
};
});
return;
}
}
// If we get here, we didn't find the register!
assertTrue("Invalid register: " + regName, false);
}
});
}
});
}
};
fSession.getExecutor().execute(query);
return query.get();
}
protected String getExpressionValue(final IExpressionDMContext exprDmc) throws Throwable
{
Query<String> query = new Query<String>() {
@Override
protected void execute(final DataRequestMonitor<String> rm) {
final FormattedValueDMContext valueDmc =
fExpService.getFormattedValueContext(exprDmc, IFormattedValues.HEX_FORMAT);
fExpService.getFormattedExpressionValue(valueDmc,
new ImmediateDataRequestMonitor<FormattedValueDMData>(rm) {
@Override
protected void handleSuccess() {
rm.done(getData().getFormattedValue());
}
});
}
};
fSession.getExecutor().execute(query);
return query.get();
}
// This method tests IExpressions.getSubExpressions(IExpressionDMC, int, int, DRM);
protected IExpressionDMContext[] checkChildren(final IExpressionDMContext parentDmc, final int startIndex, final int length,
String[] expectedValues) throws Throwable {
Query<IExpressionDMContext[]> query = new Query<IExpressionDMContext[]>() {
@Override
protected void execute(final DataRequestMonitor<IExpressionDMContext[]> rm) {
fExpService.getSubExpressions(parentDmc, startIndex, length, rm);
}
};
fSession.getExecutor().execute(query);
IExpressionDMContext[] childDmcs = query.get();
String[] childExpressions = new String[childDmcs.length];
MIExpressionDMCAccessor[] childDmcsAccessor = new MIExpressionDMCAccessor[childDmcs.length];
// Convert to a MIExpressionDMCAccessor to be able to call getRelativeExpression
// Also convert to String[] to be able to use Arrays.toString()
for (int i = 0; i < childExpressions.length; i++) {
childDmcsAccessor[i] = new MIExpressionDMCAccessor(childDmcs[i]);
childExpressions[i] = childDmcsAccessor[i].getRelativeExpression();
}
assertTrue("Expected " + Arrays.toString(expectedValues) + " but got " + Arrays.toString(childExpressions),
expectedValues.length == childExpressions.length);
for (int i = 0; i < childDmcsAccessor.length; i++) {
assertEquals(childDmcsAccessor[i].getRelativeExpression(), expectedValues[i]);
}
return childDmcs;
}
//**************************************************************************************
// Tests methods
//**************************************************************************************
/**
* Test that we can access a single register
*/
@Test
public void testMatchSingleReg() throws Throwable {
final String regName = "esp";
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
IMIExecutionDMContext threadDmc = DMContexts.getAncestorOfType(frameDmc, IMIExecutionDMContext.class);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "$"+regName);
checkChildrenCount(exprDmc, 0);
// get value of expression and compare with register
assertEquals(getRegisterValue(regName, threadDmc), getExpressionValue(exprDmc));
}
/**
* Test that we can access a single variable, without using groups or patterns
*/
@Test
public void testMatchSingleLocal() throws Throwable {
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "secondvar");
checkChildrenCount(exprDmc, 0);
// get value of expression and compare with register
assertEquals(getExpressionValue(exprDmc), "0x12");
}
/**
* Test that we can create the all-register match
*/
@Test
public void testMatchAllRegs() throws Throwable {
final String exprString = "$*";
List<String> regList = get_X86_REGS();
Collections.sort(regList);
final String[] children = regList.toArray(new String[0]);
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that we can create the all-locals match
*/
@Test
public void testMatchAllLocals() throws Throwable {
final String exprString = "*";
final String[] children = new String[] { "firstarg", "firstvar", "secondarg", "secondvar" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that we can create the all-locals match for another frame
*/
@Test
public void testMatchAllLocalsOtherFrame() throws Throwable {
final String exprString = "*";
final String[] children = new String[] { "argc", "argv", "boolvar", "chararray", "intvar" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 1);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that registers can be matched using '*'
*/
@Test
public void testMatchRegWithStar() throws Throwable {
final String exprString = "$e*";
final String[] children = new String[] { "$eax","$ebp","$ebx","$ecx","$edi","$edx","$eflags","$eip","$es", "$esi","$esp" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that registers can be matched using '?'
*/
@Test
public void testMatchRegWithQuestionMark() throws Throwable {
final String exprString = "$e??";
final String[] children = new String[] { "$eax","$ebp","$ebx","$ecx","$edi","$edx","$eip", "$esi","$esp" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that registers can be matched using [] with a single index
*/
@Test
public void testMatchRegWithBracketsOneDigit() throws Throwable {
final String exprString = "$st[4]";
final String[] children = new String[] { "$st4" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that registers can be matched using '[]' using a range
*/
@Test
public void testMatchRegWithBracketsRange() throws Throwable {
final String exprString = "$st[2-5]";
final String[] children = new String[] { "$st2","$st3", "$st4","$st5" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that all registers and all locals can be matched at the same time
*/
@Test
public void testGroupAllRegsAllLocals() throws Throwable {
final String exprString = "$*, *";
List<String> list = get_X86_REGS();
Collections.sort(list);
list.addAll(Arrays.asList(new String[] { "firstarg", "firstvar", "secondarg", "secondvar" }));
final String[] children = list.toArray(new String[list.size()]);
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that all local and all registers can be matched at the same time. This
* is the reverse order than the previous test.
*/
@Test
public void testGroupAllLocalsAllRegs() throws Throwable {
final String exprString = "*, $*";
List<String> list = get_X86_REGS();
Collections.sort(list);
list.addAll(0, Arrays.asList(new String[] { "firstarg", "firstvar", "secondarg", "secondvar" }));
final String[] children = list.toArray(new String[list.size()]);
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that we can match a range
*/
@Test
public void testGroupSubExprRange() throws Throwable {
final String exprString = "$eax, $es, *";
final String[] children = new String[] { "$es", "firstarg", "firstvar", "secondarg" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
// Check four children starting at position 1
checkChildren(exprDmc, 1, 4, children);
}
/**
* Test that we can group a local with all registers
*/
@Test
public void testGroupOneLocalAllReg() throws Throwable {
final String exprString = "firstvar, $*";
List<String> list = get_X86_REGS();
Collections.sort(list);
list.addAll(0, Arrays.asList(new String[] { "firstvar" }));
final String[] children = list.toArray(new String[list.size()]);
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that we only return a single instance of a duplicate
* register when using a pattern that matches the register
* more than once.
*/
@Test
public void testUniqueWhenOverlapReg() throws Throwable {
final String exprString = "$eax, $e?x, $eb?";
final String[] children = new String[] { "$eax","$ebx","$ecx","$edx", "$ebp" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that we only return a single instance of a duplicate
* variable when using a pattern that matches the variable
* more than once.
*/
@Test
public void testUniqueWhenOverlapLocal() throws Throwable {
final String exprString = "firstvar,*,firstvar";
final String[] children = new String[] { "firstvar", "firstarg", "secondarg", "secondvar" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that the all-register pattern is sorted alphabetically
*/
@Test
public void testSortedAllReg() throws Throwable {
final String exprString = "$*";
List<String> regList = get_X86_REGS();
Collections.sort(regList);
final String[] children = regList.toArray(new String[0]);
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that the all-local pattern is sorted alphabetically
*/
@Test
public void testSortedAllLocals() throws Throwable {
final String exprString = "*";
List<String> list = Arrays.asList(new String[] { "firstarg", "firstvar", "secondarg", "secondvar" });
Collections.sort(list);
final String[] children = list.toArray(new String[list.size()]);
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that individual expressions within a group-expression
* are not sorted between each other, but that each part of the
* group is kept in the user-specified order and sorted within
* itself.
*/
@Test
public void testSeparatlySorted() throws Throwable {
final String exprString = "$*, *";
List<String> list = get_X86_REGS();
Collections.sort(list);
List<String> localsList = Arrays.asList(new String[] { "firstarg", "firstvar", "secondarg", "secondvar" });
Collections.sort(localsList);
list.addAll(localsList);
final String[] children = list.toArray(new String[list.size()]);
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that group-expression can use a comma as a separator
*/
@Test
public void testCommaSeparation() throws Throwable {
final String exprString = "firstvar,$eax";
final String[] children = new String[] { "firstvar","$eax" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that group-expression can use a semi-colon as a separator
*/
@Test
public void testSemiColonSeparation() throws Throwable {
final String exprString = "firstvar;$eax";
final String[] children = new String[] { "firstvar","$eax" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that group-expression can use a comma and a semi-colon as a
* separator at the same time
*/
@Test
public void testCommaAndSemiColonSeparation() throws Throwable {
final String exprString = "firstvar,$eax;$es";
final String[] children = new String[] { "firstvar","$eax","$es" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that group-expression can have empty terms with commas.
*/
@Test
public void testGroupCommaEmptyTerm() throws Throwable {
final String exprString = ",,firstvar,,$eax,,";
final String[] children = new String[] { "firstvar","$eax" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that group-expression can have empty terms with semi-colon.
*/
@Test
public void testGroupSemiColonEmptyTerm() throws Throwable {
final String exprString = ";;firstvar;;$eax;;";
final String[] children = new String[] { "firstvar","$eax" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test that group-expression clean up extra spaces
*/
@Test
public void testExtraSpaces() throws Throwable {
final String exprString = " firstvar , $eax , , ";
final String[] children = new String[] { "firstvar","$eax" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
checkChildren(exprDmc, -1, -1, children);
checkChildrenCount(exprDmc, children.length);
}
/**
* Test the expression data associated with group-expressions.
*/
@Test
public void testGroupExpressionData() throws Throwable {
final String exprString = "$eax,*";
// final String[] children = new String[] { "$eax", "firstarg", "firstvar", "secondarg", "secondvar" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
Query<IExpressionDMData> query = new Query<IExpressionDMData>() {
@Override
protected void execute(final DataRequestMonitor<IExpressionDMData> rm) {
fExpService.getExpressionData(exprDmc, rm);
}
};
fSession.getExecutor().execute(query);
IExpressionDMData data = query.get();
Query<IExpressionDMDataExtension> query2 = new Query<IExpressionDMDataExtension>() {
@Override
protected void execute(final DataRequestMonitor<IExpressionDMDataExtension> rm) {
fExpService.getExpressionDataExtension(exprDmc, rm);
}
};
fSession.getExecutor().execute(query2);
IExpressionDMDataExtension dataExt = query2.get();
// Make sure the two different ways to get the group-expression data return
// teh same thing, to make sure we didn't forget to update one of the two.
assertEquals(data, dataExt);
assertEquals(exprString, dataExt.getName());
assertEquals(IExpressionDMData.BasicType.array, dataExt.getBasicType());
assertEquals("Group-pattern", dataExt.getTypeName());
assertTrue("IExpressionDMDataExtension.HasChildren should have been true", dataExt.hasChildren());
assertEquals("Group-pattern", dataExt.getTypeName());
}
/**
* Test the expression address data associated with group-expressions.
*/
@Test
public void testGroupExpressionAddressData() throws Throwable {
final String exprString = "$eax,*";
// final String[] children = new String[] { "$eax", "firstarg", "firstvar", "secondarg", "secondvar" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
Query<IExpressionDMAddress> query = new Query<IExpressionDMAddress>() {
@Override
protected void execute(final DataRequestMonitor<IExpressionDMAddress> rm) {
fExpService.getExpressionAddressData(exprDmc, rm);
}
};
fSession.getExecutor().execute(query);
IExpressionDMAddress data = query.get();
assertTrue("The address data shoudl be of type IExpressionDMLocation", data instanceof IExpressionDMLocation);
assertEquals(IExpressions.IExpressionDMLocation.INVALID_ADDRESS, data.getAddress());
assertEquals(0, data.getSize());
assertEquals("", ((IExpressionDMLocation)data).getLocation());
}
/**
* Test the call to IExpressions.getSubExpressions(IExpressionDMC, DRM);
* which is not tested by the method checkChildren() used by our other tests
*/
@Test
public void testGroupGetSubExpressions() throws Throwable {
final String exprString = "$eax,*";
final String[] children = new String[] { "$eax", "firstarg", "firstvar", "secondarg", "secondvar" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
Query<IExpressionDMContext[]> query = new Query<IExpressionDMContext[]>() {
@Override
protected void execute(final DataRequestMonitor<IExpressionDMContext[]> rm) {
fExpService.getSubExpressions(exprDmc, rm);
}
};
fSession.getExecutor().execute(query);
IExpressionDMContext[] childDmcs = query.get();
String[] childExpressions = new String[childDmcs.length];
MIExpressionDMCAccessor[] childDmcsAccessor = new MIExpressionDMCAccessor[childDmcs.length];
// Convert to a MIExpressionDMCAccessor to be able to call getRelativeExpression
// Also convert to String[] to be able to use Arrays.toString()
for (int i = 0; i < childExpressions.length; i++) {
childDmcsAccessor[i] = new MIExpressionDMCAccessor(childDmcs[i]);
childExpressions[i] = childDmcsAccessor[i].getRelativeExpression();
}
assertTrue("Expected " + Arrays.toString(children) + " but got " + Arrays.toString(childExpressions),
children.length == childExpressions.length);
for (int i = 0; i < childDmcsAccessor.length; i++) {
assertEquals(childDmcsAccessor[i].getRelativeExpression(), children[i]);
}
}
/**
* Test we cannot modify the value of a group-expression
*/
@Test
public void testGroupExpressionNotModifiable() throws Throwable {
final String exprString = "$eax,*";
// final String[] children = new String[] { "$eax", "firstarg", "firstvar", "secondarg", "secondvar" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
Query<Boolean> query = new Query<Boolean>() {
@Override
protected void execute(final DataRequestMonitor<Boolean> rm) {
fExpService.canWriteExpression(exprDmc, rm);
}
};
fSession.getExecutor().execute(query);
boolean canWrite = query.get();
assertFalse("Should not be able to modify the value of a group-expression", canWrite);
}
/**
* Test the only available format for the value of a group-expression is NATURAL
*/
@Test
public void testGroupExpressionAvailableFormats() throws Throwable {
final String exprString = "$eax,*";
// final String[] children = new String[] { "$eax", "firstarg", "firstvar", "secondarg", "secondvar" };
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString);
Query<String[]> query = new Query<String[]>() {
@Override
protected void execute(final DataRequestMonitor<String[]> rm) {
fExpService.getAvailableFormats(exprDmc, rm);
}
};
fSession.getExecutor().execute(query);
String[] formats = query.get();
assertEquals(1, formats.length);
assertEquals(IFormattedValues.NATURAL_FORMAT, formats[0]);
}
/**
* Test the different values returned by a group-expression
*/
@Test
public void testGroupExpressionValue() throws Throwable {
final String noMatchExpr = "$zzz*";
final String singleMatchExpr = "$eax,";
final String doubleMatchExpr = "$eax,$ebx";
SyncUtil.runToLocation("foo");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
final IExpressionDMContext noMatchExprDmc = SyncUtil.createExpression(frameDmc, noMatchExpr);
final IExpressionDMContext singleMatchExprDmc = SyncUtil.createExpression(frameDmc, singleMatchExpr);
final IExpressionDMContext doubleMatchExprDmc = SyncUtil.createExpression(frameDmc, doubleMatchExpr);
assertEquals("No matches", getExpressionValue(noMatchExprDmc));
assertEquals("1 unique match", getExpressionValue(singleMatchExprDmc));
assertEquals("2 unique matches", getExpressionValue(doubleMatchExprDmc));
}
}

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.GDBPatternMatchingExpressionsTest;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBPatternMatchingExpressionsTest_6_6 extends GDBPatternMatchingExpressionsTest {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
}
}

View file

@ -33,6 +33,7 @@ import org.junit.runners.Suite;
MIRunControlTest_6_6.class,
MIRunControlTargetAvailableTest_6_6.class,
MIExpressionsTest_6_6.class,
GDBPatternMatchingExpressionsTest_6_6.class,
MIMemoryTest_6_6.class,
MIBreakpointsTest_6_6.class,
MICatchpointsTest_6_6.class,

View file

@ -34,6 +34,7 @@ import org.junit.runners.Suite;
MIRunControlTest_6_6.class,
MIRunControlTargetAvailableTest_6_6.class,
MIExpressionsTest_6_6.class,
GDBPatternMatchingExpressionsTest_6_6.class,
MIMemoryTest_6_6.class,
MIBreakpointsTest_6_6.class,
MICatchpointsTest_6_6.class,

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6.GDBPatternMatchingExpressionsTest_6_6;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBPatternMatchingExpressionsTest_6_7 extends GDBPatternMatchingExpressionsTest_6_6 {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_7);
}
}

View file

@ -33,6 +33,7 @@ import org.junit.runners.Suite;
MIRunControlTest_6_7.class,
MIRunControlTargetAvailableTest_6_7.class,
MIExpressionsTest_6_7.class,
GDBPatternMatchingExpressionsTest_6_7.class,
MIMemoryTest_6_7.class,
MIBreakpointsTest_6_7.class,
MICatchpointsTest_6_7.class,

View file

@ -34,6 +34,7 @@ import org.junit.runners.Suite;
MIRunControlTest_6_7.class,
MIRunControlTargetAvailableTest_6_7.class,
MIExpressionsTest_6_7.class,
GDBPatternMatchingExpressionsTest_6_7.class,
MIMemoryTest_6_7.class,
MIBreakpointsTest_6_7.class,
MICatchpointsTest_6_7.class,

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7.GDBPatternMatchingExpressionsTest_6_7;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBPatternMatchingExpressionsTest_6_8 extends GDBPatternMatchingExpressionsTest_6_7 {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_8);
}
}

View file

@ -33,6 +33,7 @@ import org.junit.runners.Suite;
MIRunControlTest_6_8.class,
MIRunControlTargetAvailableTest_6_8.class,
MIExpressionsTest_6_8.class,
GDBPatternMatchingExpressionsTest_6_8.class,
MIMemoryTest_6_8.class,
MIBreakpointsTest_6_8.class,
MICatchpointsTest_6_8.class,

View file

@ -34,6 +34,7 @@ import org.junit.runners.Suite;
MIRunControlTest_6_8.class,
MIRunControlTargetAvailableTest_6_8.class,
MIExpressionsTest_6_8.class,
GDBPatternMatchingExpressionsTest_6_8.class,
MIMemoryTest_6_8.class,
MIBreakpointsTest_6_8.class,
MICatchpointsTest_6_8.class,

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8.GDBPatternMatchingExpressionsTest_6_8;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBPatternMatchingExpressionsTest_7_0 extends GDBPatternMatchingExpressionsTest_6_8 {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_0);
}
}

View file

@ -34,6 +34,7 @@ import org.junit.runners.Suite;
MIRunControlTargetAvailableTest_7_0.class,
MIRunControlNonStopTargetAvailableTest_7_0.class,
MIExpressionsTest_7_0.class,
GDBPatternMatchingExpressionsTest_7_0.class,
MIMemoryTest_7_0.class,
MIBreakpointsTest_7_0.class,
MICatchpointsTest_7_0.class,

View file

@ -36,6 +36,7 @@ import org.junit.runners.Suite;
MIRunControlNonStopTargetAvailableTest_7_0.class,
MIRunControlTest_7_0.class,
MIExpressionsTest_7_0.class,
GDBPatternMatchingExpressionsTest_7_0.class,
MIMemoryTest_7_0.class,
MIBreakpointsTest_7_0.class,
MICatchpointsTest_7_0.class,

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0.GDBPatternMatchingExpressionsTest_7_0;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBPatternMatchingExpressionsTest_7_1 extends GDBPatternMatchingExpressionsTest_7_0 {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_1);
}
}

View file

@ -34,6 +34,7 @@ import org.junit.runners.Suite;
MIRunControlTargetAvailableTest_7_1.class,
MIRunControlNonStopTargetAvailableTest_7_1.class,
MIExpressionsTest_7_1.class,
GDBPatternMatchingExpressionsTest_7_1.class,
MIMemoryTest_7_1.class,
MIBreakpointsTest_7_1.class,
MICatchpointsTest_7_1.class,

View file

@ -36,6 +36,7 @@ import org.junit.runners.Suite;
MIRunControlNonStopTargetAvailableTest_7_1.class,
MIRunControlTest_7_1.class,
MIExpressionsTest_7_1.class,
GDBPatternMatchingExpressionsTest_7_1.class,
MIMemoryTest_7_1.class,
MIBreakpointsTest_7_1.class,
MICatchpointsTest_7_1.class,

View file

@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1.GDBPatternMatchingExpressionsTest_7_1;
import org.eclipse.core.runtime.Platform;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBPatternMatchingExpressionsTest_7_2 extends GDBPatternMatchingExpressionsTest_7_1 {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2);
}
// GDB's list of registers is different with GDB 7.2
@Override
protected List<String> get_X86_REGS() {
// Because we are dealing with expressions for the registers, we must prefix them with '$'
List<String> list = new LinkedList<String>(Arrays.asList("$eax","$ecx","$edx","$ebx","$esp","$ebp","$esi","$edi","$eip","$eflags",
"$cs","$ss","$ds","$es","$fs","$gs","$st0","$st1","$st2","$st3",
"$st4","$st5","$st6","$st7","$fctrl","$fstat","$ftag","$fiseg","$fioff","$foseg",
"$fooff","$fop","$xmm0","$xmm1","$xmm2","$xmm3","$xmm4","$xmm5","$xmm6","$xmm7",
"$mxcsr",/*"","","","","","","","",*/"$orig_eax",
"$al","$cl","$dl","$bl","$ah","$ch","$dh","$bh","$ax","$cx",
"$dx","$bx",/*"",*/"$bp","$si","$di","$mm0","$mm1","$mm2","$mm3",
"$mm4","$mm5","$mm6","$mm7"));
// On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux
if (Platform.getOS().equals(Platform.OS_WIN32)) {
list.remove("$orig_eax");
}
return list;
}
}

View file

@ -34,6 +34,7 @@ import org.junit.runners.Suite;
MIRunControlTargetAvailableTest_7_2.class,
MIRunControlNonStopTargetAvailableTest_7_2.class,
MIExpressionsTest_7_2.class,
GDBPatternMatchingExpressionsTest_7_2.class,
MIMemoryTest_7_2.class,
MIBreakpointsTest_7_2.class,
MICatchpointsTest_7_2.class,

View file

@ -36,6 +36,7 @@ import org.junit.runners.Suite;
MIRunControlTargetAvailableTest_7_2.class,
MIRunControlNonStopTargetAvailableTest_7_2.class,
MIExpressionsTest_7_2.class,
GDBPatternMatchingExpressionsTest_7_2.class,
MIMemoryTest_7_2.class,
MIBreakpointsTest_7_2.class,
MICatchpointsTest_7_2.class,

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2.GDBPatternMatchingExpressionsTest_7_2;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBPatternMatchingExpressionsTest_7_3 extends GDBPatternMatchingExpressionsTest_7_2 {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_3);
}
}

View file

@ -34,6 +34,7 @@ import org.junit.runners.Suite;
MIRunControlTargetAvailableTest_7_3.class,
MIRunControlNonStopTargetAvailableTest_7_3.class,
MIExpressionsTest_7_3.class,
GDBPatternMatchingExpressionsTest_7_3.class,
MIMemoryTest_7_3.class,
MIBreakpointsTest_7_3.class,
MICatchpointsTest_7_3.class,

View file

@ -36,6 +36,7 @@ import org.junit.runners.Suite;
MIRunControlTargetAvailableTest_7_3.class,
MIRunControlNonStopTargetAvailableTest_7_3.class,
MIExpressionsTest_7_3.class,
GDBPatternMatchingExpressionsTest_7_3.class,
MIMemoryTest_7_3.class,
MIBreakpointsTest_7_3.class,
MICatchpointsTest_7_3.class,

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3.GDBPatternMatchingExpressionsTest_7_3;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBPatternMatchingExpressionsTest_7_4 extends GDBPatternMatchingExpressionsTest_7_3 {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_4);
}
}

View file

@ -34,6 +34,7 @@ import org.junit.runners.Suite;
MIRunControlTargetAvailableTest_7_4.class,
MIRunControlNonStopTargetAvailableTest_7_4.class,
MIExpressionsTest_7_4.class,
GDBPatternMatchingExpressionsTest_7_4.class,
MIMemoryTest_7_4.class,
MIBreakpointsTest_7_4.class,
MICatchpointsTest_7_4.class,

View file

@ -36,6 +36,7 @@ import org.junit.runners.Suite;
MIRunControlTargetAvailableTest_7_4.class,
MIRunControlNonStopTargetAvailableTest_7_4.class,
MIExpressionsTest_7_4.class,
GDBPatternMatchingExpressionsTest_7_4.class,
MIMemoryTest_7_4.class,
MIBreakpointsTest_7_4.class,
MICatchpointsTest_7_4.class,

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4.GDBPatternMatchingExpressionsTest_7_4;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBPatternMatchingExpressionsTest_7_5 extends GDBPatternMatchingExpressionsTest_7_4 {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_5);
}
}

View file

@ -34,6 +34,7 @@ import org.junit.runners.Suite;
MIRunControlTargetAvailableTest_7_5.class,
MIRunControlNonStopTargetAvailableTest_7_5.class,
MIExpressionsTest_7_5.class,
GDBPatternMatchingExpressionsTest_7_5.class,
MIMemoryTest_7_5.class,
MIBreakpointsTest_7_5.class,
MICatchpointsTest_7_5.class,

View file

@ -36,6 +36,7 @@ import org.junit.runners.Suite;
MIRunControlTargetAvailableTest_7_5.class,
MIRunControlNonStopTargetAvailableTest_7_5.class,
MIExpressionsTest_7_5.class,
GDBPatternMatchingExpressionsTest_7_5.class,
MIMemoryTest_7_5.class,
MIBreakpointsTest_7_5.class,
MICatchpointsTest_7_5.class,

View file

@ -498,6 +498,11 @@ public class CMainTab extends CAbstractMainTab {
// Notice that we don't check if exePath points to a valid executable since such
// check is too expensive to be done on the UI thread.
// See "https://bugs.eclipse.org/bugs/show_bug.cgi?id=328012".
// We only verify that the program path represents a file.
if (!exePath.toFile().isFile()) {
setErrorMessage(fPreviouslyCheckedProgramErrorMsg = LaunchMessages.CMainTab_Selection_must_be_file);
return (fPreviouslyCheckedProgramIsValid = false);
}
}
}