Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Henrique Barboza2012-08-20 14:55:50 +0000
committerDaniel Henrique Barboza2012-08-30 17:48:36 +0000
commitd5a2dad050942ef3b1818f2cb01571507175cbad (patch)
treea4918c7d92c3174b294adacd6a67210d847f239d
parente3dc97ec6e9ec52e64fcc487d090668ed89b0147 (diff)
downloadorg.eclipse.linuxtools-d5a2dad050942ef3b1818f2cb01571507175cbad.tar.gz
org.eclipse.linuxtools-d5a2dad050942ef3b1818f2cb01571507175cbad.tar.xz
org.eclipse.linuxtools-d5a2dad050942ef3b1818f2cb01571507175cbad.zip
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@br.ibm.com> IP-Clean: Daniel Henrique Barboza <danielhb@br.ibm.com> Tested-by: Daniel Henrique Barboza <danielhb@br.ibm.com>
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcdaRecordsParser.java37
-rw-r--r--gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/parser/GcnoRecordsParser.java32
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 6eeac2ed39..4075d12071 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(IStatus.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 501a86dfda..9f13314ebc 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);

Back to the top