1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 19:35:36 +02:00

Merge branch 'master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-01-06 00:04:07 -05:00
commit 68dfbade0a
27 changed files with 510 additions and 103 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation and others. * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -16,6 +16,7 @@ package org.eclipse.cdt.core.parser.tests.ast2;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.XVALUE; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.XVALUE;
import static org.eclipse.cdt.core.parser.ParserLanguage.CPP;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@ -9625,4 +9626,24 @@ public class AST2CPPTests extends AST2BaseTest {
IBinding ctor= bh.assertNonProblem("E(){}", 1); IBinding ctor= bh.assertNonProblem("E(){}", 1);
assertTrue(ctor instanceof ICPPConstructor); assertTrue(ctor instanceof ICPPConstructor);
} }
// struct S;
// struct S {
// S();
// ~S();
// T();
// ~T();
// };
public void testErrorForDestructorWithWrongName_367590() throws Exception {
IASTTranslationUnit tu= parse(getAboveComment(), CPP, false, false);
IASTCompositeTypeSpecifier S;
IASTProblemDeclaration p;
IASTSimpleDeclaration s;
S= getCompositeType(tu, 1);
s= getDeclaration(S, 0);
s= getDeclaration(S, 1);
p= getDeclaration(S, 2);
p= getDeclaration(S, 3);
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2011 IBM Corporation and others. * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -5689,4 +5689,18 @@ public class AST2TemplateTests extends AST2BaseTest {
public void testDeductionForConstFunctionType_367562() throws Exception { public void testDeductionForConstFunctionType_367562() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <typename> struct base {
// typedef int type;
// };
// template <typename A, typename B> struct derived;
// template <typename B> struct derived<int, B> : public base<B> {
// typedef typename derived::type type; // ERROR HERE
// };
public void testTemplateShortNameInQualifiedName_367607() throws Exception {
parseAndCheckBindings();
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
ICPPDeferredClassInstance shortHand= bh.assertNonProblem("derived:", -1);
assertTrue(shortHand.getClassTemplate() instanceof ICPPClassTemplatePartialSpecialization);
}
} }

View file

@ -14,9 +14,7 @@ import java.io.IOException;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.parser.util.ASTPrinter;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
@ -41,13 +39,6 @@ public class ClassTypeHelperTests extends AST2BaseTest {
return new BindingAssertionHelper(code, true); return new BindingAssertionHelper(code, true);
} }
// int a;
// const int& b;
public void testTemp() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ASTPrinter.print(helper.getTranslationUnit());
}
// struct A { // struct A {
// A(const A& a); // A(const A& a);
// }; // };

View file

@ -36,13 +36,13 @@ import org.eclipse.core.runtime.CoreException;
* *
*/ */
public class BTreeTests extends BaseTestCase { public class BTreeTests extends BaseTestCase {
private static int DEBUG= 0;
protected File dbFile; protected File dbFile;
protected Database db; protected Database db;
protected BTree btree; protected BTree btree;
protected int rootRecord; protected int rootRecord;
protected IBTreeComparator comparator; protected IBTreeComparator comparator;
protected boolean debugMode = false;
public static Test suite() { public static Test suite() {
return suite(BTreeTests.class); return suite(BTreeTests.class);
@ -80,6 +80,7 @@ public class BTreeTests extends BaseTestCase {
for(int i=0; i<noTrials; i++) { for(int i=0; i<noTrials; i++) {
int seed = seeder.nextInt(); int seed = seeder.nextInt();
if (DEBUG > 0)
System.out.println("Iteration #"+i); System.out.println("Iteration #"+i);
trial(seed, false); trial(seed, false);
} }
@ -95,6 +96,7 @@ public class BTreeTests extends BaseTestCase {
for(int i=0; i<6; i++) { for(int i=0; i<6; i++) {
int seed = seeder.nextInt(); int seed = seeder.nextInt();
if (DEBUG > 0)
System.out.println("Iteration #"+i); System.out.println("Iteration #"+i);
trialImp(seed, false, new Random(seed*2), 1); trialImp(seed, false, new Random(seed*2), 1);
} }
@ -124,6 +126,7 @@ public class BTreeTests extends BaseTestCase {
init(degree); init(degree);
if (DEBUG > 0)
System.out.print("\t "+seed+" "+(nIterations/1000)+"K: "); System.out.print("\t "+seed+" "+(nIterations/1000)+"K: ");
for(int i=0; i<nIterations; i++) { for(int i=0; i<nIterations; i++) {
if(random.nextDouble()<pInsert) { if(random.nextDouble()<pInsert) {
@ -132,7 +135,7 @@ public class BTreeTests extends BaseTestCase {
if(newEntry) { if(newEntry) {
BTMockRecord btValue = new BTMockRecord(db, value.intValue()); BTMockRecord btValue = new BTMockRecord(db, value.intValue());
history.add(btValue); history.add(btValue);
if(debugMode) if(DEBUG > 1)
System.out.println("Add: "+value+" @ "+btValue.record); System.out.println("Add: "+value+" @ "+btValue.record);
btree.insert(btValue.getRecord()); btree.insert(btValue.getRecord());
} }
@ -142,12 +145,12 @@ public class BTreeTests extends BaseTestCase {
BTMockRecord btValue = (BTMockRecord) history.get(index); BTMockRecord btValue = (BTMockRecord) history.get(index);
history.remove(index); history.remove(index);
expected.remove(new Integer(btValue.intValue())); expected.remove(new Integer(btValue.intValue()));
if(debugMode) if(DEBUG > 1)
System.out.println("Remove: "+btValue.intValue()+" @ "+btValue.record); System.out.println("Remove: "+btValue.intValue()+" @ "+btValue.record);
btree.delete(btValue.getRecord()); btree.delete(btValue.getRecord());
} }
} }
if(i % 1000 == 0) { if(i % 1000 == 0 && DEBUG > 0) {
System.out.print("."); System.out.print(".");
} }
if(checkCorrectnessEachIteration) { if(checkCorrectnessEachIteration) {
@ -155,6 +158,7 @@ public class BTreeTests extends BaseTestCase {
assertBTreeInvariantsHold("[iteration "+i+"] "); assertBTreeInvariantsHold("[iteration "+i+"] ");
} }
} }
if (DEBUG > 0)
System.out.println(); System.out.println();
assertBTreeMatchesSortedSet("[Trial end] ", btree, expected); assertBTreeMatchesSortedSet("[Trial end] ", btree, expected);
@ -174,9 +178,11 @@ public class BTreeTests extends BaseTestCase {
final Iterator i = expected.iterator(); final Iterator i = expected.iterator();
btree.accept(new IBTreeVisitor(){ btree.accept(new IBTreeVisitor(){
int k; int k;
@Override
public int compare(long record) throws CoreException { public int compare(long record) throws CoreException {
return 0; return 0;
} }
@Override
public boolean visit(long record) throws CoreException { public boolean visit(long record) throws CoreException {
if(record!=0) { if(record!=0) {
BTMockRecord btValue = new BTMockRecord(record, db); BTMockRecord btValue = new BTMockRecord(record, db);
@ -227,6 +233,7 @@ public class BTreeTests extends BaseTestCase {
} }
private class BTMockRecordComparator implements IBTreeComparator { private class BTMockRecordComparator implements IBTreeComparator {
@Override
public int compare(long record1, long record2) throws CoreException { public int compare(long record1, long record2) throws CoreException {
return db.getInt(record1) - db.getInt(record2); return db.getInt(record1) - db.getInt(record2);
} }

View file

@ -117,8 +117,8 @@ public class ClassTests extends PDOMTestBase {
bindings = ns.find("testRef"); bindings = ns.find("testRef");
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES); IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES);
for (int i = 0; i < refs.length; ++i) // for (int i = 0; i < refs.length; ++i)
System.out.println(refs[i].getFileLocation().getNodeOffset()); // System.out.println(refs[i].getFileLocation().getNodeOffset());
assertEquals(5, refs.length); assertEquals(5, refs.length);
} }

View file

@ -255,8 +255,8 @@ public class DBTest extends BaseTestCase {
int expected = caseSensitive ? a.compareTo(b) : a.compareToIgnoreCase(b); int expected = caseSensitive ? a.compareTo(b) : a.compareToIgnoreCase(b);
assertCMP(a, expected, b, caseSensitive); assertCMP(a, expected, b, caseSensitive);
} }
System.out.print("Trials: "+n+" Max length: "+max+" ignoreCase: "+!caseSensitive); // System.out.print("Trials: "+n+" Max length: "+max+" ignoreCase: "+!caseSensitive);
System.out.println(" Time: "+(System.currentTimeMillis()-start)); // System.out.println(" Time: "+(System.currentTimeMillis()-start));
} }
private String randomString(int min, int max, Random r) { private String randomString(int min, int max, Random r) {

View file

@ -274,6 +274,7 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
IIndexerStateListener listener= null; IIndexerStateListener listener= null;
if(stateCount != null) { if(stateCount != null) {
listener= new IIndexerStateListener() { listener= new IIndexerStateListener() {
@Override
public void indexChanged(IIndexerStateEvent event) { public void indexChanged(IIndexerStateEvent event) {
stateCount[0]++; stateCount[0]++;
} }
@ -299,8 +300,14 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
} }
private void doGenerate(String[] args) throws CoreException { private void doGenerate(String[] args) throws CoreException {
GeneratePDOMApplication app = new GeneratePDOMApplication(); GeneratePDOMApplication app = new GeneratePDOMApplication() {
IApplicationContext ac= new MockApplicationContext(args); @Override
protected void output(String s) {}
};
String[] newArgs= new String[args.length+1];
newArgs[0]= GeneratePDOMApplication.OPT_QUIET;
System.arraycopy(args, 0, newArgs, 1, args.length);
IApplicationContext ac= new MockApplicationContext(newArgs);
app.start(ac); app.start(ac);
} }
@ -309,73 +316,93 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
*/ */
public static class TestProjectProvider1 implements IExportProjectProvider { public static class TestProjectProvider1 implements IExportProjectProvider {
@Override
public ICProject createProject() throws CoreException {return null;} public ICProject createProject() throws CoreException {return null;}
@Override
public Map getExportProperties() {return null;} public Map getExportProperties() {return null;}
@Override
public IIndexLocationConverter getLocationConverter(ICProject cproject) {return null;} public IIndexLocationConverter getLocationConverter(ICProject cproject) {return null;}
@Override
public void setApplicationArguments(String[] arguments) {} public void setApplicationArguments(String[] arguments) {}
} }
public static class TestProjectProvider2 implements IExportProjectProvider { public static class TestProjectProvider2 implements IExportProjectProvider {
@Override
public ICProject createProject() throws CoreException { public ICProject createProject() throws CoreException {
ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
toDeleteOnTearDown.add(cproject); toDeleteOnTearDown.add(cproject);
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1); CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
return cproject; return cproject;
} }
@Override
public Map getExportProperties() {return null;} public Map getExportProperties() {return null;}
@Override
public IIndexLocationConverter getLocationConverter(ICProject cproject) {return null;} public IIndexLocationConverter getLocationConverter(ICProject cproject) {return null;}
@Override
public void setApplicationArguments(String[] arguments) {} public void setApplicationArguments(String[] arguments) {}
} }
public static class TestProjectProvider3 implements IExportProjectProvider { public static class TestProjectProvider3 implements IExportProjectProvider {
@Override
public ICProject createProject() throws CoreException { public ICProject createProject() throws CoreException {
ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
toDeleteOnTearDown.add(cproject); toDeleteOnTearDown.add(cproject);
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1); CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
return cproject; return cproject;
} }
@Override
public Map getExportProperties() {return null;} public Map getExportProperties() {return null;}
@Override
public IIndexLocationConverter getLocationConverter(ICProject cproject) { public IIndexLocationConverter getLocationConverter(ICProject cproject) {
return new ResourceContainerRelativeLocationConverter(cproject.getProject()); return new ResourceContainerRelativeLocationConverter(cproject.getProject());
} }
@Override
public void setApplicationArguments(String[] arguments) {} public void setApplicationArguments(String[] arguments) {}
} }
public static class TestProjectProvider4 implements IExportProjectProvider { public static class TestProjectProvider4 implements IExportProjectProvider {
@Override
public ICProject createProject() throws CoreException { public ICProject createProject() throws CoreException {
ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
toDeleteOnTearDown.add(cproject); toDeleteOnTearDown.add(cproject);
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1); CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
return cproject; return cproject;
} }
@Override
public Map getExportProperties() { public Map getExportProperties() {
Map map= new HashMap(); Map map= new HashMap();
map.put(SDK_VERSION, "4.0.1"); map.put(SDK_VERSION, "4.0.1");
map.put(IIndexFragment.PROPERTY_FRAGMENT_ID, ACME_SDK_ID); map.put(IIndexFragment.PROPERTY_FRAGMENT_ID, ACME_SDK_ID);
return map; return map;
} }
@Override
public IIndexLocationConverter getLocationConverter(ICProject cproject) { public IIndexLocationConverter getLocationConverter(ICProject cproject) {
return new ResourceContainerRelativeLocationConverter(cproject.getProject()); return new ResourceContainerRelativeLocationConverter(cproject.getProject());
} }
@Override
public void setApplicationArguments(String[] arguments) {} public void setApplicationArguments(String[] arguments) {}
} }
public static class TestProjectProvider5 implements IExportProjectProvider { public static class TestProjectProvider5 implements IExportProjectProvider {
@Override
public ICProject createProject() throws CoreException { public ICProject createProject() throws CoreException {
ICProject cproject= CProjectHelper.createCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); ICProject cproject= CProjectHelper.createCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
toDeleteOnTearDown.add(cproject); toDeleteOnTearDown.add(cproject);
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ3); CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ3);
return cproject; return cproject;
} }
@Override
public Map getExportProperties() { public Map getExportProperties() {
Map map= new HashMap(); Map map= new HashMap();
map.put(SDK_VERSION, "4.0.1"); map.put(SDK_VERSION, "4.0.1");
map.put(IIndexFragment.PROPERTY_FRAGMENT_ID, ACME_SDK_ID); map.put(IIndexFragment.PROPERTY_FRAGMENT_ID, ACME_SDK_ID);
return map; return map;
} }
@Override
public IIndexLocationConverter getLocationConverter(ICProject cproject) { public IIndexLocationConverter getLocationConverter(ICProject cproject) {
return new ResourceContainerRelativeLocationConverter(cproject.getProject()); return new ResourceContainerRelativeLocationConverter(cproject.getProject());
} }
@Override
public void setApplicationArguments(String[] arguments) {} public void setApplicationArguments(String[] arguments) {}
} }
} }
@ -386,13 +413,22 @@ class MockApplicationContext implements IApplicationContext {
arguments= new HashMap(); arguments= new HashMap();
arguments.put(APPLICATION_ARGS, appArgs); arguments.put(APPLICATION_ARGS, appArgs);
} }
@Override
public void applicationRunning() {} public void applicationRunning() {}
@Override
public Map getArguments() {return arguments;} public Map getArguments() {return arguments;}
@Override
public String getBrandingApplication() {return null;} public String getBrandingApplication() {return null;}
@Override
public Bundle getBrandingBundle() {return null;} public Bundle getBrandingBundle() {return null;}
@Override
public String getBrandingDescription() {return null;} public String getBrandingDescription() {return null;}
@Override
public String getBrandingId() {return null;} public String getBrandingId() {return null;}
@Override
public String getBrandingName() {return null;} public String getBrandingName() {return null;}
@Override
public String getBrandingProperty(String key) {return null;} public String getBrandingProperty(String key) {return null;}
@Override
public void setResult(Object result, IApplication application) {} public void setResult(Object result, IApplication application) {}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others. * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -124,7 +124,7 @@ public interface IASTName extends IASTNode, IName {
public char[] getLookupKey(); public char[] getLookupKey();
/** /**
* Gets the intermediate representation of the biniding, if already available. * Gets the intermediate representation of the binding, if already available.
* @noreference This method is not intended to be referenced by clients. * @noreference This method is not intended to be referenced by clients.
*/ */
public IBinding getPreBinding(); public IBinding getPreBinding();
@ -134,4 +134,10 @@ public interface IASTName extends IASTNode, IName {
* @noreference This method is not intended to be referenced by clients. * @noreference This method is not intended to be referenced by clients.
*/ */
public IBinding resolvePreBinding(); public IBinding resolvePreBinding();
/**
* Returns whether this name is qualified, i.e. whether it is preceded by a scope operator.
* @since 5.4
*/
public boolean isQualified();
} }

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
@ -24,7 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
* @since 5.3 * @since 5.3
*/ */
public interface ICPPASTRangeBasedForStatement extends IASTStatement { public interface ICPPASTRangeBasedForStatement extends IASTStatement, IASTImplicitNameOwner {
public static final ASTNodeProperty DECLARATION = new ASTNodeProperty( public static final ASTNodeProperty DECLARATION = new ASTNodeProperty(
"ICPPASTRangeBasedForStatement.DECLARATION [IASTDeclaration]"); //$NON-NLS-1$ "ICPPASTRangeBasedForStatement.DECLARATION [IASTDeclaration]"); //$NON-NLS-1$
public static final ASTNodeProperty INITIALIZER = new ASTNodeProperty( public static final ASTNodeProperty INITIALIZER = new ASTNodeProperty(
@ -53,8 +54,10 @@ public interface ICPPASTRangeBasedForStatement extends IASTStatement {
*/ */
public IScope getScope(); public IScope getScope();
@Override
public ICPPASTRangeBasedForStatement copy(); public ICPPASTRangeBasedForStatement copy();
@Override
public ICPPASTRangeBasedForStatement copy(CopyStyle style); public ICPPASTRangeBasedForStatement copy(CopyStyle style);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2011 IBM Corporation and others. * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -265,4 +265,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
public IASTName getLastName() { public IASTName getLastName() {
return this; return this;
} }
@Override
public boolean isQualified() {
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. * Copyright (c) 2008, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner; import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
@ -152,6 +153,22 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return this; return this;
} }
@Override
public boolean isQualified() {
IASTNode parent= getParent();
if (parent instanceof ICPPASTQualifiedName) {
ICPPASTQualifiedName qn= (ICPPASTQualifiedName) parent;
if (qn.isFullyQualified())
return true;
IASTName[] qns = qn.getNames();
if (qns.length > 0 && qns[0] == this)
return false;
return true;
}
return false;
}
@Override @Override
public final String toString() { public final String toString() {
return new String(toCharArray()); return new String(toCharArray());

View file

@ -10,15 +10,26 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
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.TDEF;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
/** /**
* Range based for loop in c++. * Range based for loop in c++.
@ -28,14 +39,17 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang
private IASTDeclaration fDeclaration; private IASTDeclaration fDeclaration;
private IASTInitializerClause fInitClause; private IASTInitializerClause fInitClause;
private IASTStatement fBody; private IASTStatement fBody;
private IASTImplicitName[] fImplicitNames;
public CPPASTRangeBasedForStatement() { public CPPASTRangeBasedForStatement() {
} }
@Override
public CPPASTRangeBasedForStatement copy() { public CPPASTRangeBasedForStatement copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);
} }
@Override
public CPPASTRangeBasedForStatement copy(CopyStyle style) { public CPPASTRangeBasedForStatement copy(CopyStyle style) {
CPPASTRangeBasedForStatement copy = new CPPASTRangeBasedForStatement(); CPPASTRangeBasedForStatement copy = new CPPASTRangeBasedForStatement();
copy.setDeclaration(fDeclaration == null ? null : fDeclaration.copy(style)); copy.setDeclaration(fDeclaration == null ? null : fDeclaration.copy(style));
@ -48,10 +62,12 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang
return copy; return copy;
} }
@Override
public IASTDeclaration getDeclaration() { public IASTDeclaration getDeclaration() {
return fDeclaration; return fDeclaration;
} }
@Override
public void setDeclaration(IASTDeclaration declaration) { public void setDeclaration(IASTDeclaration declaration) {
assertNotFrozen(); assertNotFrozen();
this.fDeclaration = declaration; this.fDeclaration = declaration;
@ -61,10 +77,12 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang
} }
} }
@Override
public IASTInitializerClause getInitializerClause() { public IASTInitializerClause getInitializerClause() {
return fInitClause; return fInitClause;
} }
@Override
public void setInitializerClause(IASTInitializerClause initClause) { public void setInitializerClause(IASTInitializerClause initClause) {
assertNotFrozen(); assertNotFrozen();
fInitClause = initClause; fInitClause = initClause;
@ -74,10 +92,12 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang
} }
} }
@Override
public IASTStatement getBody() { public IASTStatement getBody() {
return fBody; return fBody;
} }
@Override
public void setBody(IASTStatement statement) { public void setBody(IASTStatement statement) {
assertNotFrozen(); assertNotFrozen();
fBody = statement; fBody = statement;
@ -87,12 +107,72 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang
} }
} }
@Override
public IScope getScope() { public IScope getScope() {
if (fScope == null) if (fScope == null)
fScope = new CPPBlockScope(this); fScope = new CPPBlockScope(this);
return fScope; return fScope;
} }
@Override
public IASTImplicitName[] getImplicitNames() {
if (fImplicitNames == null) {
IASTInitializerClause forInit = getInitializerClause();
final ASTNode position = (ASTNode) forInit;
if (forInit instanceof IASTExpression) {
final IASTExpression forInitExpr = (IASTExpression) forInit;
IType type= SemanticUtil.getNestedType(forInitExpr.getExpressionType(), TDEF|CVTYPE);
if (type instanceof IArrayType) {
fImplicitNames= IASTImplicitName.EMPTY_NAME_ARRAY;
} else if (type instanceof ICPPClassType) {
ICPPClassType ct= (ICPPClassType) type;
if (CPPSemantics.findBindings(ct.getCompositeScope(), CPPVisitor.BEGIN_STR, true).length > 0) {
CPPASTName name = new CPPASTName(CPPVisitor.BEGIN);
name.setOffset(position.getOffset());
CPPASTFieldReference fieldRef = new CPPASTFieldReference(name, forInitExpr.copy());
IASTExpression expr= new CPPASTFunctionCallExpression(fieldRef, CPPVisitor.NO_ARGS);
expr.setParent(this);
expr.setPropertyInParent(ICPPASTRangeBasedForStatement.INITIALIZER);
CPPASTImplicitName begin= new CPPASTImplicitName(name.toCharArray(), this);
begin.setBinding(name.resolveBinding());
begin.setOffsetAndLength(position);
name = new CPPASTName(CPPVisitor.END);
name.setOffset(position.getOffset());
fieldRef.setFieldName(name);
CPPASTImplicitName end= new CPPASTImplicitName(name.toCharArray(), this);
end.setBinding(name.resolveBinding());
end.setOffsetAndLength(position);
fImplicitNames= new IASTImplicitName[] {begin, end};
}
}
}
if (fImplicitNames == null) {
CPPASTName name = new CPPASTName(CPPVisitor.BEGIN);
name.setOffset(position.getOffset());
CPPASTIdExpression fname = new CPPASTIdExpression(name);
IASTExpression expr= new CPPASTFunctionCallExpression(fname, new IASTInitializerClause[] {forInit.copy()});
expr.setParent(this);
expr.setPropertyInParent(ICPPASTRangeBasedForStatement.INITIALIZER);
CPPASTImplicitName begin= new CPPASTImplicitName(name.toCharArray(), this);
begin.setBinding(name.resolveBinding());
begin.setOffsetAndLength(position);
name = new CPPASTName(CPPVisitor.END);
name.setOffset(position.getOffset());
fname.setName(name);
CPPASTImplicitName end= new CPPASTImplicitName(name.toCharArray(), this);
end.setBinding(name.resolveBinding());
end.setOffsetAndLength(position);
fImplicitNames= new IASTImplicitName[] {begin, end};
}
}
return fImplicitNames;
}
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept( ASTVisitor action ){
if (action.shouldVisitStatements) { if (action.shouldVisitStatements) {
@ -106,6 +186,14 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang
return false; return false;
if (fInitClause != null && !fInitClause.accept(action)) if (fInitClause != null && !fInitClause.accept(action))
return false; return false;
IASTImplicitName[] implicits = action.shouldVisitImplicitNames ? getImplicitNames() : null;
if (implicits != null) {
for (IASTImplicitName implicit : implicits) {
if (!implicit.accept(action))
return false;
}
}
if (fBody != null && !fBody.accept(action)) if (fBody != null && !fBody.accept(action))
return false; return false;
@ -114,6 +202,7 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang
return true; return true;
} }
@Override
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if (child == fDeclaration) { if (child == fDeclaration) {
setDeclaration((IASTDeclaration) other); setDeclaration((IASTDeclaration) other);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2011 IBM Corporation and others. * Copyright (c) 2002, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -3211,17 +3211,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (name instanceof ICPPASTConversionName) if (name instanceof ICPPASTConversionName)
return; return;
// accept destructor
final char[] nchars= name.getLookupKey();
if (nchars.length > 0 && nchars[0] == '~')
return;
if (opt == DeclarationOptions.CPP_MEMBER) { if (opt == DeclarationOptions.CPP_MEMBER) {
// accept constructor within class body // Accept constructor and destructor within class body
if (CharArrayUtils.equals(nchars, currentClassName)) final char[] nchars= name.getLookupKey();
if (nchars.length > 0 && currentClassName != null) {
final int start= nchars[0] == '~' ? 1 : 0;
if (CharArrayUtils.equals(nchars, start, nchars.length-start, currentClassName))
return; return;
}
} else if (isQualified) { } else if (isQualified) {
// accept qualified constructor outside of class body // Accept qualified constructor or destructor outside of class body
return; return;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others. * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -324,7 +324,7 @@ public class CPPSemantics {
if (binding instanceof ICPPClassTemplate && !(binding instanceof ICPPClassSpecialization) && if (binding instanceof ICPPClassTemplate && !(binding instanceof ICPPClassSpecialization) &&
!(binding instanceof ICPPTemplateParameter) && !(data.astName instanceof ICPPASTTemplateId)) { !(binding instanceof ICPPTemplateParameter) && !(data.astName instanceof ICPPASTTemplateId)) {
ASTNodeProperty prop = data.astName.getPropertyInParent(); ASTNodeProperty prop = data.astName.getPropertyInParent();
if (prop != ICPPASTTemplateId.TEMPLATE_NAME && prop != ICPPASTQualifiedName.SEGMENT_NAME) { if (prop != ICPPASTTemplateId.TEMPLATE_NAME && !data.astName.isQualified()) {
// You cannot use a class template name outside of the class template scope, // You cannot use a class template name outside of the class template scope,
// mark it as a problem. // mark it as a problem.
IBinding replacement= CPPTemplates.isUsedInClassTemplateScope((ICPPClassTemplate) binding, data.astName); IBinding replacement= CPPTemplates.isUsedInClassTemplateScope((ICPPClassTemplate) binding, data.astName);
@ -649,15 +649,14 @@ public class CPPSemantics {
} }
} }
if (data.astName != null if (data.astName != null) {
&& CharArrayUtils.equals(CPPVisitor.BEGIN, data.astName.getSimpleID())) { final char[] simpleID = data.astName.getSimpleID();
if (CharArrayUtils.equals(CPPVisitor.BEGIN, simpleID) || CharArrayUtils.equals(CPPVisitor.END, simpleID)) {
IASTNode parent = data.astName.getParent(); // id-expression IASTNode parent = data.astName.getParent(); // id-expression
if (parent != null) if (parent != null)
parent= parent.getParent(); // function call parent= parent.getParent(); // function call
if (parent != null) if (parent != null)
parent= parent.getParent(); // the loop parent= parent.getParent(); // the loop
if (parent != null)
parent= parent.getParent(); // unary *
if (parent instanceof ICPPASTRangeBasedForStatement) { if (parent instanceof ICPPASTRangeBasedForStatement) {
IBinding[] std= parent.getTranslationUnit().getScope().find(CPPVisitor.STD); IBinding[] std= parent.getTranslationUnit().getScope().find(CPPVisitor.STD);
for (IBinding binding : std) { for (IBinding binding : std) {
@ -667,6 +666,7 @@ public class CPPSemantics {
} }
} }
} }
}
return namespaces; return namespaces;
} }

View file

@ -48,6 +48,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement; import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner; import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
@ -151,7 +152,6 @@ import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
@ -201,14 +201,15 @@ public class CPPVisitor extends ASTQueries {
private static final CPPBasicType UNSIGNED_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED); private static final CPPBasicType UNSIGNED_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
private static final CPPBasicType INT_TYPE = new CPPBasicType(Kind.eInt, 0); private static final CPPBasicType INT_TYPE = new CPPBasicType(Kind.eInt, 0);
private static final String BEGIN_STR = "begin"; //$NON-NLS-1$ public static final String BEGIN_STR = "begin"; //$NON-NLS-1$
static final char[] BEGIN = BEGIN_STR.toCharArray(); public static final char[] BEGIN = BEGIN_STR.toCharArray();
public static final char[] END = "end".toCharArray(); //$NON-NLS-1$
static final String STD = "std"; //$NON-NLS-1$ static final String STD = "std"; //$NON-NLS-1$
private static final char[] SIZE_T = "size_t".toCharArray(); //$NON-NLS-1$ private static final char[] SIZE_T = "size_t".toCharArray(); //$NON-NLS-1$
private static final char[] PTRDIFF_T = "ptrdiff_t".toCharArray(); //$NON-NLS-1$ private static final char[] PTRDIFF_T = "ptrdiff_t".toCharArray(); //$NON-NLS-1$
private static final char[] TYPE_INFO= "type_info".toCharArray(); //$NON-NLS-1$ private static final char[] TYPE_INFO= "type_info".toCharArray(); //$NON-NLS-1$
private static final char[] INITIALIZER_LIST = "initializer_list".toCharArray(); //$NON-NLS-1$ private static final char[] INITIALIZER_LIST = "initializer_list".toCharArray(); //$NON-NLS-1$
private static final IASTInitializerClause[] NO_ARGS = {}; public static final IASTInitializerClause[] NO_ARGS = {};
// Thread-local set of DeclSpecifiers for which auto types are being created. // Thread-local set of DeclSpecifiers for which auto types are being created.
// Used to prevent infinite recursion while processing invalid self-referencing // Used to prevent infinite recursion while processing invalid self-referencing
@ -1925,22 +1926,23 @@ public class CPPVisitor extends ASTQueries {
IType type= SemanticUtil.getNestedType(expr.getExpressionType(), TDEF|CVTYPE); IType type= SemanticUtil.getNestedType(expr.getExpressionType(), TDEF|CVTYPE);
if (type instanceof IArrayType) { if (type instanceof IArrayType) {
beginExpr= expr.copy(); beginExpr= expr.copy();
} else if (type instanceof ICPPClassType) {
ICPPClassType ct= (ICPPClassType) type;
if (CPPSemantics.findBindings(ct.getCompositeScope(), BEGIN_STR, true).length > 0) {
final CPPASTName name = new CPPASTName(BEGIN);
name.setOffset(((ASTNode) forInit).getOffset());
beginExpr= new CPPASTFunctionCallExpression(
new CPPASTFieldReference(name, expr.copy()), NO_ARGS);
}
} }
} }
if (beginExpr == null) { if (beginExpr == null) {
final CPPASTName name = new CPPASTName(BEGIN); IASTImplicitName[] implicits= forStmt.getImplicitNames();
name.setOffset(((ASTNode) forInit).getOffset()); if (implicits.length > 0) {
IBinding b= implicits[0].getBinding();
CPPASTName name= new CPPASTName();
name.setBinding(b);
if (b instanceof ICPPMethod) {
beginExpr= new CPPASTFunctionCallExpression( beginExpr= new CPPASTFunctionCallExpression(
new CPPASTIdExpression(name), new CPPASTFieldReference(name, null), NO_ARGS);
new IASTInitializerClause[] { forInit.copy() }); } else {
beginExpr= new CPPASTFunctionCallExpression(new CPPASTIdExpression(name), NO_ARGS);
}
} else {
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
}
} }
autoInitClause= new CPPASTUnaryExpression(IASTUnaryExpression.op_star, beginExpr); autoInitClause= new CPPASTUnaryExpression(IASTUnaryExpression.op_star, beginExpr);
autoInitClause.setParent(forStmt); autoInitClause.setParent(forStmt);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -37,40 +37,52 @@ class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName {
fBinding= binding; fBinding= binding;
} }
@Override
public IBinding resolveBinding() { public IBinding resolveBinding() {
return fBinding; return fBinding;
} }
@Override
public IBinding resolvePreBinding() { public IBinding resolvePreBinding() {
return fBinding; return fBinding;
} }
@Override
public IBinding getBinding() { public IBinding getBinding() {
return fBinding; return fBinding;
} }
@Override
public IBinding getPreBinding() { public IBinding getPreBinding() {
return fBinding; return fBinding;
} }
@Override
public ILinkage getLinkage() { public ILinkage getLinkage() {
final IASTTranslationUnit tu= getTranslationUnit(); final IASTTranslationUnit tu= getTranslationUnit();
return tu == null ? Linkage.NO_LINKAGE : tu.getLinkage(); return tu == null ? Linkage.NO_LINKAGE : tu.getLinkage();
} }
@Override
public IASTCompletionContext getCompletionContext() { public IASTCompletionContext getCompletionContext() {
return null; return null;
} }
@Override
public boolean isDeclaration() { public boolean isDeclaration() {
return false; return false;
} }
@Override
public boolean isDefinition() { public boolean isDefinition() {
return false; return false;
} }
@Override
public boolean isReference() { public boolean isReference() {
return false; return false;
} }
@Override
public char[] toCharArray() { public char[] toCharArray() {
return fName; return fName;
} }
@Override
public char[] getSimpleID() { public char[] getSimpleID() {
return fName; return fName;
} }
@Override
public char[] getLookupKey() { public char[] getLookupKey() {
return fName; return fName;
} }
@ -79,15 +91,22 @@ class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName {
public String toString() { public String toString() {
return new String(fName); return new String(fName);
} }
@Override
public void setBinding(IBinding binding) {assert false;} public void setBinding(IBinding binding) {assert false;}
@Override
public int getRoleOfName(boolean allowResolution) { public int getRoleOfName(boolean allowResolution) {
return IASTNameOwner.r_unclear; return IASTNameOwner.r_unclear;
} }
@Override
public IASTName getLastName() { public IASTName getLastName() {
return this; return this;
} }
@Override @Override
public boolean isQualified() {
return false;
}
@Override
public IASTName copy() { public IASTName copy() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -51,144 +51,179 @@ public class PDOMASTAdapter {
public AnonymousASTName(IASTName name, final IASTFileLocation loc) { public AnonymousASTName(IASTName name, final IASTFileLocation loc) {
fDelegate= name; fDelegate= name;
fLocation= new IASTFileLocation() { fLocation= new IASTFileLocation() {
@Override
public int getEndingLineNumber() { public int getEndingLineNumber() {
return loc.getStartingLineNumber(); return loc.getStartingLineNumber();
} }
@Override
public String getFileName() { public String getFileName() {
return loc.getFileName(); return loc.getFileName();
} }
@Override
public int getStartingLineNumber() { public int getStartingLineNumber() {
return loc.getStartingLineNumber(); return loc.getStartingLineNumber();
} }
@Override
public IASTFileLocation asFileLocation() { public IASTFileLocation asFileLocation() {
return loc.asFileLocation(); return loc.asFileLocation();
} }
@Override
public int getNodeLength() { public int getNodeLength() {
return 0; return 0;
} }
@Override
public int getNodeOffset() { public int getNodeOffset() {
return loc.getNodeOffset(); return loc.getNodeOffset();
} }
@Override
public IASTPreprocessorIncludeStatement getContextInclusionStatement() { public IASTPreprocessorIncludeStatement getContextInclusionStatement() {
return loc.getContextInclusionStatement(); return loc.getContextInclusionStatement();
} }
}; };
} }
@Override
public boolean accept(ASTVisitor visitor) { public boolean accept(ASTVisitor visitor) {
return fDelegate.accept(visitor); return fDelegate.accept(visitor);
} }
@Override
public boolean contains(IASTNode node) { public boolean contains(IASTNode node) {
return fDelegate.contains(node); return fDelegate.contains(node);
} }
@Override
public IBinding getBinding() { public IBinding getBinding() {
return fDelegate.getBinding(); return fDelegate.getBinding();
} }
@Override
public IBinding getPreBinding() { public IBinding getPreBinding() {
return fDelegate.getPreBinding(); return fDelegate.getPreBinding();
} }
@Override
public String getContainingFilename() { public String getContainingFilename() {
return fLocation.getFileName(); return fLocation.getFileName();
} }
@Override
public IASTFileLocation getFileLocation() { public IASTFileLocation getFileLocation() {
return fLocation; return fLocation;
} }
@Override
public ILinkage getLinkage() { public ILinkage getLinkage() {
return fDelegate.getLinkage(); return fDelegate.getLinkage();
} }
@Override
public IASTNodeLocation[] getNodeLocations() { public IASTNodeLocation[] getNodeLocations() {
return fDelegate.getNodeLocations(); return fDelegate.getNodeLocations();
} }
@Override
public IASTNode getParent() { public IASTNode getParent() {
return fDelegate.getParent(); return fDelegate.getParent();
} }
@Override
public IASTNode[] getChildren() { public IASTNode[] getChildren() {
return fDelegate.getChildren(); return fDelegate.getChildren();
} }
@Override
public ASTNodeProperty getPropertyInParent() { public ASTNodeProperty getPropertyInParent() {
return fDelegate.getPropertyInParent(); return fDelegate.getPropertyInParent();
} }
@Override
public String getRawSignature() { public String getRawSignature() {
return fDelegate.getRawSignature(); return fDelegate.getRawSignature();
} }
@Override
public IASTTranslationUnit getTranslationUnit() { public IASTTranslationUnit getTranslationUnit() {
return fDelegate.getTranslationUnit(); return fDelegate.getTranslationUnit();
} }
@Override
public int getRoleOfName(boolean allowResolution) { public int getRoleOfName(boolean allowResolution) {
return fDelegate.getRoleOfName(allowResolution); return fDelegate.getRoleOfName(allowResolution);
} }
@Override
public boolean isDeclaration() { public boolean isDeclaration() {
return fDelegate.isDeclaration(); return fDelegate.isDeclaration();
} }
@Override
public boolean isDefinition() { public boolean isDefinition() {
return fDelegate.isDefinition(); return fDelegate.isDefinition();
} }
@Override
public boolean isReference() { public boolean isReference() {
return fDelegate.isReference(); return fDelegate.isReference();
} }
@Override
public IBinding resolveBinding() { public IBinding resolveBinding() {
return fDelegate.resolveBinding(); return fDelegate.resolveBinding();
} }
@Override
public IBinding resolvePreBinding() { public IBinding resolvePreBinding() {
return fDelegate.resolvePreBinding(); return fDelegate.resolvePreBinding();
} }
@Override
public IASTCompletionContext getCompletionContext() { public IASTCompletionContext getCompletionContext() {
return fDelegate.getCompletionContext(); return fDelegate.getCompletionContext();
} }
@Override
public void setBinding(IBinding binding) { public void setBinding(IBinding binding) {
fDelegate.setBinding(binding); fDelegate.setBinding(binding);
} }
@Override
public void setParent(IASTNode node) { public void setParent(IASTNode node) {
fDelegate.setParent(node); fDelegate.setParent(node);
} }
@Override
public void setPropertyInParent(ASTNodeProperty property) { public void setPropertyInParent(ASTNodeProperty property) {
fDelegate.setPropertyInParent(property); fDelegate.setPropertyInParent(property);
} }
@Override
public char[] toCharArray() { public char[] toCharArray() {
return fDelegate.toCharArray(); return fDelegate.toCharArray();
} }
@Override
public char[] getSimpleID() { public char[] getSimpleID() {
return fDelegate.getSimpleID(); return fDelegate.getSimpleID();
} }
@Override
public char[] getLookupKey() { public char[] getLookupKey() {
return fDelegate.getLookupKey(); return fDelegate.getLookupKey();
} }
@Override
public IASTImageLocation getImageLocation() { public IASTImageLocation getImageLocation() {
return null; return null;
} }
@Override
public boolean isPartOfTranslationUnitFile() { public boolean isPartOfTranslationUnitFile() {
return fLocation.getFileName().equals(fDelegate.getTranslationUnit().getFilePath()); return fLocation.getFileName().equals(fDelegate.getTranslationUnit().getFilePath());
} }
@ -198,40 +233,53 @@ public class PDOMASTAdapter {
return fDelegate.toString(); return fDelegate.toString();
} }
@Override
public IASTName getLastName() { public IASTName getLastName() {
return this; return this;
} }
@Override
public IToken getSyntax() throws ExpansionOverlapsBoundaryException, public IToken getSyntax() throws ExpansionOverlapsBoundaryException,
UnsupportedOperationException { UnsupportedOperationException {
return fDelegate.getSyntax(); return fDelegate.getSyntax();
} }
@Override
public IToken getLeadingSyntax() throws ExpansionOverlapsBoundaryException, public IToken getLeadingSyntax() throws ExpansionOverlapsBoundaryException,
UnsupportedOperationException { UnsupportedOperationException {
return fDelegate.getLeadingSyntax(); return fDelegate.getLeadingSyntax();
} }
@Override
public IToken getTrailingSyntax() throws ExpansionOverlapsBoundaryException, public IToken getTrailingSyntax() throws ExpansionOverlapsBoundaryException,
UnsupportedOperationException { UnsupportedOperationException {
return fDelegate.getTrailingSyntax(); return fDelegate.getTrailingSyntax();
} }
@Override
public boolean isFrozen() { public boolean isFrozen() {
return fDelegate.isFrozen(); return fDelegate.isFrozen();
} }
@Override
public boolean isActive() { public boolean isActive() {
return fDelegate.isFrozen(); return fDelegate.isFrozen();
} }
@Override
public IASTName copy() { public IASTName copy() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public IASTName copy(CopyStyle style) { public IASTName copy(CopyStyle style) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean isQualified() {
return fDelegate.isQualified();
}
} }
private static class AnonymousEnumeration implements IEnumeration { private static class AnonymousEnumeration implements IEnumeration {
@ -248,43 +296,53 @@ public class PDOMASTAdapter {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public Object getAdapter(Class adapter) { public Object getAdapter(Class adapter) {
return fDelegate.getAdapter(adapter); return fDelegate.getAdapter(adapter);
} }
@Override
public IEnumerator[] getEnumerators() throws DOMException { public IEnumerator[] getEnumerators() throws DOMException {
return fDelegate.getEnumerators(); return fDelegate.getEnumerators();
} }
@Override
public ILinkage getLinkage() { public ILinkage getLinkage() {
return fDelegate.getLinkage(); return fDelegate.getLinkage();
} }
@Override
public String getName() { public String getName() {
return new String(fName); return new String(fName);
} }
@Override
public char[] getNameCharArray() { public char[] getNameCharArray() {
return fName; return fName;
} }
@Override
public IScope getScope() throws DOMException { public IScope getScope() throws DOMException {
return fDelegate.getScope(); return fDelegate.getScope();
} }
@Override
public boolean isSameType(IType type) { public boolean isSameType(IType type) {
return fDelegate.isSameType(type); return fDelegate.isSameType(type);
} }
@Override
public IBinding getOwner() { public IBinding getOwner() {
return fDelegate.getOwner(); return fDelegate.getOwner();
} }
@Override
public long getMinValue() { public long getMinValue() {
return fDelegate.getMinValue(); return fDelegate.getMinValue();
} }
@Override
public long getMaxValue() { public long getMaxValue() {
return fDelegate.getMaxValue(); return fDelegate.getMaxValue();
} }
@ -304,51 +362,63 @@ public class PDOMASTAdapter {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public IField findField(String name) { public IField findField(String name) {
return fDelegate.findField(name); return fDelegate.findField(name);
} }
@Override
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public Object getAdapter(Class adapter) { public Object getAdapter(Class adapter) {
return fDelegate.getAdapter(adapter); return fDelegate.getAdapter(adapter);
} }
@Override
public IScope getCompositeScope() { public IScope getCompositeScope() {
return fDelegate.getCompositeScope(); return fDelegate.getCompositeScope();
} }
@Override
public IField[] getFields() { public IField[] getFields() {
return fDelegate.getFields(); return fDelegate.getFields();
} }
@Override
public int getKey() { public int getKey() {
return fDelegate.getKey(); return fDelegate.getKey();
} }
@Override
public ILinkage getLinkage() { public ILinkage getLinkage() {
return fDelegate.getLinkage(); return fDelegate.getLinkage();
} }
@Override
public String getName() { public String getName() {
return new String(fName); return new String(fName);
} }
@Override
public char[] getNameCharArray() { public char[] getNameCharArray() {
return fName; return fName;
} }
@Override
public IScope getScope() throws DOMException { public IScope getScope() throws DOMException {
return fDelegate.getScope(); return fDelegate.getScope();
} }
@Override
public boolean isSameType(IType type) { public boolean isSameType(IType type) {
return fDelegate.isSameType(type); return fDelegate.isSameType(type);
} }
@Override
public IBinding getOwner() { public IBinding getOwner() {
return fDelegate.getOwner(); return fDelegate.getOwner();
} }
@Override
public boolean isAnonymous() { public boolean isAnonymous() {
return fDelegate.isAnonymous(); return fDelegate.isAnonymous();
} }
@ -368,14 +438,17 @@ public class PDOMASTAdapter {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public String getName() { public String getName() {
return new String(fName); return new String(fName);
} }
@Override
public char[] getNameCharArray() { public char[] getNameCharArray() {
return fName; return fName;
} }
@Override
public String[] getQualifiedName() throws DOMException { public String[] getQualifiedName() throws DOMException {
String[] qn= fDelegate.getQualifiedName(); String[] qn= fDelegate.getQualifiedName();
if (qn.length < 1) { if (qn.length < 1) {
@ -385,6 +458,7 @@ public class PDOMASTAdapter {
return qn; return qn;
} }
@Override
public char[][] getQualifiedNameCharArray() throws DOMException { public char[][] getQualifiedNameCharArray() throws DOMException {
char[][] qn= fDelegate.getQualifiedNameCharArray(); char[][] qn= fDelegate.getQualifiedNameCharArray();
if (qn.length < 1) { if (qn.length < 1) {
@ -394,23 +468,28 @@ public class PDOMASTAdapter {
return qn; return qn;
} }
@Override
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public Object getAdapter(Class adapter) { public Object getAdapter(Class adapter) {
return fDelegate.getAdapter(adapter); return fDelegate.getAdapter(adapter);
} }
@Override
public ILinkage getLinkage() { public ILinkage getLinkage() {
return fDelegate.getLinkage(); return fDelegate.getLinkage();
} }
@Override
public IScope getScope() throws DOMException { public IScope getScope() throws DOMException {
return fDelegate.getScope(); return fDelegate.getScope();
} }
@Override
public boolean isGloballyQualified() throws DOMException { public boolean isGloballyQualified() throws DOMException {
return fDelegate.isGloballyQualified(); return fDelegate.isGloballyQualified();
} }
@Override
public IBinding getOwner() { public IBinding getOwner() {
return fDelegate.getOwner(); return fDelegate.getOwner();
} }
@ -421,30 +500,37 @@ public class PDOMASTAdapter {
super(name, (ICPPBinding) delegate); super(name, (ICPPBinding) delegate);
} }
@Override
public IEnumerator[] getEnumerators() throws DOMException { public IEnumerator[] getEnumerators() throws DOMException {
return ((IEnumeration) fDelegate).getEnumerators(); return ((IEnumeration) fDelegate).getEnumerators();
} }
@Override
public boolean isSameType(IType type) { public boolean isSameType(IType type) {
return ((IEnumeration) fDelegate).isSameType(type); return ((IEnumeration) fDelegate).isSameType(type);
} }
@Override
public long getMinValue() { public long getMinValue() {
return ((IEnumeration)fDelegate).getMinValue(); return ((IEnumeration)fDelegate).getMinValue();
} }
@Override
public long getMaxValue() { public long getMaxValue() {
return ((IEnumeration)fDelegate).getMaxValue(); return ((IEnumeration)fDelegate).getMaxValue();
} }
@Override
public boolean isScoped() { public boolean isScoped() {
return ((ICPPEnumeration)fDelegate).isScoped(); return ((ICPPEnumeration)fDelegate).isScoped();
} }
@Override
public IType getFixedType() { public IType getFixedType() {
return ((ICPPEnumeration)fDelegate).getFixedType(); return ((ICPPEnumeration)fDelegate).getFixedType();
} }
@Override
public ICPPScope asScope() { public ICPPScope asScope() {
return ((ICPPEnumeration)fDelegate).asScope(); return ((ICPPEnumeration)fDelegate).asScope();
} }
@ -455,58 +541,72 @@ public class PDOMASTAdapter {
super(name, delegate); super(name, delegate);
} }
@Override
public IField findField(String name) { public IField findField(String name) {
return ((ICPPClassType) fDelegate).findField(name); return ((ICPPClassType) fDelegate).findField(name);
} }
@Override
public ICPPMethod[] getAllDeclaredMethods() { public ICPPMethod[] getAllDeclaredMethods() {
return ((ICPPClassType) fDelegate).getAllDeclaredMethods(); return ((ICPPClassType) fDelegate).getAllDeclaredMethods();
} }
@Override
public ICPPBase[] getBases() { public ICPPBase[] getBases() {
return ((ICPPClassType) fDelegate).getBases(); return ((ICPPClassType) fDelegate).getBases();
} }
@Override
public IScope getCompositeScope() { public IScope getCompositeScope() {
return ((ICPPClassType) fDelegate).getCompositeScope(); return ((ICPPClassType) fDelegate).getCompositeScope();
} }
@Override
public ICPPConstructor[] getConstructors() { public ICPPConstructor[] getConstructors() {
return ((ICPPClassType) fDelegate).getConstructors(); return ((ICPPClassType) fDelegate).getConstructors();
} }
@Override
public ICPPField[] getDeclaredFields() { public ICPPField[] getDeclaredFields() {
return ((ICPPClassType) fDelegate).getDeclaredFields(); return ((ICPPClassType) fDelegate).getDeclaredFields();
} }
@Override
public ICPPMethod[] getDeclaredMethods() { public ICPPMethod[] getDeclaredMethods() {
return ((ICPPClassType) fDelegate).getDeclaredMethods(); return ((ICPPClassType) fDelegate).getDeclaredMethods();
} }
@Override
public IField[] getFields() { public IField[] getFields() {
return ((ICPPClassType) fDelegate).getFields(); return ((ICPPClassType) fDelegate).getFields();
} }
@Override
public IBinding[] getFriends() { public IBinding[] getFriends() {
return ((ICPPClassType) fDelegate).getFriends(); return ((ICPPClassType) fDelegate).getFriends();
} }
@Override
public int getKey() { public int getKey() {
return ((ICPPClassType) fDelegate).getKey(); return ((ICPPClassType) fDelegate).getKey();
} }
@Override
public ICPPMethod[] getMethods() { public ICPPMethod[] getMethods() {
return ((ICPPClassType) fDelegate).getMethods(); return ((ICPPClassType) fDelegate).getMethods();
} }
@Override
public ICPPClassType[] getNestedClasses() { public ICPPClassType[] getNestedClasses() {
return ((ICPPClassType) fDelegate).getNestedClasses(); return ((ICPPClassType) fDelegate).getNestedClasses();
} }
@Override
public boolean isSameType(IType type) { public boolean isSameType(IType type) {
return ((ICPPClassType) fDelegate).isSameType(type); return ((ICPPClassType) fDelegate).isSameType(type);
} }
@Override
public boolean isAnonymous() { public boolean isAnonymous() {
return ((ICPPClassType) fDelegate).isAnonymous(); return ((ICPPClassType) fDelegate).isAnonymous();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2011 Wind River Systems, Inc. and others. * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
* Freescale Semiconductor - refactoring * Freescale Semiconductor - refactoring
* Patrick Chuong (Texas Instruments) - Bug 329682 * Patrick Chuong (Texas Instruments) - Bug 329682
* Patrick Chuong (Texas Instruments) - Bug 353351 * Patrick Chuong (Texas Instruments) - Bug 353351
* Patrick Chuong (Texas Instruments) - Bug 364405
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.disassembly.dsf; package org.eclipse.cdt.debug.internal.ui.disassembly.dsf;
@ -17,6 +18,7 @@ import java.math.BigInteger;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.source.IAnnotationModel;
public abstract class AbstractDisassemblyBackend implements IDisassemblyBackend { public abstract class AbstractDisassemblyBackend implements IDisassemblyBackend {
@ -63,4 +65,10 @@ public abstract class AbstractDisassemblyBackend implements IDisassemblyBackend
} }
}); });
} }
/**
* Do nothing, sub-class can override to update PC annotation.
*/
public void updateExtendedPCAnnotation(IAnnotationModel model) {
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2011 Wind River Systems, Inc. and others. * Copyright (c) 2010, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Wind River Systems - initial API and implementation * Wind River Systems - initial API and implementation
* Freescale Semiconductor - refactoring * Freescale Semiconductor - refactoring
* Patrick Chuong (Texas Instruments) - Bug 364405
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.disassembly.dsf; package org.eclipse.cdt.debug.internal.ui.disassembly.dsf;
@ -15,6 +16,7 @@ import java.math.BigInteger;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.IAnnotationModel;
/** /**
* This is the main interface that connects the DSF Disassembly view to CDI and * This is the main interface that connects the DSF Disassembly view to CDI and
@ -191,4 +193,9 @@ public interface IDisassemblyBackend {
* Called when the Disassembly view has no further use for this backend. * Called when the Disassembly view has no further use for this backend.
*/ */
void dispose(); void dispose();
/**
* Update the extended PC annotation.
*/
void updateExtendedPCAnnotation(IAnnotationModel model);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2011 Wind River Systems, Inc. and others. * Copyright (c) 2010, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Wind River Systems - initial API and implementation * Wind River Systems - initial API and implementation
* Freescale Semiconductor - refactoring * Freescale Semiconductor - refactoring
* Patrick Chuong (Texas Instruments) - Bug 364405
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.disassembly.dsf; package org.eclipse.cdt.debug.internal.ui.disassembly.dsf;
@ -35,4 +36,8 @@ public interface IDisassemblyDocument {
BigInteger address, int length, String functionOffset, BigInteger opcode, BigInteger address, int length, String functionOffset, BigInteger opcode,
String instruction, String compilationPath, int lineNumber) String instruction, String compilationPath, int lineNumber)
throws BadLocationException; throws BadLocationException;
AddressRangePosition getDisassemblyPosition(BigInteger address);
BigInteger getAddressOfLine(int line);
int getNumberOfLines();
} }

View file

@ -10,30 +10,31 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service.command; package org.eclipse.cdt.dsf.gdb.service.command;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
/** /**
* With GDB 7.4, the command 'maintenance set python print-stack' is not supported. * With GDB 7.4, the command 'maintenance set python print-stack' is not supported.
* The new command "set python print-stack none|full|message" has replaced it, with * The new command "set python print-stack none|full|message" has replaced it.
* the default being 'message'. With this new default
* @since 4.1 * @since 4.1
*/ */
public class GDBControl_7_4 extends GDBControl_7_2 implements IGDBControl { public class GDBControl_7_4 extends GDBControl_7_2 implements IGDBControl {
public GDBControl_7_4(DsfSession session, ILaunchConfiguration config, CommandFactory factory) { public GDBControl_7_4(DsfSession session, ILaunchConfiguration config, CommandFactory factory) {
super(session, config, factory); super(session, config, factory);
setUseThreadGroupOptions(true);
} }
@Override @Override
public void setPrintPythonErrors(boolean enabled, RequestMonitor rm) { public void setPrintPythonErrors(boolean enabled, RequestMonitor rm) {
// With GDB 7.4, the command 'maintenance set python print-stack' is not supported. // With GDB 7.4, the command 'maintenance set python print-stack' has been replaced by
// The new command "set python print-stack none|full|message" has replaced it, with // the new command "set python print-stack none|full|message".
// the default being 'message'. This new default is good enough for us, so no
// need to do anything anymore.
// Bug 367788 // Bug 367788
rm.done(); String errorOption = enabled ? "full" : "none"; //$NON-NLS-1$ //$NON-NLS-2$
queueCommand(
getCommandFactory().createMIGDBSetPythonPrintStack(getContext(), errorOption),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2011 QNX Software Systems and others. * Copyright (c) 2000, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -15,6 +15,7 @@
* Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306) * Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
* Abeer Bagul - Support for -exec-arguments (bug 337687) * Abeer Bagul - Support for -exec-arguments (bug 337687)
* Marc Khouzam (Ericsson) - New methods for new MIDataDisassemble (Bug 357073) * Marc Khouzam (Ericsson) - New methods for new MIDataDisassemble (Bug 357073)
* Marc Khouzam (Ericsson) - New method for new MIGDBSetPythonPrintStack (Bug 367788)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command; package org.eclipse.cdt.dsf.mi.service.command;
@ -101,6 +102,7 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetDetachOnFork;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetEnv; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetEnv;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetNonStop; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetNonStop;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetPagination; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetPagination;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetPythonPrintStack;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetSchedulerLocking; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetSchedulerLocking;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetSolibAbsolutePrefix; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetSolibAbsolutePrefix;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetSolibSearchPath; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetSolibSearchPath;
@ -631,6 +633,11 @@ public class CommandFactory {
return new MIGDBSetPagination(ctx, isSet); return new MIGDBSetPagination(ctx, isSet);
} }
/** @since 4.1 */
public ICommand<MIInfo> createMIGDBSetPythonPrintStack(ICommandControlDMContext ctx, String option) {
return new MIGDBSetPythonPrintStack(ctx, option);
}
/** @since 4.1 */ /** @since 4.1 */
public ICommand<MIInfo> createMIGDBSetSchedulerLocking(ICommandControlDMContext ctx, String mode) { public ICommand<MIInfo> createMIGDBSetSchedulerLocking(ICommandControlDMContext ctx, String mode) {
return new MIGDBSetSchedulerLocking(ctx, mode); return new MIGDBSetSchedulerLocking(ctx, mode);

View file

@ -0,0 +1,34 @@
/*******************************************************************************
* 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.command.commands;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
/**
*
* -gdb-set python print-stack [ none | message | full ]
*
* By default, gdb will print only the message component of a Python exception when an error occurs
* in a Python script. This can be controlled using set python print-stack: if full, then full Python
* stack printing is enabled; if none, then Python stack and message printing is disabled; if message,
* the default, only the message component of the error is printed.
*
* Available with GDB 7.4
*
* @since 4.1
*
*/
public class MIGDBSetPythonPrintStack extends MIGDBSet
{
public MIGDBSetPythonPrintStack(ICommandControlDMContext ctx, String option) {
super(ctx, new String[] {"python", "print-stack", option}); //$NON-NLS-1$//$NON-NLS-2$
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2011 Wind River Systems and others. * Copyright (c) 2007, 2012 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,10 +7,11 @@
* *
* Contributors: * Contributors:
* Wind River Systems - initial API and implementation * Wind River Systems - initial API and implementation
* Patrick Chuong (Texas Instruments) - Bug fix (326670) * Patrick Chuong (Texas Instruments) - Bug 326670
* Patrick Chuong (Texas Instruments) - Bug fix (329682) * Patrick Chuong (Texas Instruments) - Bug 329682
* Patrick Chuong (Texas Instruments) - bug fix (330259) * Patrick Chuong (Texas Instruments) - bug 330259
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781) * Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
* Patrick Chuong (Texas Instruments) - Bug 364405
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
@ -56,6 +57,7 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocume
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.SourceFileInfo; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.SourceFileInfo;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.presentation.DisassemblyIPAnnotation; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.presentation.DisassemblyIPAnnotation;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyAnnotationModel;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyViewer; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyViewer;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
@ -197,6 +199,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
*/ */
private final static String BREAKPOINT_ANNOTATIONS= "breakpoints"; //$NON-NLS-1$ private final static String BREAKPOINT_ANNOTATIONS= "breakpoints"; //$NON-NLS-1$
/**
* Annotation model attachment key for extended PC annotations.
*/
private final static String EXTENDED_PC_ANNOTATIONS = "ExtendedPCAnnotations"; //$NON-NLS-1$
private final static BigInteger PC_UNKNOWN = BigInteger.valueOf(-1); private final static BigInteger PC_UNKNOWN = BigInteger.valueOf(-1);
private final static BigInteger PC_RUNNING = BigInteger.valueOf(-2); private final static BigInteger PC_RUNNING = BigInteger.valueOf(-2);
@ -354,6 +361,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private Action fJumpToAddressAction = new JumpToAddressAction(this); private Action fJumpToAddressAction = new JumpToAddressAction(this);
private IDebugContextListener fDebugContextListener; private IDebugContextListener fDebugContextListener;
private DisassemblyAnnotationModel fExtPCAnnotationModel;
private IColumnSupport fColumnSupport; private IColumnSupport fColumnSupport;
@ -1849,7 +1857,10 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fDebugSessionId = null; fDebugSessionId = null;
boolean needUpdate = false; boolean needUpdate = false;
if (context != null) { if (context != null) {
if (prevBackend != null && prevBackend.supportsDebugContext(context)) { IDisassemblyBackend contextBackend = (IDisassemblyBackend)context.getAdapter(IDisassemblyBackend.class);
// Need to compare the backend classes to prevent reusing the same backend object.
// sub class can overwrite the standard disassembly backend to provide its own customization.
if ((prevBackend != null) && (contextBackend != null) && prevBackend.getClass().equals(contextBackend.getClass()) && prevBackend.supportsDebugContext(context)) {
newBackend = prevBackend; newBackend = prevBackend;
} else { } else {
needUpdate = true; needUpdate = true;
@ -1957,6 +1968,15 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
firePropertyChange(PROP_SUSPENDED); firePropertyChange(PROP_SUSPENDED);
} }
private void attachExtendedPCAnnotationModel() {
IAnnotationModel annotationModel = fViewer.getAnnotationModel();
if (annotationModel instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ame= (IAnnotationModelExtension) annotationModel;
fExtPCAnnotationModel = new DisassemblyAnnotationModel();
ame.addAnnotationModel(EXTENDED_PC_ANNOTATIONS, fExtPCAnnotationModel);
}
}
private void attachBreakpointsAnnotationModel() { private void attachBreakpointsAnnotationModel() {
IAnnotationModel annotationModel = fViewer.getAnnotationModel(); IAnnotationModel annotationModel = fViewer.getAnnotationModel();
if (annotationModel instanceof IAnnotationModelExtension) { if (annotationModel instanceof IAnnotationModelExtension) {
@ -2030,6 +2050,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private void resetViewer() { private void resetViewer() {
// clear all state and cache // clear all state and cache
fExtPCAnnotationModel = null;
fPCAnnotationUpdatePending = false; fPCAnnotationUpdatePending = false;
fGotoFramePending = false; fGotoFramePending = false;
fPCAddress = fFrameAddress = PC_RUNNING; fPCAddress = fFrameAddress = PC_RUNNING;
@ -2044,6 +2065,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fViewer.setDocument(fDocument, new AnnotationModel()); fViewer.setDocument(fDocument, new AnnotationModel());
if (fDebugSessionId != null) { if (fDebugSessionId != null) {
attachBreakpointsAnnotationModel(); attachBreakpointsAnnotationModel();
attachExtendedPCAnnotationModel();
fDocument.insertInvalidAddressRange(0, 0, fStartAddress, fEndAddress); fDocument.insertInvalidAddressRange(0, 0, fStartAddress, fEndAddress);
} }
} }
@ -2457,6 +2479,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
pos = updateAddressAnnotation(fSecondaryPCAnnotation, fFrameAddress); pos = updateAddressAnnotation(fSecondaryPCAnnotation, fFrameAddress);
} }
fPCAnnotationUpdatePending = pos == null && fFrameAddress.compareTo(BigInteger.ZERO) >= 0; fPCAnnotationUpdatePending = pos == null && fFrameAddress.compareTo(BigInteger.ZERO) >= 0;
if (fExtPCAnnotationModel != null) {
fBackend.updateExtendedPCAnnotation(fExtPCAnnotationModel);
}
return pos; return pos;
} }

View file

@ -1 +1,5 @@
bin.includes = feature.xml bin.includes = feature.xml,\
eclipse_update_120.jpg,\
epl-v10.html,\
feature.properties,\
license.html

View file

@ -19,3 +19,4 @@ bin.includes = META-INF/,\
plugin.properties,\ plugin.properties,\
about.properties,\ about.properties,\
cdt_logo_icon32.png cdt_logo_icon32.png
src.includes = about.html

View file

@ -1 +1,5 @@
bin.includes = feature.xml bin.includes = feature.xml,\
eclipse_update_120.jpg,\
epl-v10.html,\
feature.properties,\
license.html