Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Linux Tools Project » Mangled C++ names are printed in the coverage summary report
Mangled C++ names are printed in the coverage summary report [message #1001708] Thu, 17 January 2013 08:57 Go to next message
Tamas Kleiber is currently offline Tamas Kleiber
Messages: 20
Registered: December 2010
Junior Member
Hello,

I am on Windows platform working with Win32/PE executables. Eclipse's built in x86/le parser can demangle the C++ function names. But I noticed that the GCov Integration plug-in produces mangled names in it's summary report view.

Take the following example:

/* function prototype */
void VER_updateVersionInfoField(VER_infoFieldTypes_t field, uint8_t srcAddress[]);

/* demangled name by eclipse's x86/le binary parser */
VER_updateVersionInfoField(VER_infoFieldTypes_t, uint8_t[]) : void

/* mangled name visible in GCov Integration plug-in's summary report */
_ZN12_GLOBAL__N_126VER_updateVersionInfoFieldENS_16VER_infoFields_eEPh


Would it be possible to get demangled names in the summary report?
Re: Mangled C++ names are printed in the coverage summary report [message #1001817 is a reply to message #1001708] Thu, 17 January 2013 12:14 Go to previous messageGo to next message
Xavier Raynaud is currently offline Xavier Raynaud
Messages: 15
Registered: February 2012
Junior Member
Do you have "c++filt.exe" in your Path ?
If yes, what's the result of the following command:

c++filt.exe _ZN12_GLOBAL__N_126VER_updateVersionInfoFieldENS_16VER_infoFields_eEPh

Re: Mangled C++ names are printed in the coverage summary report [message #1001826 is a reply to message #1001817] Thu, 17 January 2013 12:28 Go to previous messageGo to next message
Tamas Kleiber is currently offline Tamas Kleiber
Messages: 20
Registered: December 2010
Junior Member
The output is the same:

C:\>c++filt --version
GNU c++filt (GNU Binutils) 2.22
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

C:\>c++filt _ZN12_GLOBAL__N_126VER_updateVersionInfoFieldENS_16VER_infoFields_eEPh
_ZN12_GLOBAL__N_126VER_updateVersionInfoFieldENS_16VER_infoFields_eEPh


I've also checked all c++filt switches and they produce the same output in all cases.

So the problem is on my end?
Re: Mangled C++ names are printed in the coverage summary report [message #1002223 is a reply to message #1001817] Fri, 18 January 2013 08:02 Go to previous messageGo to next message
Tamas Kleiber is currently offline Tamas Kleiber
Messages: 20
Registered: December 2010
Junior Member
Hello Xavier,

I found the problem. C++filt required the -n option. This way the output is as follows:

O:\eclipse\eclipse_java>c++filt c++filt.exe --help
Usage: c++filt [options] [mangled names]
Options are:
  [-_|--strip-underscore]     Ignore first leading underscore (default)
  [-n|--no-strip-underscore]  Do not ignore a leading underscore
  [-p|--no-params]            Do not display function arguments
  [-i|--no-verbose]           Do not show implementation details (if any)
  [-t|--types]                Also attempt to demangle type encodings
  [-s|--format {none,auto,gnu,lucid,arm,hp,edg,gnu-v3,java,gnat}]
  [@<file>]                   Read extra options from <file>
  [-h|--help]                 Display this information
  [-v|--version]              Show the version information
Demangled names are displayed to stdout.
If a name cannot be demangled it is just echoed to stdout.
If no names are provided on the command line, stdin is read.
Report bugs to <http://www.sourceware.org/bugzilla/>.

O:\eclipse\eclipse_java>c++filt -n _ZN12_GLOBAL__N_126VER_updateVersionInfoFieldENS_16VER_infoFields_eEPh
(anonymous namespace)::VER_updateVersionInfoField((anonymous namespace)::VER_infoFields_e, unsigned char*)


Note that the anonymous or file scope name space is intentional.

[Updated on: Fri, 18 January 2013 08:04]

Report message to a moderator

Re: Mangled C++ names are printed in the coverage summary report [message #1004295 is a reply to message #1002223] Tue, 22 January 2013 23:42 Go to previous message
Tamas Kleiber is currently offline Tamas Kleiber
Messages: 20
Registered: December 2010
Junior Member
I found that in CovManager.java, the following call is made:
name = STSymbolManager.sharedInstance.demangle(binaryObject, name, project);


The demangle() function calls demangleImpl(symbolName, cpu, project) where cpu is identified as "x86".

In demangleImpl() the first code line is this:
CPPFilt cppfilt = getCppFilt(cpu, project);


And getCppFilt() reaches this code snippet:
if (adCppfilt.cppfilt == null) {
	try {
		adCppfilt.cppfilt = STCPPFiltFactory.getCPPFilt(cpu, project);
	} catch (IOException _) {
		// TODO: log the error ?;
		// Perhaps log the error only once, because 
		// this method is called many many times...
		return null;
	}
}


where STCPPFiltFactory.getCPPFilt(cpu, project) throws an exception saying: "java.io.IOException: Cannot run program "c++filt": Launching failed", but this exception is silenced with a TODO.

So at last it turned out that the GCov plugin has some dependencies and actually my mingw is not registered in the system path as it is not allowed to be registered in my work environment that way. So after fixing the tool dependency issue at my end, I reached to this position in demangleImpl():

symbolName = cppfilt.getFunction(symbolName);


Which returns the original mangled names as per the examples above. I think my issue is coming from DefaultBinutilsFactory.java, as class DefaultBinutilsFactory defines the CPPFILT_CMD command simply as "c++filt". So probably the -n command line switch is never applied.

I tried to figure out how to add this -n switch for quick testing as prefix to the function name or as a suffix to CPPFILT_CMD but nothing worked out...


So... as c++filt has two operation modes, cut first underscore (default behavior) and keep first underscore (alternative behavior), would it be possible to perform the c++filt tool invocation twice so that if the default invocation results in the same mangled name which was passed to the demangler function than it tries to demangle the name using the alternate method with the -n switch?


By the way I am using the latest MinGW/GCC distribution on Windows so the mangled names should not be anything fancy unique special abominations...
Previous Topic:GCov integration plug-in only accepts executable files from loaded project folders
Next Topic:Autotools and Windows and Cygwin Post 0.8
Goto Forum:
  


Current Time: Tue Sep 16 17:45:50 GMT 2014

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

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