summaryrefslogtreecommitdiffstats
path: root/tools/wine_valgrind/valgrind_stop_frame.patch
blob: 1e3d71d3fb825b5bd00acd086af2b54a6bcffbf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
This patch adds a "STOP" frame to valgrind suppressions
so we can do exact matches. This is filed as
https://bugs.kde.org/show_bug.cgi?id=222604
TODO(thestig) update the matcher spec and submit upstream.
Index: include/pub_tool_seqmatch.h
===================================================================
--- include/pub_tool_seqmatch.h	(revision 10880)
+++ include/pub_tool_seqmatch.h	(working copy)
@@ -76,6 +76,7 @@
         void* input, SizeT szbInput, UWord nInput, UWord ixInput,
         Bool (*pIsStar)(void*),
         Bool (*pIsQuery)(void*),
+        Bool (*pIsStop)(void*),
         Bool (*pattEQinp)(void*,void*)
      );
 
Index: coregrind/m_errormgr.c
===================================================================
--- coregrind/m_errormgr.c	(revision 10880)
+++ coregrind/m_errormgr.c	(working copy)
@@ -194,7 +194,8 @@
       NoName,     /* Error case */
       ObjName,    /* Name is of an shared object file. */
       FunName,    /* Name is of a function. */
-      DotDotDot   /* Frame-level wildcard */
+      DotDotDot,  /* Frame-level wildcard */
+      STOP        /* STOP sign */
    }
    SuppLocTy;
 
@@ -1074,6 +1075,11 @@
       p->ty = DotDotDot;
       return True;
    }
+   if (VG_(strcmp)(p->name, "STOP") == 0) {
+      p->name = NULL;
+      p->ty = STOP;
+      return True;
+   }
    VG_(printf)("location should be \"...\", or should start "
                "with \"fun:\" or \"obj:\"\n");
    return False;
@@ -1243,13 +1249,17 @@
          } while (!eof && !VG_STREQ(buf, "}"));
       }
 
-      // Reject entries which are entirely composed of frame
-      // level wildcards.
       vg_assert(i > 0); // guaranteed by frame-descriptor reading loop
+      // Reject any pattern where STOP is not the last entry.
+      for (j = 0; j < i - 1; j++) {
+         if (tmp_callers[j].ty == STOP)
+            BOMB("STOP must be the last entry in a suppression");
+      }
+      // Reject entries which are entirely composed of frame level wildcards.
       for (j = 0; j < i; j++) {
          if (tmp_callers[j].ty == FunName || tmp_callers[j].ty == ObjName)
             break;
-         vg_assert(tmp_callers[j].ty == DotDotDot);
+         vg_assert(tmp_callers[j].ty == DotDotDot || tmp_callers[j].ty == STOP);
       }
       vg_assert(j >= 0 && j <= i);
       if (j == i) {
@@ -1324,6 +1334,12 @@
    return False; /* there's no '?' equivalent in the supp syntax */
 }
 
+static Bool supploc_IsStop ( void* supplocV )
+{
+   SuppLoc* supploc = (SuppLoc*)supplocV;
+   return supploc->ty == STOP;
+}
+
 static Bool supp_pattEQinp ( void* supplocV, void* addrV )
 {
    SuppLoc* supploc = (SuppLoc*)supplocV; /* PATTERN */
@@ -1340,6 +1356,8 @@
             should never get called with a pattern value for which the
             _IsStar or _IsQuery function would return True.  Hence
             this can't happen. */
+      case STOP:
+         // Ditto.
          vg_assert(0);
       case ObjName:
          /* Get the object name into 'caller_name', or "???"
@@ -1389,7 +1407,7 @@
          matchAll,
          /*PATT*/supps, szbPatt, n_supps, 0/*initial Ix*/,
          /*INPUT*/ips, szbInput, n_ips,  0/*initial Ix*/,
-         supploc_IsStar, supploc_IsQuery, supp_pattEQinp
+         supploc_IsStar, supploc_IsQuery, supploc_IsStop, supp_pattEQinp
       );
 }
 
Index: coregrind/m_seqmatch.c
===================================================================
--- coregrind/m_seqmatch.c	(revision 10880)
+++ coregrind/m_seqmatch.c	(working copy)
@@ -45,6 +45,7 @@
         void* input, SizeT szbInput, UWord nInput, UWord ixInput,
         Bool (*pIsStar)(void*),
         Bool (*pIsQuery)(void*),
+        Bool (*pIsStop)(void*),
         Bool (*pattEQinp)(void*,void*)
      )
 {
@@ -102,7 +103,7 @@
          if (VG_(generic_match)( matchAll,
                                  patt, szbPatt, nPatt,  ixPatt+1,
                                  input,szbInput,nInput, ixInput+0,
-                                 pIsStar,pIsQuery,pattEQinp) ) {
+                                 pIsStar,pIsQuery,pIsStop,pattEQinp) ) {
             return True;
          }
          // but we can tail-recurse for the second call
@@ -125,6 +126,9 @@
       }
    }
 
+   if (havePatt && pIsStop(currPatt))
+      return !haveInput;
+
    // obvious case with literal chars in the pattern
    //
    // ma (p:ps)   (i:is) = p == i && ma ps is
@@ -163,10 +167,11 @@
 */
 static Bool charIsStar  ( void* pV ) { return *(Char*)pV == '*'; }
 static Bool charIsQuery ( void* pV ) { return *(Char*)pV == '?'; }
+static Bool charIsStop  ( void* pV ) { return *(Char*)pV == '!'; }
 static Bool char_p_EQ_i ( void* pV, void* cV ) {
    Char p = *(Char*)pV;
    Char c = *(Char*)cV;
-   vg_assert(p != '*' && p != '?');
+   vg_assert(p != '*' && p != '?' && p != '!');
    return p == c;
 }
 Bool VG_(string_match) ( const Char* patt, const Char* input )
@@ -175,7 +180,7 @@
              True/* match-all */,
              (void*)patt,  sizeof(UChar), VG_(strlen)(patt), 0,
              (void*)input, sizeof(UChar), VG_(strlen)(input), 0,
-             charIsStar, charIsQuery, char_p_EQ_i
+             charIsStar, charIsQuery, charIsStop, char_p_EQ_i
           );
 }