Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Linux Tools Project » GCov integration plug-in only accepts executable files from loaded project folders
GCov integration plug-in only accepts executable files from loaded project folders [message #999992] Sun, 13 January 2013 18:00 Go to next message
Tamas Kleiber is currently offline Tamas Kleiber
Messages: 20
Registered: December 2010
Junior Member
Hello,

I have some problems opening a Win32/PE executable with the gcov integration plug-in if the executable can be found in a folder which is not part of the CDT project itself or if the executable is linked into the project using linked resources from whatever local or arbitrary place.

Example:

eclipse workspace: c:/workspace/
CDT project home: o:/test_project/
executable location: c:/output_files/unittest.exe

In this particular setup, if the executable is selected using "File System..." gcov plug-in throws "c:/output_files/unittest.exe is not a valid binary file." Error.

If executable location is: o:/test_project/unittest.exe, everything is fine, the executable is opened without any problems.

If an arbitrary folder is linked into CDT's project explorer view as a linked resource the error is thrown again even if executable is opened with the "Workspace..." button.


The following code line fails in OpenGCDialog.java inside member validateBinary():
IBinaryObject binary = STSymbolManager.sharedInstance.getBinaryObject(new Path(binValue));


I traced through the code and in STSymbolManager.sharedInstance.getBinaryObject(), the first code line fails:
IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);


Variable c becomes null. The path input parameter is a valid path outside of the CDT project home: "c:/output_files/unittest.exe"

The documentation of .getFileForLocation() states the followings:

Quote:

Returns a handle to the file which is mapped to the given path in the local file system, or null if none. The path should be absolute; a relative path will be treated as absolute. The path segments need not be valid names. The resulting file may not currently exist.

This method returns null when the given file system location is not under the location of any existing project in the workspace.

The result will also omit resources that are explicitly excluded from the workspace according to existing resource filters.

Warning: This method ignores linked resources and their children. Since linked resources may overlap other resources, a unique mapping from a file system location to a single resource is not guaranteed. To find all resources for a given location, including linked resources, use the method findFilesForLocation.



This means that the currently used interface in STSymbolManager.sharedInstance.getBinaryObject() can only open executables which are directly stored under a loaded project's home folder. In my opinion this is a very big limitation and for example in my case I cannot resolve it without violation of workplace policies.


Would it be possible to update method getBinaryObject() in STSymbolManager() class to support also arbitrary locations and not only ones from the project folder itself without linked resources?
Re: GCov integration plug-in only accepts executable files from loaded project folders [message #1000255 is a reply to message #999992] Mon, 14 January 2013 11:17 Go to previous messageGo to next message
Xavier Raynaud is currently offline Xavier Raynaud
Messages: 15
Registered: February 2012
Junior Member
Hi,

Thanks for you message.
I reproduced it locally.

A patch will be ready soon.

Xavier
Re: GCov integration plug-in only accepts executable files from loaded project folders [message #1000302 is a reply to message #1000255] Mon, 14 January 2013 13:21 Go to previous messageGo to next message
Xavier Raynaud is currently offline Xavier Raynaud
Messages: 15
Registered: February 2012
Junior Member
patch submitted here:
https://git.eclipse.org/r/9652
Re: GCov integration plug-in only accepts executable files from loaded project folders [message #1000340 is a reply to message #1000302] Mon, 14 January 2013 15:00 Go to previous messageGo to next message
Tamas Kleiber is currently offline Tamas Kleiber
Messages: 20
Registered: December 2010
Junior Member
Thank you very much! I've tested the patch. I could open binaries from linked resources and also from completely unrelated locations on my local drive.

[Updated on: Mon, 14 January 2013 19:04]

Report message to a moderator

Re: GCov integration plug-in only accepts executable files from loaded project folders [message #1000502 is a reply to message #999992] Mon, 14 January 2013 22:41 Go to previous messageGo to next message
Jeff Johnston is currently offline Jeff Johnston
Messages: 173
Registered: July 2009
Senior Member
Tamas, the code sequence you are referring to is trying to get the project for the resource to then get its binary parsers. The code is prepared for c to come back null in which case it looks for the default binary parser from the CCorePlugin.

Unfortunately, this is looking for a preference to have been set up which isn't done and so it should fall back to the ELF binary parser. Your executable should be PE and thus the ELF parser should fail.

There are two possible ways to try and fix this.

1. Have CCorePlugin return a more appropriate default binary parser
- currently the binary parser extensions don't register themselves with
extension info (e.g. .exe means this should be the PE binary parser)
- this information is stored at the project level which ties together the
proper output suffix and binary parser
- one could create a dummy project and see what binary parser gets set for it but
that is a hack

2. Don't bother asking CCorePlugin for the default binary parser and instead add all
binary parsers that have registered themselves to the list of binary parsers to
try
- conceivably this should try all parsers until the PE parser is tried at which
point things should get farther along (can't say what will happen after that)

If you open a Bugzilla bug, I can attempt to post a gerrit patch for you to try using option 2 or perhaps placing a repo somewhere for you.
Re: GCov integration plug-in only accepts executable files from loaded project folders [message #1000504 is a reply to message #999992] Mon, 14 January 2013 22:44 Go to previous messageGo to next message
Jeff Johnston is currently offline Jeff Johnston
Messages: 173
Registered: July 2009
Senior Member
No Message Body
Re: GCov integration plug-in only accepts executable files from loaded project folders [message #1000506 is a reply to message #1000502] Mon, 14 January 2013 22:47 Go to previous messageGo to next message
Jeff Johnston is currently offline Jeff Johnston
Messages: 173
Registered: July 2009
Senior Member
Ignore my last post. I did not see Xavier's post regarding his gerrit patch. It happens to match what I was going to do.
Re: GCov integration plug-in only accepts executable files from loaded project folders [message #1000679 is a reply to message #1000506] Tue, 15 January 2013 08:35 Go to previous message
Xavier Raynaud is currently offline Xavier Raynaud
Messages: 1
Registered: July 2011
Junior Member
Hi Jeff,

Just for info: I had the same idea, but I don't find how to change the default binary parser returned by CCorePlugin.
Is there a way to change it easily ?
Previous Topic:Regex based file filter for Gcov coverage outputs
Next Topic:Mangled C++ names are printed in the coverage summary report
Goto Forum:
  


Current Time: Fri Sep 19 00:03:06 GMT 2014

Powered by FUDForum. Page generated in 0.03127 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software