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/memcheck/mac_shared.h b/memcheck/mac_shared.h
index babe916..4683a31 100644
--- a/memcheck/mac_shared.h
+++ b/memcheck/mac_shared.h
@@ -266,6 +266,11 @@
 /* Used in describe_addr() */
 extern Bool (*MAC_(describe_addr_supp))    ( Addr a, AddrInfo* ai );
 
+/* For VALGRIND_COUNT_LEAKS client request */
+extern Int MAC_(total_bytes_leaked);
+extern Int MAC_(total_bytes_dubious);
+extern Int MAC_(total_bytes_reachable);
+extern Int MAC_(total_bytes_suppressed);
 
 /*------------------------------------------------------------*/
 /*--- Functions                                            ---*/
@@ -293,6 +298,9 @@
 extern void MAC_(common_pre_clo_init) ( void );
 extern void MAC_(common_fini)         ( void (*leak_check)(void) );
 
+extern Bool MAC_(handle_common_client_requests) 
+                  ( ThreadState* tst, UInt* arg_block, UInt* ret );
+
 extern void MAC_(print_malloc_stats) ( void );
 
 /* For leak checking */