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 ); }