If a suppression file contains an error, the lineno reported could be wrong.
Also, give filename and lineno of the used suppressions in -v debugging output.
The fix consists in ensuring that tool specific read_extra function gets
the Int* lineno pointer, together with other VG_(get_line) parameters.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13469
Int count; // The number of times this error has been suppressed.
HChar* sname; // The name by which the suppression is referred to.
+ // Index in VG_(clo_suppressions) giving filename from which suppression
+ // was read, and the lineno in this file where sname was read.
+ Int clo_suppressions_i;
+ Int sname_lineno;
+
// Length of 'callers'
Int n_callers;
// Array of callers, for matching stack traces. First one (name of fn
// blank line before the first shown suppression, if any
if (!any_supp)
VG_(dmsg)("\n");
- VG_(dmsg)("used_suppression: %6d %s\n", su->count, su->sname);
+ VG_(dmsg)("used_suppression: %6d %s %s:%d\n", su->count, su->sname,
+ VG_(clo_suppressions)[su->clo_suppressions_i],
+ su->sname_lineno);
}
any_supp = True;
}
/* Print the contexts in order of increasing error count.
Once an error is shown, we add a huge value to its count to filter it
- out. After having shown all errors, we reset count to the original value. */
+ out.
+ After having shown all errors, we reset count to the original value. */
for (i = 0; i < n_err_contexts; i++) {
n_min = (1 << 30) - 1;
p_min = NULL;
SizeT nBuf = *nBufp;
HChar ch;
Int n, i;
+
+ vg_assert(lineno); // lineno needed to correctly track line numbers.
+
while (True) {
buf[0] = 0;
/* First, read until a non-blank char appears. */
i--; buf[i] = 0;
};
- /* VG_(printf)("The line is '%s'\n", buf); */
+ // VG_(printf)("The line *%p %d is '%s'\n", lineno, *lineno, buf);
/* Ok, we have a line. If a non-comment line, return.
If a comment line, start all over again. */
if (buf[0] != '#') return False;
if (is_location_line(*bufpp))
return True; // Not a extra suppr line
else
- return False; // An suppression extra line
+ return False; // A suppression extra line
}
/* True if s contains no wildcard (?, *) characters. */
return found;
}
-/* Read suppressions from the file specified in VG_(clo_suppressions)
+/* Read suppressions from the file specified in
+ VG_(clo_suppressions)[clo_suppressions_i]
and place them in the suppressions list. If there's any difficulty
doing this, just give up -- there's no point in trying to recover.
*/
-static void load_one_suppressions_file ( const HChar* filename )
+static void load_one_suppressions_file ( Int clo_suppressions_i )
{
+ const HChar* filename = VG_(clo_suppressions)[clo_suppressions_i];
SysRes sres;
Int fd, i, j, lineno = 0;
Bool got_a_location_line_read_by_tool;
if (eof || VG_STREQ(buf, "}")) BOMB("unexpected '}'");
supp->sname = VG_(arena_strdup)(VG_AR_CORE, "errormgr.losf.2", buf);
+ supp->clo_suppressions_i = clo_suppressions_i;
+ supp->sname_lineno = lineno;
eof = get_nbnc_line ( fd, &buf, &nBuf, &lineno );
// from fd till a location line.
if (VG_(needs).tool_errors &&
!VG_TDICT_CALL(tool_read_extra_suppression_info,
- fd, &buf, &nBuf, supp))
+ fd, &buf, &nBuf, &lineno, supp))
{
BOMB("bad or missing extra suppression info");
}
VG_(dmsg)("Reading suppressions file: %s\n",
VG_(clo_suppressions)[i] );
}
- load_one_suppressions_file( VG_(clo_suppressions)[i] );
+ load_one_suppressions_file( i );
}
}
Bool show_TIDs,
UInt (*update) (Error*),
Bool (*recog) (const HChar*, Supp*),
- Bool (*read_extra) (Int, HChar**, SizeT*, Supp*),
+ Bool (*read_extra) (Int, HChar**, SizeT*, Int*, Supp*),
Bool (*matches) (Error*, Supp*),
const HChar* (*name) (Error*),
Bool (*get_xtra_si)(Error*,/*OUT*/HChar*,Int)
Bool tool_show_ThreadIDs_for_errors;
UInt (*tool_update_extra) (Error*);
Bool (*tool_recognised_suppression) (const HChar*, Supp*);
- Bool (*tool_read_extra_suppression_info) (Int, HChar**, SizeT*, Supp*);
+ Bool (*tool_read_extra_suppression_info) (Int, HChar**, SizeT*, Int*,
+ Supp*);
Bool (*tool_error_matches_suppression) (Error*, Supp*);
const HChar* (*tool_get_error_name) (Error*);
Bool (*tool_get_extra_suppression_info) (Error*,/*OUT*/HChar*,Int);
*/
static
Bool drd_read_extra_suppression_info(Int fd, HChar** bufpp,
- SizeT* nBufp, Supp* supp)
+ SizeT* nBufp, Int* lineno, Supp* supp)
{
return True;
}
}
Bool pc_read_extra_suppression_info ( Int fd, HChar** bufpp,
- SizeT* nBufp, Supp* su )
+ SizeT* nBufp, Int* lineno, Supp* su )
{
Bool eof;
if (VG_(get_supp_kind)(su) == XS_SysParam) {
- eof = VG_(get_line) ( fd, bufpp, nBufp, NULL );
+ eof = VG_(get_line) ( fd, bufpp, nBufp, lineno );
if (eof) return False;
VG_(set_supp_string)(su, VG_(strdup)("pc.common.presi.1", *bufpp));
}
UInt pc_update_Error_extra ( Error* err );
Bool pc_is_recognised_suppression ( const HChar* name, Supp *su );
Bool pc_read_extra_suppression_info ( Int fd, HChar** bufpp,
- SizeT* nBufp, Supp* su );
+ SizeT* nBufp, Int* lineno, Supp* su );
Bool pc_error_matches_suppression (Error* err, Supp* su);
const HChar* pc_get_error_name ( Error* err );
Bool pc_get_extra_suppression_info ( Error* err,
}
Bool HG_(read_extra_suppression_info) ( Int fd, HChar** bufpp, SizeT* nBufp,
- Supp* su )
+ Int* lineno, Supp* su )
{
/* do nothing -- no extra suppression info present. Return True to
indicate nothing bad happened. */
UInt HG_(update_extra) ( Error* err );
Bool HG_(recognised_suppression) ( const HChar* name, Supp *su );
Bool HG_(read_extra_suppression_info) ( Int fd, HChar** bufpp, SizeT* nBufp,
- Supp* su );
+ Int* lineno, Supp* su );
Bool HG_(error_matches_suppression) ( Error* err, Supp* su );
const HChar* HG_(get_error_name) ( Error* err );
Bool HG_(get_extra_suppression_info) ( Error* err,
// Read any extra info for this suppression kind. Most likely for filling
// in the `extra' and `string' parts (with VG_(set_supp_{extra, string})())
// of a suppression if necessary. Should return False if a syntax error
- // occurred, True otherwise. bufpp and nBufp are the same as for
- // VG_(get_line).
+ // occurred, True otherwise.
+ // fd, bufpp, nBufp and lineno are the same as for VG_(get_line).
Bool (*read_extra_suppression_info)(Int fd, HChar** bufpp, SizeT* nBufp,
- Supp* su),
+ Int* lineno, Supp* su),
// This should just check the kinds match and maybe some stuff in the
// `string' and `extra' field if appropriate (using VG_(get_supp_*)() to
};
Bool MC_(read_extra_suppression_info) ( Int fd, HChar** bufpp,
- SizeT* nBufp, Supp *su )
+ SizeT* nBufp, Int* lineno, Supp *su )
{
Bool eof;
Int i;
if (VG_(get_supp_kind)(su) == ParamSupp) {
- eof = VG_(get_line) ( fd, bufpp, nBufp, NULL );
+ eof = VG_(get_line) ( fd, bufpp, nBufp, lineno );
if (eof) return False;
VG_(set_supp_string)(su, VG_(strdup)("mc.resi.1", *bufpp));
} else if (VG_(get_supp_kind)(su) == LeakSupp) {
lse = VG_(malloc)("mc.resi.2", sizeof(MC_LeakSuppExtra));
lse->match_leak_kinds = RallS;
VG_(set_supp_extra)(su, lse); // By default, all kinds will match.
- eof = VG_(get_line) ( fd, bufpp, nBufp, NULL );
+ eof = VG_(get_line) ( fd, bufpp, nBufp, lineno );
if (eof) return True; // old LeakSupp style, no match-leak-kinds line.
if (0 == VG_(strncmp)(*bufpp, "match-leak-kinds:", 17)) {
i = 17;
Bool MC_(is_recognised_suppression) ( const HChar* name, Supp* su );
Bool MC_(read_extra_suppression_info) ( Int fd, HChar** buf,
- SizeT* nBuf, Supp *su );
+ SizeT* nBuf, Int* lineno, Supp *su );
Bool MC_(error_matches_suppression) ( Error* err, Supp* su );