]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
fix incorrect lineno in supp error msgs+ -v give filename+lineno of used supp.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 22 Jul 2013 22:00:13 +0000 (22:00 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 22 Jul 2013 22:00:13 +0000 (22:00 +0000)
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

coregrind/m_errormgr.c
coregrind/m_tooliface.c
coregrind/pub_core_tooliface.h
drd/drd_error.c
exp-sgcheck/pc_common.c
exp-sgcheck/pc_common.h
helgrind/hg_errors.c
helgrind/hg_errors.h
include/pub_tool_tooliface.h
memcheck/mc_errors.c
memcheck/mc_include.h

index 0e99234b6872bf213819736158a03b0dacb5fc86..1374cd421d23cd72bbf0afb59ebe3dbcf929b6dd 100644 (file)
@@ -226,6 +226,11 @@ struct _Supp {
    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
@@ -902,7 +907,9 @@ static Bool show_used_suppressions ( void )
          // 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;
    }
@@ -944,7 +951,8 @@ void VG_(show_all_errors) (  Int verbosity, Bool xml )
 
    /* 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;
@@ -1066,6 +1074,9 @@ static Bool get_nbnc_line ( Int fd, HChar** bufpp, SizeT* nBufp, Int* lineno )
    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. */
@@ -1100,7 +1111,7 @@ static Bool get_nbnc_line ( Int fd, HChar** bufpp, SizeT* nBufp, Int* lineno )
          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;
@@ -1125,7 +1136,7 @@ Bool VG_(get_line) ( Int fd, HChar** bufpp, SizeT* nBufp, Int* lineno )
    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. */
@@ -1191,12 +1202,14 @@ static Bool tool_name_present(const HChar *name, HChar *names)
    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;
@@ -1257,6 +1270,8 @@ static void load_one_suppressions_file ( const HChar* filename )
       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 );
 
@@ -1311,7 +1326,7 @@ static void load_one_suppressions_file ( const HChar* filename )
       // 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");
       }
@@ -1408,7 +1423,7 @@ void VG_(load_suppressions) ( void )
          VG_(dmsg)("Reading suppressions file: %s\n", 
                    VG_(clo_suppressions)[i] );
       }
-      load_one_suppressions_file( VG_(clo_suppressions)[i] );
+      load_one_suppressions_file( i );
    }
 }
 
index ac2af3667662fafe15bd280ca25abbfcb09b2e18..bcf825530dc35ad6a5dfb6db1cd36c98a3cbdcff 100644 (file)
@@ -231,7 +231,7 @@ void VG_(needs_tool_errors)(
    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)
index 056d173535133d017d4e52bea6af05fb7160b761..0946bff3dea79413c07e92cf6263d2b13fc6c4c7 100644 (file)
@@ -122,7 +122,8 @@ typedef struct {
    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);
index cf1944dc5fca37e2b1f4e5e20a57580f600e56a2..bf1353a731aa4318ed24a5d7407ebfc38b0f12fb 100644 (file)
@@ -556,7 +556,7 @@ static Bool drd_is_recognized_suppression(const HChar* const name,
  */
 static
 Bool drd_read_extra_suppression_info(Int fd, HChar** bufpp,
-                                     SizeT* nBufp, Supp* supp)
+                                     SizeT* nBufp, Int* lineno, Supp* supp)
 {
    return True;
 }
index d4c5bc94d2f6f16029eacb3f3663973e8d246f5c..f7b8006e1b2c0cc8b019447171e2243e33df6d87 100644 (file)
@@ -736,11 +736,11 @@ 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 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));
    }
index c547a235fb4aa698a0650a00d36779a6940467e7..418f8b48a6e8c552d90dace700667715cf6d6466 100644 (file)
@@ -53,7 +53,7 @@ void pc_pp_Error           ( Error* err );
 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,
index d218024fd35623d35d052b2144718bde6bc20ed2..ffa31025cbc027b0f38771c55b137fc7442ca0f0 100644 (file)
@@ -1367,7 +1367,7 @@ 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 )
 {
    /* do nothing -- no extra suppression info present.  Return True to
       indicate nothing bad happened. */
index 79c6fb536ed825027530d9f8709d315476985cdd..03d88c19fcb0b5ffd49e658df6243a7b8ff6fd4c 100644 (file)
@@ -41,7 +41,7 @@ void  HG_(pp_Error)        ( Error* err );
 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,
index 2dd38f3849595e9cf3285570786a238d69a47054..3d43be8a54410c7622037187ba772d2abeeb5ddd 100644 (file)
@@ -318,10 +318,10 @@ extern void VG_(needs_tool_errors) (
    // 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
index 62cc0b73a8c76d4010f40715e0b37d54beec7a09..b9aa00a39edb11210c7f3d61a0491d9b3d692c4d 100644 (file)
@@ -1535,13 +1535,13 @@ struct _MC_LeakSuppExtra {
 };
 
 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) {
@@ -1550,7 +1550,7 @@ Bool MC_(read_extra_suppression_info) ( Int fd, HChar** bufpp,
       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;
index 29a09688ba406f735621eecd448abb9c8655fc8a..a658c7cfe82214d8b2021fbba13f0fd0b62412d3 100644 (file)
@@ -397,7 +397,7 @@ UInt MC_(update_Error_extra) ( Error* err );
 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 );