[gnumeric] Valgrind: avoid noise from GnmRenderedValue::rotation.



commit 1a2466cc2774dbf4a23a65bdedd7ba91cb37da38
Author: Morten Welinder <terra gnome org>
Date:   Tue Mar 18 15:49:33 2014 -0400

    Valgrind: avoid noise from GnmRenderedValue::rotation.
    
    It's a signed bitfield and some versions of Valgrind do not understand
    that it is defined when it has been set.

 src/rendered-value.c |   19 +++++++++++++++++++
 test/common.supp     |    8 ++++++++
 tools/gnmvalgrind    |    7 +++++--
 3 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/src/rendered-value.c b/src/rendered-value.c
index c33822a..427d415 100644
--- a/src/rendered-value.c
+++ b/src/rendered-value.c
@@ -73,6 +73,20 @@ debug_rv (void)
        return res > 0;
 }
 
+/*
+ * Some valgrind versions have a hard time with signed bitfields,
+ * such as GnmRenderedValue::rotation.
+ */
+static gboolean
+valgrind_bitfield_workarounds (void)
+{
+       static int res = -1;
+       if (res == -1) {
+               res = gnm_debug_flag ("valgrind-bitfield-workarounds");
+       }
+       return res > 0;
+}
+
 
 static guint16
 calc_indent (PangoContext *context, const GnmStyle *mstyle)
@@ -274,6 +288,11 @@ gnm_rendered_value_new (GnmCell const *cell,
 
                rrv = CHUNK_ALLOC (GnmRenderedRotatedValue, rendered_rotated_value_pool);
                res = &rrv->rv;
+               if (valgrind_bitfield_workarounds ()) {
+                       memset (&res->go_fore_color + 1,
+                               0,
+                               (char *)(res + 1) - (char *)(&res->go_fore_color + 1));
+               }
 
                rrv->linecount = 0;
                rrv->lines = NULL;
diff --git a/test/common.supp b/test/common.supp
index 027f5e7..2f27300 100644
--- a/test/common.supp
+++ b/test/common.supp
@@ -800,3 +800,11 @@
    fun:g_malloc
    fun:g_quark_from_string
 }
+
+{
+   GLIB/G_INTERN_STRING
+   Memcheck:Leak
+   fun:malloc
+   fun:g_malloc
+   fun:g_intern_string
+}
diff --git a/tools/gnmvalgrind b/tools/gnmvalgrind
index 3179cd1..b74aa55 100755
--- a/tools/gnmvalgrind
+++ b/tools/gnmvalgrind
@@ -31,6 +31,7 @@ die "$0: usage $0 [valgrind options] gnumeric [gnumeric-options]\n"
     unless $program;
 
 &add_debug_flag ('G_SLICE', 'always-malloc');
+&add_debug_flag ('GNM_DEBUG', 'valgrind-bitfield-workarounds');
 if ($seen_leak_check) {
     &add_debug_flag ('G_DEBUG', 'resident-modules');
     &add_debug_flag ('GNM_DEBUG', 'close-displays');
@@ -51,12 +52,14 @@ sub add_debug_flag {
     my ($var,$flag) = @_;
 
     if (exists $ENV{$var}) {
-       print STDERR "Adding $flag to existing $var\n" if $verbose;
+       foreach my $f2 (split (':', $ENV{$var})) {
+           return if $f2 eq $flag;
+       }
        $ENV{$var} .= ":$flag";
     } else {
-       print STDERR "Setting $var=$flag\n" if $verbose;
        $ENV{$var} = $flag;
     }
+    print STDERR "Setting $var=", $ENV{$var}, "\n" if $verbose;
 }
 
 sub find_topsrc {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]