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

Added tracing to CompositeValue.create.

Change-Id: I46b076c2d2fd1b4b0cb490fd3de2ff55e5ec66d7
This commit is contained in:
Sergey Prigogin 2017-02-27 20:29:09 -08:00
parent 68a8cf3205
commit b868b50c37
6 changed files with 38 additions and 13 deletions

View file

@ -9,6 +9,9 @@ org.eclipse.cdt.core/debug/parser=false
# Prints parser stack traces
org.eclipse.cdt.core/debug/parser/exceptions=false
# Diagnostic tracing in CompositeValue class
org.eclipse.cdt.core/debug/parser/CompositeValue=false
# Reports statistics for building the structure to do resource lookups.
org.eclipse.cdt.core/debug/resourceLookup=false
@ -33,8 +36,8 @@ org.eclipse.cdt.core/debug/typeresolver=false
# Reports issues with locking the index
org.eclipse.cdt.core/debug/index/locks=false
# Reports unusually slow IndexFileSet operations
org.eclipse.cdt.core/debug/index/indexfileset=false
# Diagnostic logging in the IndexFileSet class
org.eclipse.cdt.core/debug/index/IndexFileSet=false
# Reports events related to setting up the indexer for a project
org.eclipse.cdt.core/debug/indexer/setup=false

View file

@ -69,6 +69,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
import org.eclipse.cdt.internal.core.dom.parser.CompositeValue;
import org.eclipse.cdt.internal.core.index.IndexBasedFileContentProvider;
import org.eclipse.cdt.internal.core.parser.InternalParserUtil;
import org.eclipse.cdt.internal.core.parser.ParserLogService;
@ -90,6 +91,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.osgi.util.NLS;
@ -97,7 +99,12 @@ import org.eclipse.osgi.util.NLS;
* @see ITranslationUnit
*/
public class TranslationUnit extends Openable implements ITranslationUnit {
private URI location = null;
static {
CompositeValue.sDEBUG=
Boolean.parseBoolean(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/parser/CompositeValue")); //$NON-NLS-1$
}
private URI location;
private String contentTypeId;
/**
@ -106,7 +113,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
*/
protected IProblemRequestor problemRequestor;
SourceManipulationInfo sourceManipulationInfo = null;
SourceManipulationInfo sourceManipulationInfo;
private ILanguage fLanguageOfContext;
public TranslationUnit(ICElement parent, IFile file, String idType) {

View file

@ -461,7 +461,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
}
});
if (IndexFileSet.sDEBUG_INDEX_FILE_SET && fIndexFileSet != null && fASTFileSet != null) {
if (IndexFileSet.sDEBUG && fIndexFileSet != null && fASTFileSet != null) {
long t = ((IndexFileSet) fIndexFileSet).getTimingContainsDeclarationNanos() +
((IndexFileSet) fASTFileSet).getTimingContainsDeclarationNanos();
String forName = fOriginatingTranslationUnit == null ?

View file

@ -12,6 +12,7 @@ import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -33,6 +34,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
public final class CompositeValue implements IValue {
public static boolean sDEBUG; // Initialized in the TranslationUnit.
private final ICPPEvaluation evaluation;
private final ICPPEvaluation[] values;
@ -169,10 +172,22 @@ public final class CompositeValue implements IValue {
* when determining the values of the fields.
*/
public static CompositeValue create(ICPPClassType classType, IASTNode point) {
return create(classType, point, 0);
}
/**
* Creates a value representing an instance of a class type, with the values of the fields
* determined by the default member initializers only. Constructors are not considered
* when determining the values of the fields.
*/
public static CompositeValue create(ICPPClassType classType, IASTNode point, int nestingLevel) {
Set<ICPPClassType> recursionProtectionSet = fCreateInProgress.get();
if (!recursionProtectionSet.add(classType)) {
return new CompositeValue(null, ICPPEvaluation.EMPTY_ARRAY);
}
if (sDEBUG && nestingLevel > 0) {
System.out.println("CompositeValue.create(" + ASTTypeUtil.getType(classType) + ", " + nestingLevel + ")"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
try {
ActivationRecord record = new ActivationRecord();
ICPPEvaluation[] values = new ICPPEvaluation[ClassTypeHelper.getFields(classType, point).length];
@ -184,7 +199,7 @@ public final class CompositeValue implements IValue {
if (baseClass instanceof ICPPClassType) {
ICPPClassType baseClassType = (ICPPClassType) baseClass;
ICPPField[] baseFields = ClassTypeHelper.getDeclaredFields(baseClassType, point);
IValue compValue = CompositeValue.create(baseClassType, point);
IValue compValue = CompositeValue.create(baseClassType, point, nestingLevel + 1);
for (ICPPField baseField : baseFields) {
int fieldPos = CPPASTFieldReference.getFieldPosition(baseField);
if (fieldPos == -1) {

View file

@ -34,7 +34,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
public class IndexFileSet implements IIndexFileSet {
public static boolean sDEBUG_INDEX_FILE_SET; // Initialized in the PDOMManager.
public static boolean sDEBUG; // Initialized in the PDOMManager.
private IIndexFileSet fInverse;
private final HashMap<IIndexFragment, IIndexFragmentFileSet> fSubSets= new HashMap<>();
@ -74,10 +74,10 @@ public class IndexFileSet implements IIndexFileSet {
if (cachedValue != null)
return cachedValue;
long startTime = sDEBUG_INDEX_FILE_SET ? System.nanoTime() : 0;
long startTime = sDEBUG ? System.nanoTime() : 0;
boolean contains = computeContainsDeclaration(binding);
fDeclarationContainmentCache.put(binding, contains);
if (sDEBUG_INDEX_FILE_SET) {
if (sDEBUG) {
timingContainsDeclarationNanos += System.nanoTime() - startTime;
}
return contains;
@ -104,7 +104,7 @@ public class IndexFileSet implements IIndexFileSet {
}
long fileRecord = PDOMName.getFileRecord(db, nameRecord);
if (pdomFileSet.containsFile(fileRecord)) {
if (sDEBUG_INDEX_FILE_SET && iterationCount >= 200) {
if (sDEBUG && iterationCount >= 200) {
System.out.println(
String.format("IndexFileSet: %s (%s) found after %d iterations", //$NON-NLS-1$
String.join("::", binding.getQualifiedName()), //$NON-NLS-1$
@ -125,7 +125,7 @@ public class IndexFileSet implements IIndexFileSet {
CCorePlugin.log(e);
}
}
if (sDEBUG_INDEX_FILE_SET && iterationCount >= 200) {
if (sDEBUG && iterationCount >= 200) {
System.out.println(
String.format("IndexFileSet: %s (%s) not found after %d iterations", //$NON-NLS-1$
String.join("::", binding.getQualifiedName()), //$NON-NLS-1$

View file

@ -199,8 +199,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
public PDOMManager() {
PDOM.sDEBUG_LOCKS= Boolean.parseBoolean(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/index/locks")); //$NON-NLS-1$
IndexFileSet.sDEBUG_INDEX_FILE_SET=
Boolean.parseBoolean(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/index/indexfileset")); //$NON-NLS-1$
IndexFileSet.sDEBUG=
Boolean.parseBoolean(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/index/IndexFileSet")); //$NON-NLS-1$
addIndexerSetupParticipant(new WaitForRefreshJobs());
fProjectDescriptionListener= new CProjectDescriptionListener(this);
fJobChangeListener= new JobChangeListener(this);