Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] 1.0.1 editor/binaryinfo fix II

Hi,

Again just an FYI, turns out I was using a toolchain that put absolute source paths in the .o's. There were issues in the ISymbol->IFunction translation for toolchains that produce relative source paths. (Probably IVariable too). This corrects that.

All the standard, "I'll look at the head when we move to the head" disclaimers apply. :)

Thanks!
-Chris

diff -r -c xide_compare/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryInfo.java xide/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryInfo.java *** xide_compare/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryInfo.java Wed Mar 12 08:41:14 2003 --- xide/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryInfo.java Wed Mar 12 08:40:57 2003
***************
*** 18,23 ****
--- 18,24 ----
  import org.eclipse.cdt.core.IBinaryParser.ISymbol;
  import org.eclipse.cdt.core.model.CModelException;
  import org.eclipse.cdt.core.model.ICElement;
+ import org.eclipse.core.resources.IResource;
  import org.eclipse.core.resources.IFile;
  import org.eclipse.core.resources.IProject;
  import org.eclipse.core.runtime.IPath;
***************
*** 175,190 ****
  		}
  		return binary;
  	}
!
! 	private void addFunction(ISymbol symbol) {
  		ICElement parent = getElement();
  		String filename = filename = symbol.getFilename();
- 		Function function = null;

  		// Addr2line returns the funny "??" when it can find the file.
  		if (filename != null && !filename.equals("??")) {
- 			TranslationUnit tu = null;
  			IPath path = new Path(filename);
  			if (hash.containsKey(path)) {
  				tu = (TranslationUnit) hash.get(path);
  			} else {
--- 176,207 ----
  		}
  		return binary;
  	}
! 	
! 	/** Converts the symbol to a function by reading the ISymbol information
! 	 * and using it to create a Function. */
! 	private void addFunction(ISymbol symbol)
! 	{
! 		Function function = null;
  		ICElement parent = getElement();
  		String filename = filename = symbol.getFilename();

  		// Addr2line returns the funny "??" when it can find the file.
  		if (filename != null && !filename.equals("??")) {
  			IPath path = new Path(filename);
+ 			
+ 			/* in the case of a relative path, we need to turn it into an absolute
+ 			 * path so that the lookups later work properly. */
+ 			if( !path.isAbsolute() )
+ 			{
+ 				IResource parentRes = (IResource)parent.getAdapter( IResource.class );
+ 				// assert parentRes, we should always have a solid executable.
+ 				if( parentRes != null )
+ 				{
+ 					IPath parentPath = parentRes.getLocation().removeLastSegments(1);
+ 					path = parentPath.append(path);
+ 				}
+ 			}
+ 			TranslationUnit tu = null;
  			if (hash.containsKey(path)) {
  				tu = (TranslationUnit) hash.get(path);
  			} else {



Back to the top