* [PATCH] Describe better version mismatch in libgcov driver.
@ 2019-01-18 10:04 Martin Liška
0 siblings, 0 replies; only message in thread
From: Martin Liška @ 2019-01-18 10:04 UTC (permalink / raw)
To: gcc-patches; +Cc: Jan Hubicka
[-- Attachment #1: Type: text/plain, Size: 607 bytes --]
Hi.
The patch is about better explanation of version mismatch in libgcov
driver. Now we'll print:
profiling:/tmp/main.gcda:Version mismatch - expected 9.0 (experimental) (A90e) got 8.2 (release) (A82*)
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
It's approved by Honza.
Thanks,
Martin
libgcc/ChangeLog:
2019-01-17 Martin Liska <mliska@suse.cz>
* libgcov-driver.c (gcov_version_string): New function.
(gcov_version): Convert version integer into string.
---
libgcc/libgcov-driver.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
[-- Attachment #2: 0001-Describe-better-version-mismatch-in-libgcov-driver.patch --]
[-- Type: text/x-patch, Size: 1851 bytes --]
diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index 44f43e6e9af..41d28ace926 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -157,6 +157,27 @@ fail:
return (struct gcov_fn_buffer **)free_fn_data (gi_ptr, fn_buffer, ix);
}
+/* Convert VERSION into a string description and return the it.
+ BUFFER is used for storage of the string. The code should be
+ aligned wit gcov-iov.c. */
+
+static char *
+gcov_version_string (char *buffer, char version[4])
+{
+ if (version[0] < 'A' || version[0] > 'Z'
+ || version[1] < '0' || version[1] > '9'
+ || version[2] < '0' || version[2] > '9')
+ sprintf (buffer, "(unknown)");
+ else
+ {
+ unsigned major = 10 * (version[0] - 'A') + (version[1] - '0');
+ unsigned minor = version[2] - '0';
+ sprintf (buffer, "%u.%u (%s)", major, minor,
+ version[3] == '*' ? "release" : "experimental");
+ }
+ return buffer;
+}
+
/* Check if VERSION of the info block PTR matches libgcov one.
Return 1 on success, or zero in case of versions mismatch.
If FILENAME is not NULL, its value used for reporting purposes
@@ -169,12 +190,16 @@ gcov_version (struct gcov_info *ptr, gcov_unsigned_t version,
if (version != GCOV_VERSION)
{
char v[4], e[4];
+ char version_string[128], expected_string[128];
GCOV_UNSIGNED2STRING (v, version);
GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
- gcov_error ("profiling:%s:Version mismatch - expected %.4s got %.4s\n",
- filename? filename : ptr->filename, e, v);
+ gcov_error ("profiling:%s:Version mismatch - expected %s (%.4s) "
+ "got %s (%.4s)\n",
+ filename? filename : ptr->filename,
+ gcov_version_string (expected_string, e), e,
+ gcov_version_string (version_string, v), v);
return 0;
}
return 1;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-01-18 10:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-18 10:04 [PATCH] Describe better version mismatch in libgcov driver Martin Liška
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).