From b868b50c37b98b2346f8cee7e0b1a288c4efbfa4 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 27 Feb 2017 20:29:09 -0800 Subject: [PATCH] Added tracing to CompositeValue.create. Change-Id: I46b076c2d2fd1b4b0cb490fd3de2ff55e5ec66d7 --- core/org.eclipse.cdt.core/.options | 7 +++++-- .../internal/core/model/TranslationUnit.java | 11 +++++++++-- .../core/dom/parser/ASTTranslationUnit.java | 2 +- .../core/dom/parser/CompositeValue.java | 17 ++++++++++++++++- .../cdt/internal/core/index/IndexFileSet.java | 10 +++++----- .../cdt/internal/core/pdom/PDOMManager.java | 4 ++-- 6 files changed, 38 insertions(+), 13 deletions(-) diff --git a/core/org.eclipse.cdt.core/.options b/core/org.eclipse.cdt.core/.options index 150f80e521c..7eb461fdc67 100644 --- a/core/org.eclipse.cdt.core/.options +++ b/core/org.eclipse.cdt.core/.options @@ -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 diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java index 43418911ebd..eb2d172f4bc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java @@ -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) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java index 9859d4dc144..981af093877 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java @@ -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 ? diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java index 40f4ff7a2f2..9524927ec57 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java @@ -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 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) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java index 151d95e9bc9..0c85b49204b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java @@ -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 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$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java index 056607eb636..77ef13a9d92 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java @@ -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);