Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Head Branch: Indexer patch



Same patch as before, this one updated for the Head branch.


In this patch:


- Improved error handling for Indexer
- Improved error handling for MatchLocator

- Bounds checking for mappings in IncudeEntry

- Improved error handling for Merge operations

- Source file name fitering for recreating an already existing index


Test Suite run on Windows.


- Bogdan


Index: index/ChangeLog
===================================================================
retrieving revision 1.29
diff -u -r1.29 ChangeLog
--- index/ChangeLog	10 Feb 2004 18:17:42 -0000	1.29
+++ index/ChangeLog	13 Feb 2004 20:02:00 -0000
@@ -1,17 +1,28 @@
-2004-02-09 Bogdan Gheorghe
+2004-02-13 Bogdan Gheorghe
 	PR 51232
+
+	- Added mapping range checking to IncludeEntry to avoid out of bounds exceptions
+	- Added error handling to MergeFactory to handle problems during the save operation
+	- Added source file name filtering for the recreate an already existing index scenario in
+	  IndexAllProject. 
+	- Added more robust error handling to SourceIndexer
+	- Added error handling routine to Util.getFileCharContent() to deal with potential out of 
+	  memory crash
+	
+	* index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java
+	* index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java
+	* index/org/eclipse/cdt/internal/core/index/search/Util.java
+	* index/org/eclipse/cdt/internal/core/index/search/indexing/IndexAllProject.java
+	* index/org/eclipse/cdt/internal/core/index/search/indexing/SourceIndexer.java
+	* index/org/eclipse/cdt/internal/core/index/search/indexing/AddFolderToIndex.java
+	
+2004-02-10 Bogdan Gheorghe
 	
-	- Added a layer of separation between the parser and the indexer: we now
-	  create a worker thread to run the parser in. This allows the indexer to 
-	  finish all scheduled jobs regardless of how the parser performs on
-	  individual files (i.e. indexing no longer affected by parser failures)
-	  
 	- Modified some of the stored index block reading routines to use separate
 	  counters, thus avoiding potential EOF exceptions.
 	  
     * index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java
-	* index/org/eclipse/cdt/internal/core/index/search/indexing/SourceIndexer.java
-	
+    
 2004-02-03 Alain Magloire
 
 	PR 51106                                                                                                                   
Index: index/org/eclipse/cdt/internal/core/Util.java
===================================================================
retrieving revision 1.3
diff -u -r1.3 Util.java
--- index/org/eclipse/cdt/internal/core/Util.java	27 Oct 2003 20:57:43 -0000	1.3
+++ index/org/eclipse/cdt/internal/core/Util.java	13 Feb 2004 20:02:00 -0000
@@ -148,7 +148,11 @@
 		try {
 			stream = new BufferedInputStream(new FileInputStream(file));
 			return Util.getInputStreamAsCharArray(stream, (int) file.length(), encoding);
-		} finally {
+		}
+		catch (OutOfMemoryError er){
+			return null;
+		}
+		 finally {
 			if (stream != null) {
 				try {
 					stream.close();
Index: index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java
===================================================================
retrieving revision 1.1
diff -u -r1.1 IncludeEntry.java
--- index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java	26 Sep 2003 17:53:31 -0000	1.1
+++ index/org/eclipse/cdt/internal/core/index/impl/IncludeEntry.java	13 Feb 2004 20:02:00 -0000
@@ -157,8 +157,12 @@
 	 */
 	public void mapRefs(int[] mappings) {
 		int position= 0;
+
 		for (int i= 0; i < fNumRefs; i++) {
-			int map= mappings[fRefs[i]];
+			//Take care that the reference is actually within the bounds of the mapping
+			int map= -1;
+			if(fRefs[i] >= 0 && fRefs[i] < mappings.length) 
+				map= mappings[fRefs[i]];
 			if (map != -1 && map != 0)
 				fRefs[position++]= map;
 		}
Index: index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java
===================================================================
retrieving revision 1.3
diff -u -r1.3 MergeFactory.java
--- index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java	26 Sep 2003 17:53:31 -0000	1.3
+++ index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java	13 Feb 2004 20:02:01 -0000
@@ -13,6 +13,9 @@
 import java.io.IOException;
 import java.util.Map;
 
+import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
+import org.eclipse.cdt.internal.core.search.processing.JobManager;
+
 /**
  * A mergeFactory is used to merge 2 indexes into one. One of the indexes 
  * (oldIndex) is on the disk and the other(addsIndex) is in memory.
@@ -81,7 +84,24 @@
 			mergeReferences();
 			mergeIncludes();
 			mergeOutput.flush();
-		} finally {
+		} 
+		catch ( Exception ex ){
+			if (ex instanceof IOException)
+			  throw (IOException) ex;
+			else {
+			  if (IndexManager.VERBOSE) {
+				   JobManager.verbose("-> got the following exception during merge:"); //$NON-NLS-1$
+				   ex.printStackTrace();
+			  }
+			}
+		}
+		catch ( VirtualMachineError er ) {
+			if (IndexManager.VERBOSE) {
+			  JobManager.verbose("-> got the following exception during merge:"); //$NON-NLS-1$
+			  er.printStackTrace();
+			} 
+		}
+		finally {
 			//closes everything
 			oldInput.close();
 			addsInput.close();
Index: index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java
===================================================================
retrieving revision 1.5
diff -u -r1.5 AddFolderToIndex.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java	9 Sep 2003 17:53:51 -0000	1.5
+++ index/org/eclipse/cdt/internal/core/search/indexing/AddFolderToIndex.java	13 Feb 2004 20:02:01 -0000
@@ -58,13 +58,12 @@
 					public boolean visit(IResourceProxy proxy) throws CoreException {
 						switch(proxy.getType()) {
 							case IResource.FILE :
-//							TODO: BOG Put the file name checking back
-								//if (Util.isJavaFileName(proxy.getName())) {
+								if (Util.isCCFileName(proxy.getName())) {
 									IResource resource = proxy.requestResource();
 									if (pattern == null || !Util.isExcluded(resource, pattern))
 										indexManager.addSource((IFile)resource, container);
-								//}
-								//return false;
+								}
+								return false;
 							case IResource.FOLDER :
 								if (pattern != null && Util.isExcluded(proxy.requestResource(), pattern))
 									return false;
Index: index/org/eclipse/cdt/internal/core/search/indexing/IndexAllProject.java
===================================================================
retrieving revision 1.7
diff -u -r1.7 IndexAllProject.java
--- index/org/eclipse/cdt/internal/core/search/indexing/IndexAllProject.java	27 Oct 2003 20:57:43 -0000	1.7
+++ index/org/eclipse/cdt/internal/core/search/indexing/IndexAllProject.java	13 Feb 2004 20:02:01 -0000
@@ -124,9 +124,8 @@
 									public boolean visit(IResourceProxy proxy) {
 										if (isCancelled) return false;
 										switch(proxy.getType()) {
-											case IResource.FILE :
-//											TODO: BOG Put the file name checking back
-												//if (Util.isCCFileName(proxy.getName())) {
+											case IResource.FILE :					
+												if (Util.isCCFileName(proxy.getName())) {
 													IResource resource = proxy.requestResource();
 													IPath path = resource.getLocation();
 													if (path != null && (patterns == null || !Util.isExcluded(resource, patterns))) {
@@ -136,8 +135,8 @@
 																? (Object) resource
 													}
-												//}
-												//return false;
+												}
+												return false;
 											case IResource.FOLDER :
 												if (patterns != null && Util.isExcluded(proxy.requestResource(), patterns))
 													return false;
Index: index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
===================================================================
retrieving revision 1.17
diff -u -r1.17 SourceIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java	10 Feb 2004 18:17:42 -0000	1.17
+++ index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java	13 Feb 2004 20:02:01 -0000
@@ -97,28 +97,36 @@
 		{
 		}
 		
-		ParserRunner p = new ParserRunner(parser);
-		Thread t = new Thread(p, "CDT Indexer Parser Runner");
-		t.start();
-		
 		try{
-			t.join();
+			boolean retVal = parser.parse();
+			
+			if (!retVal)
+				org.eclipse.cdt.internal.core.model.Util.log(null, "Failed to index " + resourceFile.getFullPath(), ICLogConstants.CDT);
+
+			if (AbstractIndexer.VERBOSE){
+				if (!retVal)
+					AbstractIndexer.verbose("PARSE FAILED " + resourceFile.getName().toString());
+				else
+					AbstractIndexer.verbose("PARSE SUCCEEDED " + resourceFile.getName().toString());			
+			}	
 		}
-		catch (InterruptedException e){
-			org.eclipse.cdt.internal.core.model.Util.log(null, "Parser Runner InterruptedException - file: " + resourceFile.getFullPath(), ICLogConstants.CDT);
+		catch ( VirtualMachineError vmErr){
+			if (vmErr instanceof OutOfMemoryError){
+				org.eclipse.cdt.internal.core.model.Util.log(null, "Out Of Memory error: " + vmErr.getMessage() + " on File: " + resourceFile.getName(), ICLogConstants.CDT);
+			}
+		}
+		catch ( Exception ex ){
+			if (ex instanceof IOException)
+				throw (IOException) ex;
+		}
+		finally{
+			//Release all resources
+			parser=null;
+			currentProject = null;
+			requestor = null;
+			provider = null;
+			scanInfo=null;
 		}
-		
-		boolean retVal = p.getResult();
-		
-		if (!retVal)
-			org.eclipse.cdt.internal.core.model.Util.log(null, "Failed to index " + resourceFile.getFullPath(), ICLogConstants.CDT);
-		
-		if (AbstractIndexer.VERBOSE){
-			if (!retVal)
-				AbstractIndexer.verbose("PARSE FAILED " + resourceFile.getName().toString());
-			else
-				AbstractIndexer.verbose("PARSE SUCCEEDED " + resourceFile.getName().toString());			
-		}	
 	}
 	/**
 	 * Sets the document types the <code>IIndexer</code> handles.
@@ -132,25 +140,4 @@
 		return resourceFile;
 	}
 	
-	class ParserRunner implements Runnable {
-		IParser parser;
-		boolean retVal;
-		ParserRunner(IParser parser){
-			this.parser = parser;
-		}
-		/* (non-Javadoc)
-		 * @see java.lang.Runnable#run()
-		 */
-		public void run() {
-			try{
-				retVal=parser.parse();
-			}
-			catch (Exception e){
-				org.eclipse.cdt.internal.core.model.Util.log(null, "Parser Runner Exception " + resourceFile.getFullPath() + " Message: " + e.getMessage(), ICLogConstants.CDT);
-			}
-		}
-		
-		boolean getResult(){ return retVal;}
-		
-	}
 }
Index: search/ChangeLog
===================================================================
retrieving revision 1.42
diff -u -r1.42 ChangeLog
--- search/ChangeLog	9 Feb 2004 15:46:35 -0000	1.42
+++ search/ChangeLog	13 Feb 2004 20:02:06 -0000
@@ -1,3 +1,7 @@
+2004-02-13 Bogdan Gheorghe
+	- Added error handling to MatchLocator.locateMatches to handle possible
+	  parser failures.
+	
 2004-02-06 Bogdan Gheorghe
 
 	- Modified CSearchPattern.scanforParameters. If no parameters are passed in
Index: search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
===================================================================
retrieving revision 1.42
diff -u -r1.42 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	27 Jan 2004 01:21:18 -0000	1.42
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	13 Feb 2004 20:02:07 -0000
@@ -451,7 +451,23 @@
 			if (VERBOSE)
 			  MatchLocator.verbose("*** New Search for path: " + pathString);
 			  
-			parser.parse();
+			
+			try{ 
+				parser.parse();
+			}
+			catch(Exception ex){
+				if (VERBOSE){
+					ex.printStackTrace();
+				}
+			}
+			catch(VirtualMachineError vmErr){
+				if (VERBOSE){
+					MatchLocator.verbose("MatchLocator VM Error: ");
+					vmErr.printStackTrace();
+				}
+			}
+			
 		}
 	}
 	

Back to the top