Reinstate Addrcheck. Some of the tests fail -- some of the leak ones
because the added VG_(find_root_memory)() is just a stub. And there's a
problem with overlap checking that I haven't worked out yet. Still it's a
start. The commit also brings Memcheck back into the build process,
although mc_main.c is entirely commented out at the moment.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3352 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/memcheck/Makefile.am b/memcheck/Makefile.am
index 66cab64..7624d7e 100644
--- a/memcheck/Makefile.am
+++ b/memcheck/Makefile.am
@@ -17,9 +17,8 @@
mac_leakcheck.c \
mac_malloc_wrappers.c \
mac_needs.c \
- mc_main.c \
mc_errcontext.c \
- mc_from_ucode.c \
+ mc_main.c \
mc_translate.c
vgtool_memcheck_so_LDFLAGS = -shared
diff --git a/memcheck/mac_malloc_wrappers.c b/memcheck/mac_malloc_wrappers.c
index cb84181..7250353 100644
--- a/memcheck/mac_malloc_wrappers.c
+++ b/memcheck/mac_malloc_wrappers.c
@@ -526,6 +526,49 @@
die_and_free_mem ( tid, mc, prev_chunk, mp->rzB );
}
+/*------------------------------------------------------------*/
+/*--- Statistics printing ---*/
+/*------------------------------------------------------------*/
+
+typedef
+ struct {
+ UInt nblocks;
+ SizeT nbytes;
+ }
+ MallocStats;
+
+static void malloc_stats_count_chunk(VgHashNode* node, void* d) {
+ MAC_Chunk* mc = (MAC_Chunk*)node;
+ MallocStats *ms = (MallocStats *)d;
+
+ ms->nblocks ++;
+ ms->nbytes += mc->size;
+}
+
+void MAC_(print_malloc_stats) ( void )
+{
+ MallocStats ms;
+
+ ms.nblocks = 0;
+ ms.nbytes = 0;
+
+ if (VG_(clo_verbosity) == 0)
+ return;
+
+ /* Count memory still in use. */
+ VG_(HT_apply_to_all_nodes)(MAC_(malloc_list), malloc_stats_count_chunk, &ms);
+
+ VG_(message)(Vg_UserMsg,
+ "malloc/free: in use at exit: %d bytes in %d blocks.",
+ ms.nbytes, ms.nblocks);
+ VG_(message)(Vg_UserMsg,
+ "malloc/free: %d allocs, %d frees, %u bytes allocated.",
+ cmalloc_n_mallocs,
+ cmalloc_n_frees, cmalloc_bs_mallocd);
+ if (VG_(clo_verbosity) > 1)
+ VG_(message)(Vg_UserMsg, "");
+}
+
/*--------------------------------------------------------------------*/
-/*--- end mac_malloc_wrappers.c ---*/
+/*--- end ---*/
/*--------------------------------------------------------------------*/
diff --git a/memcheck/mac_needs.c b/memcheck/mac_needs.c
index 745d03f..28a828e 100644
--- a/memcheck/mac_needs.c
+++ b/memcheck/mac_needs.c
@@ -829,50 +829,6 @@
#endif
/*------------------------------------------------------------*/
-/*--- Statistics printing ---*/
-/*------------------------------------------------------------*/
-
-typedef
- struct {
- UInt nblocks;
- SizeT nbytes;
- }
- MallocStats;
-
-static void malloc_stats_count_chunk(VgHashNode* node, void* d) {
- MAC_Chunk* mc = (MAC_Chunk*)node;
- MallocStats *ms = (MallocStats *)d;
-
- ms->nblocks ++;
- ms->nbytes += mc->size;
-}
-
-static void print_malloc_stats ( void )
-{
- MallocStats ms;
-
- ms.nblocks = 0;
- ms.nbytes = 0;
-
- /* Mmm... more lexical scoping */
- if (VG_(clo_verbosity) == 0)
- return;
-
- /* Count memory still in use. */
- VG_(HT_apply_to_all_nodes)(MAC_(malloc_list), malloc_stats_count_chunk, &ms);
-
- VG_(message)(Vg_UserMsg,
- "malloc/free: in use at exit: %d bytes in %d blocks.",
- ms.nbytes, ms.nblocks);
- VG_(message)(Vg_UserMsg,
- "malloc/free: %d allocs, %d frees, %u bytes allocated.",
- cmalloc_n_mallocs,
- cmalloc_n_frees, cmalloc_bs_mallocd);
- if (VG_(clo_verbosity) > 1)
- VG_(message)(Vg_UserMsg, "");
-}
-
-/*------------------------------------------------------------*/
/*--- Common initialisation + finalisation ---*/
/*------------------------------------------------------------*/
@@ -885,7 +841,7 @@
void MAC_(common_fini)(void (*leak_check)(LeakCheckMode mode))
{
- print_malloc_stats();
+ MAC_(print_malloc_stats)();
if (VG_(clo_verbosity) == 1) {
if (MAC_(clo_leak_check) == LC_Off)
diff --git a/memcheck/mac_replace_strmem.c b/memcheck/mac_replace_strmem.c
index 6c8b71d..0e4012f 100644
--- a/memcheck/mac_replace_strmem.c
+++ b/memcheck/mac_replace_strmem.c
@@ -352,7 +352,7 @@
return dst;
}
-void *memset(void *s, int c, size_t n)
+void *memset(void *s, Int c, SizeT n)
{
unsigned char *cp = s;
diff --git a/memcheck/mac_shared.h b/memcheck/mac_shared.h
index 2f6ad58..3b83b10 100644
--- a/memcheck/mac_shared.h
+++ b/memcheck/mac_shared.h
@@ -374,6 +374,8 @@
extern void MAC_(pp_LeakError)(void* vl, UInt n_this_record,
UInt n_total_records);
+extern void MAC_(print_malloc_stats) ( void );
+
extern void MAC_(do_detect_memory_leaks) (
LeakCheckMode mode,
Bool (*is_valid_64k_chunk) ( UInt ),
diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c
index c4cef5b..c101175 100644
--- a/memcheck/mc_main.c
+++ b/memcheck/mc_main.c
@@ -88,7 +88,7 @@
misaligned address.
*/
-
+#if 0
/*------------------------------------------------------------*/
/*--- Function declarations. ---*/
/*------------------------------------------------------------*/
@@ -1891,6 +1891,7 @@
}
VG_DETERMINE_INTERFACE_VERSION(TL_(pre_clo_init), 9./8)
+#endif
/*--------------------------------------------------------------------*/
/*--- end mc_main.c ---*/