Added two client requests: VALGRIND_COUNT_ERRORS and VALGRIND_COUNT_LEAKS.
The first returns the number of errors found so far, and is a core request.
The second returns the number of bytes found
reachable/dubious/leaked/suppressed by all leak checks so far, for Memcheck and
Addrcheck.

Both are useful for using Valgrind in regression test suites where multiple
tests are present in a single file -- one can run Valgrind with no output
(using --logfile-fd=-1) and use the requests after each test to determine if
any errors happened.

Had to rename and make public vg_n_errs_found --> VG_(n_errs_found) to do so.
Nb: leak errors are not counted as errors for the purposes of
VALGRIND_COUNT_ERRORS.  This was decided as the best thing to do after
discussion with Olly Betts, who original suggested these changes.

Pulled out common client request code shared between Memcheck and Addrcheck.

Added a regression test for this.

Added some documentation too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1533 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/addrcheck/ac_main.c b/addrcheck/ac_main.c
index dfa1e8f..2df76da 100644
--- a/addrcheck/ac_main.c
+++ b/addrcheck/ac_main.c
@@ -1082,9 +1082,10 @@
    return True;
 }
       
-/* 
-   Client requests
- */
+/*------------------------------------------------------------*/
+/*--- Client requests                                      ---*/
+/*------------------------------------------------------------*/
+
 Bool SK_(handle_client_request) ( ThreadState* tst, UInt* arg_block, UInt *ret )
 {
 #define IGNORE(what)                                                    \
@@ -1131,10 +1132,14 @@
          return False;
 
       default:
-         VG_(message)(Vg_UserMsg, 
-                      "Warning: unknown addrcheck client request code %d",
-                      arg[0]);
-         return False;
+         if (MAC_(handle_common_client_requests)(tst, arg_block, ret )) {
+            return True;
+         } else {
+            VG_(message)(Vg_UserMsg, 
+                         "Warning: unknown addrcheck client request code %d",
+                         arg[0]);
+            return False;
+         }
    }
    return True;