]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fixed a bug in the code for reading suppression files: the line numbers
authorBart Van Assche <bvanassche@acm.org>
Mon, 27 Jul 2009 12:03:03 +0000 (12:03 +0000)
committerBart Van Assche <bvanassche@acm.org>
Mon, 27 Jul 2009 12:03:03 +0000 (12:03 +0000)
reported in error messages were not correct. As an example, the following
output was produced before this patch (not correct):
$ ./vg-in-place --tool=helgrind --num-callers=1 /bin/true
...
FATAL: in suppressions file ".in_place/default.supp" near line 893:
   suppression must contain at least one location line which is not "..."
exiting now.
$ ./vg-in-place --tool=drd --num-callers=1 /bin/true
FATAL: in suppressions file ".in_place/default.supp" near line 475:
   suppression must contain at least one location line which is not "..."
exiting now.

After having applied this patch the above commands display line numbers
1104 and 619, referring to the first suppression pattern containing
three dots for the topmost stack frame, as expected.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10632

coregrind/m_errormgr.c
exp-ptrcheck/pc_common.c
include/pub_tool_errormgr.h
memcheck/mc_errors.c

index cf0b8dff14e6d9f803ed3aac1d78a6f08c52b5f3..a92609ad38ee68d1cd98778effecdf42a495996c 100644 (file)
@@ -964,7 +964,7 @@ static Int get_char ( Int fd, Char* out_buf )
    return 1;
 }
 
-Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp )
+Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp, Int* lineno )
 {
    Char* buf  = *bufpp;
    SizeT nBuf = *nBufp;
@@ -975,6 +975,8 @@ Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp )
       while (True) {
          n = get_char(fd, &ch);
          if (n == 1 && !VG_(isspace)(ch)) break;
+         if (n == 1 && ch == '\n' && lineno)
+            (*lineno)++;
          if (n <= 0) return True;
       }
 
@@ -984,6 +986,8 @@ Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp )
       while (True) {
          n = get_char(fd, &ch);
          if (n <= 0) return False; /* the next call will return True */
+         if (ch == '\n' && lineno)
+            (*lineno)++;
          if (ch == '\n') break;
          if (i > 0 && i == nBuf-1) {
             *nBufp = nBuf = nBuf * 2;
@@ -1103,21 +1107,18 @@ static void load_one_suppressions_file ( Char* filename )
 
       supp->string = supp->extra = NULL;
 
-      eof = VG_(get_line) ( fd, &buf, &nBuf );
-      lineno++;
+      eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
       if (eof) break;
 
       if (!VG_STREQ(buf, "{")) BOMB("expected '{' or end-of-file");
       
-      eof = VG_(get_line) ( fd, &buf, &nBuf );
-      lineno++;
+      eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
 
       if (eof || VG_STREQ(buf, "}")) BOMB("unexpected '}'");
 
       supp->sname = VG_(arena_strdup)(VG_AR_CORE, "errormgr.losf.2", buf);
 
-      eof = VG_(get_line) ( fd, &buf, &nBuf );
-      lineno++;
+      eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
 
       if (eof) BOMB("unexpected end-of-file");
 
@@ -1155,8 +1156,7 @@ static void load_one_suppressions_file ( Char* filename )
       else {
          // Ignore rest of suppression
          while (True) {
-            eof = VG_(get_line) ( fd, &buf, &nBuf );
-            lineno++;
+            eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
             if (eof) BOMB("unexpected end-of-file");
             if (VG_STREQ(buf, "}"))
                break;
@@ -1174,8 +1174,7 @@ static void load_one_suppressions_file ( Char* filename )
       /* the main frame-descriptor reading loop */
       i = 0;
       while (True) {
-         eof = VG_(get_line) ( fd, &buf, &nBuf );
-         lineno++;
+         eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
          if (eof)
             BOMB("unexpected end-of-file");
          if (VG_STREQ(buf, "}")) {
@@ -1201,8 +1200,7 @@ static void load_one_suppressions_file ( Char* filename )
       // lines and grab the '}'.
       if (!VG_STREQ(buf, "}")) {
          do {
-            eof = VG_(get_line) ( fd, &buf, &nBuf );
-            lineno++;
+            eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
          } while (!eof && !VG_STREQ(buf, "}"));
       }
 
index 365ffe95d162eb2ab770cda528984d67cc9e634f..4b6298b82bf352aa9f9fe2b8e1448cdb5bba3259 100644 (file)
@@ -741,7 +741,7 @@ Bool pc_read_extra_suppression_info ( Int fd, Char** bufpp,
 {
    Bool eof;
    if (VG_(get_supp_kind)(su) == XS_SysParam) {
-      eof = VG_(get_line) ( fd, bufpp, nBufp );
+      eof = VG_(get_line) ( fd, bufpp, nBufp, NULL );
       if (eof) return False;
       VG_(set_supp_string)(su, VG_(strdup)("pc.common.presi.1", *bufpp));
    }
index 8369cf12997c74e877f633424d64d5b5da01e4eb..a473c6b6416cd1b29dee43285883e0e10ed257f9 100644 (file)
@@ -92,8 +92,9 @@ extern Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind,
    pointer to size_t holding its size;  if the buffer is too small for the
    line, it will be realloc'd until big enough (updating *bufpp and *nBufp in
    the process).  (It will bomb out if the size gets ridiculous).  Skips
-   leading spaces on the line.  Returns True if EOF was hit instead.  */
-extern Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp );
+   leading spaces on the line.  Increments lineno with the number of lines
+   read if lineno is non-NULL. Returns True if EOF was hit.  */
+extern Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp, Int* lineno );
 
 
 /* ------------------------------------------------------------------ */
index 4e88f7988920c97df4d2e873ad643944fb217943..0d54a1008be3d8c4395cc8b5575dbbf860914fed 100644 (file)
@@ -1390,7 +1390,7 @@ Bool MC_(read_extra_suppression_info) ( Int fd, Char** bufpp,
    Bool eof;
 
    if (VG_(get_supp_kind)(su) == ParamSupp) {
-      eof = VG_(get_line) ( fd, bufpp, nBufp );
+      eof = VG_(get_line) ( fd, bufpp, nBufp, NULL );
       if (eof) return False;
       VG_(set_supp_string)(su, VG_(strdup)("mc.resi.1", *bufpp));
    }