]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Try to fix error_counts.
authorNicholas Nethercote <njn@valgrind.org>
Mon, 10 Aug 2009 08:25:39 +0000 (08:25 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Mon, 10 Aug 2009 08:25:39 +0000 (08:25 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10768

coregrind/m_errormgr.c
include/pub_tool_errormgr.h
memcheck/mc_errors.c
memcheck/mc_include.h
memcheck/mc_leakcheck.c
memcheck/tests/Makefile.am
memcheck/tests/error_counts.c
memcheck/tests/error_counts.stderr.exp
memcheck/tests/error_counts.stdout.exp [deleted file]

index 51ed7cf90d36ae2e306ad368e73ed8bb38039531..41918357cce03fad73ccca5a8d44b90e50e4fc68 100644 (file)
@@ -737,10 +737,11 @@ void VG_(maybe_record_error) ( ThreadId tid,
    guaranteed to only happen once.  This avoids all the recording and
    comparing stuff.  But they can be suppressed;  returns True if it is
    suppressed.  Bool 'print_error' dictates whether to print the error. 
+   Bool 'count_error' dictates whether to count the error in n_errs_found.
 */
 Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s,
                          void* extra, ExeContext* where, Bool print_error,
-                         Bool allow_db_attach )
+                         Bool allow_db_attach, Bool count_error )
 {
    Error err;
    Supp *su;
@@ -759,7 +760,8 @@ Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s,
 
    su = is_suppressible_error(&err);
    if (NULL == su) {
-      n_errs_found++;
+      if (count_error)
+         n_errs_found++;
 
       if (print_error) {
          /* A bit of prettyprinting, to ensure there's a blank line
index 01c073e9fcaecbdaa5303a925d491abe355daa8b..a473c6b6416cd1b29dee43285883e0e10ed257f9 100644 (file)
@@ -85,7 +85,7 @@ extern void VG_(maybe_record_error) ( ThreadId tid, ErrorKind ekind,
 extern Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind,
                                 Addr a, Char* s, void* extra,
                                 ExeContext* where, Bool print_error,
-                                Bool allow_GDB_attach );
+                                Bool allow_GDB_attach, Bool count_error );
 
 /* Gets a non-blank, non-comment line from fd.  bufpp is a pointer to a
    pointer to a buffer that must be allocated with VG_(malloc);  nBufp is a
index d57e8198853acb69ef858a03326119a9050ee59b..07b42742da2cb683ed0d43abc3a139cad503d8a9 100644 (file)
@@ -942,7 +942,7 @@ void MC_(record_overlap_error) ( ThreadId tid, Char* function,
 
 Bool MC_(record_leak_error) ( ThreadId tid, UInt n_this_record,
                               UInt n_total_records, LossRecord* lr,
-                              Bool print_record )
+                              Bool print_record, Bool count_error )
 {
    MC_Error extra;
    extra.Err.Leak.n_this_record   = n_this_record;
@@ -951,7 +951,7 @@ Bool MC_(record_leak_error) ( ThreadId tid, UInt n_this_record,
    return
    VG_(unique_error) ( tid, Err_Leak, /*Addr*/0, /*s*/NULL, &extra,
                        lr->key.allocated_at, print_record,
-                       /*allow_GDB_attach*/False );
+                       /*allow_GDB_attach*/False, count_error );
 }
 
 void MC_(record_user_error) ( ThreadId tid, Addr a,
index c6ff0c8417c0bc8b4d979715284ec3dcda289983..920378362aa0900a0480033b4e4e6ce75ad25b0f 100644 (file)
@@ -348,7 +348,8 @@ Bool MC_(record_leak_error)     ( ThreadId tid,
                                   UInt n_this_record,
                                   UInt n_total_records,
                                   LossRecord* lossRecord,
-                                  Bool print_record );
+                                  Bool print_record,
+                                  Bool count_error );
 
 /* Is this address in a user-specified "ignored range" ? */
 Bool MC_(in_ignored_range) ( Addr a );
index 723a6e11763e41af7507105af24baf568eaf4905..68b317e1ada878b92c2dda7d5f1d33fdd90bd485 100644 (file)
@@ -828,7 +828,7 @@ static void print_results(ThreadId tid, Bool is_full_check)
 
    // Print the loss records (in size order) and collect summary stats.
    for (i = 0; i < n_lossrecords; i++) {
-      Bool print_record;
+      Bool count_as_error, print_record;
       // Rules for printing:
       // - We don't show suppressed loss records ever (and that's controlled
       //   within the error manager).
@@ -842,12 +842,13 @@ static void print_results(ThreadId tid, Bool is_full_check)
       // includes indirectly lost blocks!
       //
       lr = lr_array[i];
+      count_as_error = Unreached == lr->key.state || 
+                       Possible  == lr->key.state;
       print_record = is_full_check &&
-                     ( MC_(clo_show_reachable) || 
-                       Unreached == lr->key.state || 
-                       Possible  == lr->key.state );
+                     ( MC_(clo_show_reachable) || count_as_error );
       is_suppressed = 
-         MC_(record_leak_error) ( tid, i+1, n_lossrecords, lr, print_record );
+         MC_(record_leak_error) ( tid, i+1, n_lossrecords, lr, print_record,
+                                  count_as_error );
 
       if (is_suppressed) {
          MC_(blocks_suppressed) += lr->num_blocks;
index f8e6e920310764e93a24a24eedafae692c7c190c..14200ad5a6504414db5f1bab69208cb254098f74 100644 (file)
@@ -59,7 +59,7 @@ EXTRA_DIST = \
        describe-block.stderr.exp describe-block.vgtest \
        doublefree.stderr.exp doublefree.vgtest \
        erringfds.stderr.exp erringfds.stdout.exp erringfds.vgtest \
-       error_counts.stderr.exp error_counts.stdout.exp error_counts.vgtest \
+       error_counts.stderr.exp error_counts.vgtest \
        errs1.stderr.exp errs1.vgtest \
        exitprog.stderr.exp exitprog.vgtest \
        execve.stderr.exp execve.vgtest \
index 336be0c65667a40c9d8a98132f282cff35a1e2c6..5268cdbc0de22713536d7d0869c1c22a4d8266bd 100644 (file)
@@ -17,7 +17,7 @@ int main(void)
    assert(sizeof(long) == sizeof(void*));
 
    /* Error counting */
-   printf("errors: %d\n\n", VALGRIND_COUNT_ERRORS);
+   fprintf(stderr, "errors: %d\n\n", VALGRIND_COUNT_ERRORS);
 
    if (x == 0) {
       y++;
@@ -25,16 +25,20 @@ int main(void)
       y--;
    }
 
-   printf("errors: %d\n\n", VALGRIND_COUNT_ERRORS);
+   fprintf(stderr, "errors: %d\n\n", VALGRIND_COUNT_ERRORS);
 
    // Get a baseline, after start-up and also after printf (because Darwin
    // printf allocates memory the first time it's called!)
    GET_INITIAL_LEAK_COUNTS;
 
+   fprintf(stderr, "errors: %d\n\n", VALGRIND_COUNT_ERRORS);
+
    /* Leak checking */
    GET_FINAL_LEAK_COUNTS;
-   PRINT_LEAK_COUNTS(stdout);
-   printf("\n");
+   PRINT_LEAK_COUNTS(stderr);
+   fprintf(stderr, "\n");
+
+   fprintf(stderr, "errors: %d\n\n", VALGRIND_COUNT_ERRORS);
 
    leaked = malloc(77);
    leaked = 0;
@@ -45,10 +49,10 @@ int main(void)
    reachable = malloc(99);
 
    GET_FINAL_LEAK_COUNTS;
-   PRINT_LEAK_COUNTS(stdout);
-   printf("\n");
+   PRINT_LEAK_COUNTS(stderr);
+   fprintf(stderr, "\n");
 
-   printf("errors: %d\n", VALGRIND_COUNT_ERRORS);
+   fprintf(stderr, "errors: %d\n", VALGRIND_COUNT_ERRORS);
 
    return 0;
 }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cb366e964b0df79578b2b7bced8b88bd35ed3790 100644 (file)
@@ -0,0 +1,19 @@
+errors: 0
+
+errors: 1
+
+errors: 1
+
+leaked:       0 bytes in  0 blocks
+dubious:      0 bytes in  0 blocks
+reachable:    0 bytes in  0 blocks
+suppressed:   0 bytes in  0 blocks
+
+errors: 1
+
+leaked:      77 bytes in  1 blocks
+dubious:     88 bytes in  1 blocks
+reachable:   99 bytes in  1 blocks
+suppressed:   0 bytes in  0 blocks
+
+errors: 3
diff --git a/memcheck/tests/error_counts.stdout.exp b/memcheck/tests/error_counts.stdout.exp
deleted file mode 100644 (file)
index 9ad46a1..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-errors: 0
-
-errors: 1
-
-leaked:       0 bytes in  0 blocks
-dubious:      0 bytes in  0 blocks
-reachable:    0 bytes in  0 blocks
-suppressed:   0 bytes in  0 blocks
-
-leaked:      77 bytes in  1 blocks
-dubious:     88 bytes in  1 blocks
-reachable:   99 bytes in  1 blocks
-suppressed:   0 bytes in  0 blocks
-
-errors: 10