[eclipse-gcov/f17] Fix gcov GCNO data format with gcc 4.7.

Roland Grunberg rgrunber at fedoraproject.org
Thu Aug 30 19:53:38 UTC 2012


commit 8c3a7688ee2bd909ab3d9fbd852d9653a8a2d389
Author: Roland Grunberg <rgrunber at redhat.com>
Date:   Tue Aug 21 13:31:20 2012 -0400

    Fix gcov GCNO data format with gcc 4.7.

 eclipse-gcov.spec          |    5 ++
 fix-gcov-GCNO-format.patch |  143 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+), 0 deletions(-)
---
diff --git a/eclipse-gcov.spec b/eclipse-gcov.spec
index 97f0223..2185022 100644
--- a/eclipse-gcov.spec
+++ b/eclipse-gcov.spec
@@ -10,6 +10,7 @@ Group:          Development/Tools
 License:        EPL
 URL:            http://www.eclipse.org/linuxtools/projectPages/gcov
 Source0:        http://download.eclipse.org/linuxtools/%{version}-sources/linuxtools-gcov-parent-%{version}-src.tar.bz2
+Patch0:         fix-gcov-GCNO-format.patch
 
 BuildArch: noarch
 
@@ -25,6 +26,7 @@ Functionality to integrate GCov with the Eclipse workbench.
 
 %prep
 %setup -q -n linuxtools-gcov-parent-%{version}-src
+%patch0 -p2
 
 %build
 chmod -x org.eclipse.linuxtools.gcov/license.html
@@ -44,6 +46,9 @@ install -d -m 755 %{buildroot}%{install_loc}
 %doc org.eclipse.linuxtools.gcov/epl-v10.html
 
 %changelog
+* Tue Aug 30 2012 Roland Grunberg <rgrunber at redhat.com> 1.0.0-2
+- Fix gcov GCNO data format with gcc 4.7.
+
 * Fri Jul 6 2012 Jeff Johnston <jjohnstn at redhat.com> 1.0.0-1
 - Update to Linux Tools 1.0.0 release (Juno).
 
diff --git a/fix-gcov-GCNO-format.patch b/fix-gcov-GCNO-format.patch
new file mode 100644
index 0000000..b38096c
--- /dev/null
+++ b/fix-gcov-GCNO-format.patch
@@ -0,0 +1,143 @@
+From d5a2dad050942ef3b1818f2cb01571507175cbad Mon Sep 17 00:00:00 2001
+From: Daniel Henrique Barboza <danielhb at br.ibm.com>
+Date: Mon, 20 Aug 2012 11:55:50 -0300
+Subject: [PATCH] Fixing Gcov parser for newer versions of Gcov
+
+GCNO file format changed in newer versions. Gcov parser must reflect
+this new format. The reading of the version number (and ANY of the data)
+should be postponed until we have the determined the byte order
+(Little/Big Endian).
+
+Change-Id: I945c8e053df2e1de7b8900347cdbea94b950f290
+Reviewed-on: https://git.eclipse.org/r/7526
+Tested-by: Hudson CI
+Reviewed-by: Daniel Henrique Barboza <danielhb at br.ibm.com>
+IP-Clean: Daniel Henrique Barboza <danielhb at br.ibm.com>
+Tested-by: Daniel Henrique Barboza <danielhb at br.ibm.com>
+---
+ .../internal/gcov/parser/GcdaRecordsParser.java    | 37 ++++++++++++++++++----
+ .../internal/gcov/parser/GcnoRecordsParser.java    | 32 ++++++++++++++++---
+ 2 files changed, 58 insertions(+), 11 deletions(-)
+
+diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcdaRecordsParser.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcdaRecordsParser.java
+index 6eeac2e..4075d12 100644
+--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcdaRecordsParser.java
++++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcdaRecordsParser.java
+@@ -58,12 +58,6 @@ public class GcdaRecordsParser {
+ 
+ 		//read magic
+ 		magic = stream.readInt();
+-		//read version
+-		//version = stream.readInt();
+-		stream.readInt();
+-		//read stamp
+-		//stamp = stream.readInt();
+-		stream.readInt();
+ 
+ 		if (magic == GCOV_DATA_MAGIC){
+ 			stream = new BEDataInputStream((DataInputStream) stream);
+@@ -79,6 +73,12 @@ public class GcdaRecordsParser {
+ 			}
+ 		}
+ 
++		//read version
++		int version = stream.readInt();
++		//read stamp
++		//stamp = stream.readInt();
++		stream.readInt();
++
+ 		while (true) {
+ 			try {
+ 				// parse header
+@@ -101,6 +101,31 @@ public class GcdaRecordsParser {
+ 									Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message);
+ 									throw new CoreException(status);
+ 								}
++
++								/*
++								 * danielhb, 2012-08-06: Gcov versions 4.7.0 or
++								 * later (long value = 875575105) has different format for
++								 * the data file:
++								 * 
++								 * prior format:
++								 * 
++								 * announce_function: header int32:ident int32:checksum
++								 * 
++								 * new format:
++								 * 
++								 * announce_function: header int32:ident
++					             *     int32:lineno_checksum int32:cfg_checksum
++								 * 
++								 * 
++								 * TL;DR Need to consume the extra long value.
++								 * 
++								 */
++								if (version >= 875575105)
++								{
++									// long cfgChksm = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
++									stream.readInt();
++								}
++
+ 								break;
+ 							}
+ 						}
+diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoRecordsParser.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoRecordsParser.java
+index 501a86d..9f13314 100644
+--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoRecordsParser.java
++++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoRecordsParser.java
+@@ -68,11 +68,6 @@ public class GcnoRecordsParser {
+ 		boolean parseFirstFnctn = false;
+ 		
+ 		magic = stream.readInt();
+-		//version = stream.readInt();
+-		stream.readInt();
+-		//stamp = stream.readInt();
+-		stream.readInt();
+-		
+ 		if (magic == GCOV_NOTE_MAGIC){
+ 			stream = new BEDataInputStream((DataInputStream) stream);
+ 		}else{
+@@ -87,6 +82,10 @@ public class GcnoRecordsParser {
+ 			}
+ 		}
+ 		
++		int version = stream.readInt();
++		//stamp = stream.readInt();
++		stream.readInt();
++
+ 		/*------------------------------------------------------------------------------
+ 		System.out.println("Gcno LE, Magic "+magic+" version "+version+" stamp "+stamp);
+ 		*/
+@@ -110,6 +109,29 @@ public class GcnoRecordsParser {
+ 					
+ 					long fnctnIdent = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
+ 					long fnctnChksm = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
++					/*
++					 * danielhb, 2012-08-06: Gcov versions 4.7.0 or
++					 * later (long value = 875575105) has different format for
++					 * the data file:
++					 * 
++					 * prior format:
++					 * 
++					 * announce_function: header int32:ident int32:checksum
++					 * 
++					 * new format:
++					 * 
++					 * announce_function: header int32:ident
++		             *     int32:lineno_checksum int32:cfg_checksum
++					 * 
++					 * 
++					 * TL;DR Need to consume the extra long value.
++					 * 
++					 */
++					if (version >= 875575105)
++					{
++						// long cfgChksm = (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
++						stream.readInt();
++					}
+ 					String fnctnName = GcovStringReader.readString(stream);
+ 					String fnctnSrcFle = GcovStringReader.readString(stream);
+ 					long fnctnFrstLnNmbr= (stream.readInt()&MasksGenerator.UNSIGNED_INT_MASK);
+-- 
+1.7.11.4
+


More information about the scm-commits mailing list