|
From: <sv...@va...> - 2005-12-07 00:36:54
|
Author: njn
Date: 2005-12-07 00:36:51 +0000 (Wed, 07 Dec 2005)
New Revision: 5308
Log:
Started folding in code from mac_shared.c and mac_shared.h into mc_main.c
and mc_include.h, as a consequence of removing Addrcheck.
Removed:
branches/COMPVBITS/memcheck/mac_shared.h
Modified:
branches/COMPVBITS/memcheck/Makefile.am
branches/COMPVBITS/memcheck/mac_leakcheck.c
branches/COMPVBITS/memcheck/mac_malloc_wrappers.c
branches/COMPVBITS/memcheck/mac_shared.c
branches/COMPVBITS/memcheck/mc_include.h
branches/COMPVBITS/memcheck/mc_main.c
branches/COMPVBITS/memcheck/mc_translate.c
Modified: branches/COMPVBITS/memcheck/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/COMPVBITS/memcheck/Makefile.am 2005-12-07 00:04:22 UTC (rev =
5307)
+++ branches/COMPVBITS/memcheck/Makefile.am 2005-12-07 00:36:51 UTC (rev =
5308)
@@ -77,7 +77,6 @@
memcheck.h
=20
noinst_HEADERS =3D \
- mac_shared.h \
mc_include.h
=20
mac_replace_strmem.o: CFLAGS +=3D -fno-omit-frame-pointer
Modified: branches/COMPVBITS/memcheck/mac_leakcheck.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/COMPVBITS/memcheck/mac_leakcheck.c 2005-12-07 00:04:22 UTC (=
rev 5307)
+++ branches/COMPVBITS/memcheck/mac_leakcheck.c 2005-12-07 00:36:51 UTC (=
rev 5308)
@@ -32,9 +32,9 @@
=20
#include "pub_tool_basics.h"
#include "pub_tool_aspacemgr.h"
-#include "pub_tool_errormgr.h" // For mac_shared.h
-#include "pub_tool_execontext.h" // For mac_shared.h
-#include "pub_tool_hashtable.h" // For mac_shared.h
+#include "pub_tool_errormgr.h" // For mc_include.h
+#include "pub_tool_execontext.h" // For mc_include.h
+#include "pub_tool_hashtable.h" // For mc_include.h
#include "pub_tool_libcbase.h"
#include "pub_tool_libcassert.h"
#include "pub_tool_libcprint.h"
@@ -42,10 +42,10 @@
#include "pub_tool_machine.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_options.h"
-#include "pub_tool_profile.h" // For mac_shared.h
+#include "pub_tool_profile.h" // For mc_include.h
#include "pub_tool_signals.h"
=20
-#include "mac_shared.h"
+#include "mc_include.h"
=20
#include <setjmp.h> // For jmp_buf
=20
@@ -551,7 +551,7 @@
=20
for (p =3D errlist; p !=3D NULL; p =3D p->next) {
if (p->loss_mode =3D=3D lc_markstack[i].state
- && VG_(eq_ExeContext) ( MAC_(clo_leak_resolution),
+ && VG_(eq_ExeContext) ( MC_(clo_leak_resolution),
p->allocated_at,=20
where) ) {
break;
@@ -593,7 +593,7 @@
Prints the error if not suppressed, unless it's reachable (Prop=
er
or IndirectLeak) and --show-reachable=3Dno */
=20
- print_record =3D ( MAC_(clo_show_reachable) ||=20
+ print_record =3D ( MC_(clo_show_reachable) ||=20
Unreached =3D=3D p_min->loss_mode ||=20
Interior =3D=3D p_min->loss_mode );
=20
@@ -804,7 +804,7 @@
if (mode =3D=3D LC_Summary && blocks_leaked > 0)
VG_(message)(Vg_UserMsg,
"Use --leak-check=3Dfull to see details of leaked memory.");
- else if (!MAC_(clo_show_reachable)) {
+ else if (!MC_(clo_show_reachable)) {
VG_(message)(Vg_UserMsg,=20
"Reachable blocks (those to which a pointer was found) are no=
t shown.");
VG_(message)(Vg_UserMsg,=20
Modified: branches/COMPVBITS/memcheck/mac_malloc_wrappers.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/COMPVBITS/memcheck/mac_malloc_wrappers.c 2005-12-07 00:04:22=
UTC (rev 5307)
+++ branches/COMPVBITS/memcheck/mac_malloc_wrappers.c 2005-12-07 00:36:51=
UTC (rev 5308)
@@ -31,18 +31,18 @@
*/
=20
#include "pub_tool_basics.h"
-#include "pub_tool_errormgr.h" // For mac_shared.h
-#include "pub_tool_execontext.h" // For mac_shared.h
-#include "pub_tool_hashtable.h" // For mac_shared.h
+#include "pub_tool_errormgr.h" // For mc_include.h
+#include "pub_tool_execontext.h" // For mc_include.h
+#include "pub_tool_hashtable.h" // For mc_include.h
#include "pub_tool_libcbase.h"
#include "pub_tool_libcassert.h"
#include "pub_tool_libcprint.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_options.h"
-#include "pub_tool_profile.h" // For mac_shared.h
+#include "pub_tool_profile.h" // For mc_include.h
#include "pub_tool_replacemalloc.h"
#include "pub_tool_threadstate.h"
-#include "mac_shared.h"
+#include "mc_include.h"
=20
/*------------------------------------------------------------*/
/*--- Defns ---*/
@@ -98,7 +98,7 @@
/* Release enough of the oldest blocks to bring the free queue
volume below vg_clo_freelist_vol. */
=20
- while (freed_list_volume > MAC_(clo_freelist_vol)) {
+ while (freed_list_volume > MC_(clo_freelist_vol)) {
MAC_Chunk* mc1;
=20
tl_assert(freed_list_start !=3D NULL);
Modified: branches/COMPVBITS/memcheck/mac_shared.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/COMPVBITS/memcheck/mac_shared.c 2005-12-07 00:04:22 UTC (rev=
5307)
+++ branches/COMPVBITS/memcheck/mac_shared.c 2005-12-07 00:36:51 UTC (rev=
5308)
@@ -6,8 +6,7 @@
=20
/*
This file is part of MemCheck, a heavyweight Valgrind tool for
- detecting memory errors, and AddrCheck, a lightweight Valgrind tool=20
- for detecting memory errors.
+ detecting memory errors.
=20
Copyright (C) 2000-2005 Julian Seward=20
js...@ac...
@@ -31,19 +30,19 @@
*/
=20
#include "pub_tool_basics.h"
-#include "pub_tool_errormgr.h" // For mac_shared.h
-#include "pub_tool_execontext.h" // For mac_shared.h
-#include "pub_tool_hashtable.h" // For mac_shared.h
+#include "pub_tool_errormgr.h" // For mc_include.h
+#include "pub_tool_execontext.h" // For mc_include.h
+#include "pub_tool_hashtable.h" // For mc_include.h
#include "pub_tool_libcassert.h"
#include "pub_tool_libcbase.h"
#include "pub_tool_libcprint.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_machine.h"
#include "pub_tool_options.h"
-#include "pub_tool_profile.h" // For mac_shared.h
+#include "pub_tool_profile.h" // For mc_include.h
#include "pub_tool_replacemalloc.h"
#include "pub_tool_threadstate.h"
-#include "mac_shared.h"
+#include "mc_include.h"
#include "memcheck.h" /* for VG_USERREQ__* */
=20
/*------------------------------------------------------------*/
@@ -55,68 +54,6 @@
#define VG_GCC296_BUG_STACK_SLOP 1024
=20
/*------------------------------------------------------------*/
-/*--- Command line options ---*/
-/*------------------------------------------------------------*/
-
-Bool MAC_(clo_partial_loads_ok) =3D False;
-Int MAC_(clo_freelist_vol) =3D 5000000;
-LeakCheckMode MAC_(clo_leak_check) =3D LC_Summary;
-VgRes MAC_(clo_leak_resolution) =3D Vg_LowRes;
-Bool MAC_(clo_show_reachable) =3D False;
-Bool MAC_(clo_workaround_gcc296_bugs) =3D False;
-Bool MAC_(clo_undef_value_errors) =3D True;
-
-Bool MAC_(process_common_cmd_line_option)(Char* arg)
-{
- VG_BOOL_CLO(arg, "--partial-loads-ok", MAC_(clo_partial_loads_ok))
- else VG_BOOL_CLO(arg, "--show-reachable", MAC_(clo_show_reacha=
ble))
- else VG_BOOL_CLO(arg, "--workaround-gcc296-bugs",MAC_(clo_workaround_=
gcc296_bugs))
-
- else VG_BOOL_CLO(arg, "--undef-value-errors", MAC_(clo_undef_value=
_errors))
- =20
- else VG_BNUM_CLO(arg, "--freelist-vol", MAC_(clo_freelist_vol), 0, 1=
000000000)
- =20
- else if (VG_CLO_STREQ(arg, "--leak-check=3Dno"))
- MAC_(clo_leak_check) =3D LC_Off;
- else if (VG_CLO_STREQ(arg, "--leak-check=3Dsummary"))
- MAC_(clo_leak_check) =3D LC_Summary;
- else if (VG_CLO_STREQ(arg, "--leak-check=3Dyes") ||
- VG_CLO_STREQ(arg, "--leak-check=3Dfull"))
- MAC_(clo_leak_check) =3D LC_Full;
-
- else if (VG_CLO_STREQ(arg, "--leak-resolution=3Dlow"))
- MAC_(clo_leak_resolution) =3D Vg_LowRes;
- else if (VG_CLO_STREQ(arg, "--leak-resolution=3Dmed"))
- MAC_(clo_leak_resolution) =3D Vg_MedRes;
- else if (VG_CLO_STREQ(arg, "--leak-resolution=3Dhigh"))
- MAC_(clo_leak_resolution) =3D Vg_HighRes;
-
- else
- return VG_(replacement_malloc_process_cmd_line_option)(arg);
-
- return True;
-}
-
-void MAC_(print_common_usage)(void)
-{
- VG_(printf)(
-" --leak-check=3Dno|summary|full search for memory leaks at exit?=
[summary]\n"
-" --leak-resolution=3Dlow|med|high how much bt merging in leak chec=
k [low]\n"
-" --show-reachable=3Dno|yes show reachable blocks in leak ch=
eck? [no]\n"
-" --undef-value-errors=3Dno|yes check for undefined value errors=
[yes]\n"
-" --partial-loads-ok=3Dno|yes too hard to explain here; see ma=
nual [no]\n"
-" --freelist-vol=3D<number> volume of freed blocks queue [50=
00000]\n"
-" --workaround-gcc296-bugs=3Dno|yes self explanatory [no]\n"
- );
- VG_(replacement_malloc_print_usage)();
-}
-
-void MAC_(print_common_debug_usage)(void)
-{
- VG_(replacement_malloc_print_debug_usage)();
-}
-
-/*------------------------------------------------------------*/
/*--- Comparing and printing errors ---*/
/*------------------------------------------------------------*/
=20
@@ -303,109 +240,6 @@
}
}
=20
-/* This prints out the message for the error types where Memcheck and
- Addrcheck have identical messages */
-void MAC_(pp_shared_Error) ( Error* err )
-{
- MAC_Error* err_extra =3D VG_(get_error_extra)(err);
-
- HChar* xpre =3D VG_(clo_xml) ? " <what>" : "";
- HChar* xpost =3D VG_(clo_xml) ? "</what>" : "";
-
- switch (VG_(get_error_kind)(err)) {
- case FreeErr:
- if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " <kind>InvalidFree</kind>");
- VG_(message)(Vg_UserMsg,=20
- "%sInvalid free() / delete / delete[]%s",
- xpre, xpost);
- VG_(pp_ExeContext)( VG_(get_error_where)(err) );
- MAC_(pp_AddrInfo)(VG_(get_error_address)(err), &err_extra->addr=
info);
- break;
-
- case FreeMismatchErr:
- if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " <kind>MismatchedFree</kind>");
- VG_(message)(Vg_UserMsg,=20
- "%sMismatched free() / delete / delete []%s",
- xpre, xpost);
- VG_(pp_ExeContext)( VG_(get_error_where)(err) );
- MAC_(pp_AddrInfo)(VG_(get_error_address)(err), &err_extra->addr=
info);
- break;
-
- case AddrErr:
- switch (err_extra->axskind) {
- case ReadAxs:
- if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " <kind>InvalidRead</kind>")=
;
- VG_(message)(Vg_UserMsg,
- "%sInvalid read of size %d%s",=20
- xpre, err_extra->size, xpost );=20
- break;
- case WriteAxs:
- if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " <kind>InvalidWrite</kind>"=
);
- VG_(message)(Vg_UserMsg,=20
- "%sInvalid write of size %d%s",=20
- xpre, err_extra->size, xpost );=20
- break;
- case ExecAxs:
- if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " <kind>InvalidJump</kind>")=
;
- VG_(message)(Vg_UserMsg,=20
- "%sJump to the invalid address "
- "stated on the next line%s",
- xpre, xpost);
- break;
- default:=20
- VG_(tool_panic)("MAC_(pp_shared_Error)(axskind)");
- }
- VG_(pp_ExeContext)( VG_(get_error_where)(err) );
- MAC_(pp_AddrInfo)(VG_(get_error_address)(err), &err_extra->addr=
info);
- break;
-
- case OverlapErr: {
- OverlapExtra* ov_extra =3D (OverlapExtra*)VG_(get_error_extra)(=
err);
- if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " <kind>Overlap</kind>");
- if (ov_extra->len =3D=3D -1)
- VG_(message)(Vg_UserMsg,
- "%sSource and destination overlap in %s(%p, %p)=
%s",
- xpre,
- VG_(get_error_string)(err),
- ov_extra->dst, ov_extra->src,
- xpost);
- else
- VG_(message)(Vg_UserMsg,
- "%sSource and destination overlap in %s(%p, %p,=
%d)%s",
- xpre,
- VG_(get_error_string)(err),
- ov_extra->dst, ov_extra->src, ov_extra->len,
- xpost);
- VG_(pp_ExeContext)( VG_(get_error_where)(err) );
- break;
- }
- case LeakErr: {
- MAC_(pp_LeakError)(err_extra);
- break;
- }
-
- case IllegalMempoolErr:
- if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " <kind>InvalidMemPool</kind>");
- VG_(message)(Vg_UserMsg, "%sIllegal memory pool address%s",
- xpre, xpost);
- VG_(pp_ExeContext)( VG_(get_error_where)(err) );
- MAC_(pp_AddrInfo)(VG_(get_error_address)(err), &err_extra->addr=
info);
- break;
-
- default:=20
- VG_(printf)("Error:\n unknown Memcheck/Addrcheck error code %d=
\n",
- VG_(get_error_kind)(err));
- VG_(tool_panic)("unknown error code in MAC_(pp_shared_Error)");
- }
-}
-
/*------------------------------------------------------------*/
/*--- Recording errors ---*/
/*------------------------------------------------------------*/
@@ -499,7 +333,7 @@
=20
/* If this is caused by an access immediately below %ESP, and the
user asks nicely, we just ignore it. */
- if (MAC_(clo_workaround_gcc296_bugs) && just_below_esp)
+ if (MC_(clo_workaround_gcc296_bugs) && just_below_esp)
return;
=20
MAC_(clear_MAC_Error)( &err_extra );
@@ -792,259 +626,6 @@
}
}
=20
-/*------------------------------------------------------------*/
-/*--- Crude profiling machinery. ---*/
-/*------------------------------------------------------------*/
-
-/* Event index. If just the name of the fn is given, this means the
- number of calls to the fn. Otherwise it is the specified event.
- Ones marked 'M' are MemCheck only. Ones marked 'A' are AddrCheck onl=
y.
- The rest are shared.
-
- 10 alloc_secondary_map
-
- 20 get_abit
-M 21 get_vbyte
- 22 set_abit
-M 23 set_vbyte
- 24 get_abits4_ALIGNED
-M 25 get_vbytes4_ALIGNED =20
-
- 30 set_address_range_perms
- 31 set_address_range_perms(lower byte loop)
- 32 set_address_range_perms(quadword loop)
- 33 set_address_range_perms(upper byte loop)
- =20
- 35 make_noaccess
- 36 make_writable
- 37 make_readable
-A 38 make_accessible
-
- 40 copy_address_range_state
- 41 copy_address_range_state(byte loop)
- 42 check_writable
- 43 check_writable(byte loop)
- 44 check_readable
- 45 check_readable(byte loop)
- 46 check_readable_asciiz
- 47 check_readable_asciiz(byte loop)
-A 48 check_accessible
-A 49 check_accessible(byte loop)
-
- 50 make_noaccess_aligned
- 51 make_writable_aligned
-
-M 60 helperc_LOADV4
-M 61 helperc_STOREV4
-M 62 helperc_LOADV2
-M 63 helperc_STOREV2
-M 64 helperc_LOADV1
-M 65 helperc_STOREV1
-
-A 66 helperc_ACCESS4
-A 67 helperc_ACCESS2
-A 68 helperc_ACCESS1
-
-M 70 rim_rd_V4_SLOWLY
-M 71 rim_wr_V4_SLOWLY
-M 72 rim_rd_V2_SLOWLY
-M 73 rim_wr_V2_SLOWLY
-M 74 rim_rd_V1_SLOWLY
-M 75 rim_wr_V1_SLOWLY
-
-A 76 ACCESS4_SLOWLY
-A 77 ACCESS2_SLOWLY
-A 78 ACCESS1_SLOWLY
-
- 80 fpu_read
- 81 fpu_read aligned 4
- 82 fpu_read aligned 8
- 83 fpu_read 2
- 84 fpu_read 10/28/108/512
-
-M 85 fpu_write
-M 86 fpu_write aligned 4
-M 87 fpu_write aligned 8
-M 88 fpu_write 2
-M 89 fpu_write 10/28/108/512
-
- 90 fpu_access
- 91 fpu_access aligned 4
- 92 fpu_access aligned 8
- 93 fpu_access 2
- 94 fpu_access 10/28/108/512
-
- 100 fpu_access_check_SLOWLY
- 101 fpu_access_check_SLOWLY(byte loop)
-
- 110 new_mem_stack_4
- 111 new_mem_stack_8
- 112 new_mem_stack_12
- 113 new_mem_stack_16
- 114 new_mem_stack_32
- 115 new_mem_stack
-
- 120 die_mem_stack_4
- 121 die_mem_stack_8
- 122 die_mem_stack_12
- 123 die_mem_stack_16
- 124 die_mem_stack_32
- 125 die_mem_stack
-*/
-
-#ifdef MAC_PROFILE_MEMORY
-
-UInt MAC_(event_ctr)[N_PROF_EVENTS];
-HChar* MAC_(event_ctr_name)[N_PROF_EVENTS];
-
-static void init_prof_mem ( void )
-{
- Int i;
- for (i =3D 0; i < N_PROF_EVENTS; i++) {
- MAC_(event_ctr)[i] =3D 0;
- MAC_(event_ctr_name)[i] =3D NULL;
- }
-}
-
-static void done_prof_mem ( void )
-{
- Int i;
- Bool spaced =3D False;
- for (i =3D 0; i < N_PROF_EVENTS; i++) {
- if (!spaced && (i % 10) =3D=3D 0) {
- VG_(printf)("\n");
- spaced =3D True;
- }
- if (MAC_(event_ctr)[i] > 0) {
- spaced =3D False;
- VG_(printf)( "prof mem event %3d: %9d %s\n",=20
- i, MAC_(event_ctr)[i],
- MAC_(event_ctr_name)[i]=20
- ? MAC_(event_ctr_name)[i] : "unnamed");
- }
- }
-}
-
-#else
-
-static void init_prof_mem ( void ) { }
-static void done_prof_mem ( void ) { }
-
-#endif
-
-/*------------------------------------------------------------*/
-/*--- Common initialisation + finalisation ---*/
-/*------------------------------------------------------------*/
-
-void MAC_(common_pre_clo_init)(void)
-{
- MAC_(malloc_list) =3D VG_(HT_construct)( 80021 ); // prime, big
- MAC_(mempool_list) =3D VG_(HT_construct)( 1009 ); // prime, not so=
big
- init_prof_mem();
-}
-
-void MAC_(common_fini)(void (*leak_check)(ThreadId tid, LeakCheckMode mo=
de))
-{
- MAC_(print_malloc_stats)();
-
- if (VG_(clo_verbosity) =3D=3D 1 && !VG_(clo_xml)) {
- if (MAC_(clo_leak_check) =3D=3D LC_Off)
- VG_(message)(Vg_UserMsg,=20
- "For a detailed leak analysis, rerun with: --leak-check=3D=
yes");
-
- VG_(message)(Vg_UserMsg,=20
- "For counts of detected errors, rerun with: -v");
- }
- if (MAC_(clo_leak_check) !=3D LC_Off)
- leak_check(1/*bogus ThreadId*/, MAC_(clo_leak_check));
-
- done_prof_mem();
-}
-
-/*------------------------------------------------------------*/
-/*--- Common client request handling ---*/
-/*------------------------------------------------------------*/
-
-Bool MAC_(handle_common_client_requests)(ThreadId tid, UWord* arg, UWord=
* ret )
-{
- switch (arg[0]) {
- case VG_USERREQ__COUNT_LEAKS: { /* count leaked bytes */
- UWord** argp =3D (UWord**)arg;
- // MAC_(bytes_leaked) et al were set by the last leak check (or ze=
ro
- // if no prior leak checks performed).
- *argp[1] =3D MAC_(bytes_leaked) + MAC_(bytes_indirect);
- *argp[2] =3D MAC_(bytes_dubious);
- *argp[3] =3D MAC_(bytes_reachable);
- *argp[4] =3D MAC_(bytes_suppressed);
- // there is no argp[5]
- //*argp[5] =3D MAC_(bytes_indirect);
- // XXX need to make *argp[1-4] readable
- *ret =3D 0;
- return True;
- }
- case VG_USERREQ__MALLOCLIKE_BLOCK: {
- Addr p =3D (Addr)arg[1];
- SizeT sizeB =3D arg[2];
- UInt rzB =3D arg[3];
- Bool is_zeroed =3D (Bool)arg[4];
-
- MAC_(new_block) ( tid, p, sizeB, /*ignored*/0, rzB, is_zeroed,=20
- MAC_AllocCustom, MAC_(malloc_list) );
- return True;
- }
- case VG_USERREQ__FREELIKE_BLOCK: {
- Addr p =3D (Addr)arg[1];
- UInt rzB =3D arg[2];
-
- MAC_(handle_free) ( tid, p, rzB, MAC_AllocCustom );
- return True;
- }
-
- case _VG_USERREQ__MEMCHECK_RECORD_OVERLAP_ERROR: {
- Char* s =3D (Char*) arg[1];
- OverlapExtra* extra =3D (OverlapExtra*)arg[2];
- MAC_(record_overlap_error)(tid, s, extra);
- return True;
- }
-
- case VG_USERREQ__CREATE_MEMPOOL: {
- Addr pool =3D (Addr)arg[1];
- UInt rzB =3D arg[2];
- Bool is_zeroed =3D (Bool)arg[3];
-
- MAC_(create_mempool) ( pool, rzB, is_zeroed );
- return True;
- }
-
- case VG_USERREQ__DESTROY_MEMPOOL: {
- Addr pool =3D (Addr)arg[1];
-
- MAC_(destroy_mempool) ( pool );
- return True;
- }
-
- case VG_USERREQ__MEMPOOL_ALLOC: {
- Addr pool =3D (Addr)arg[1];
- Addr addr =3D (Addr)arg[2];
- UInt size =3D arg[3];
-
- MAC_(mempool_alloc) ( tid, pool, addr, size );
- return True;
- }
-
- case VG_USERREQ__MEMPOOL_FREE: {
- Addr pool =3D (Addr)arg[1];
- Addr addr =3D (Addr)arg[2];
-
- MAC_(mempool_free) ( pool, addr );
- return True;
- }
-
- default:
- return False;
- }
-}
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Deleted: branches/COMPVBITS/memcheck/mac_shared.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/COMPVBITS/memcheck/mac_shared.h 2005-12-07 00:04:22 UTC (rev=
5307)
+++ branches/COMPVBITS/memcheck/mac_shared.h 2005-12-07 00:36:51 UTC (rev=
5308)
@@ -1,638 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- Declarations shared between Memcheck and Addrcheck. ---*/
-/*--- mac_shared.h ---*/
-/*--------------------------------------------------------------------*/
-
-/*
- This file is part of MemCheck, a heavyweight Valgrind tool for
- detecting memory errors, and AddrCheck, a lightweight Valgrind tool=20
- for detecting memory errors.
-
- Copyright (C) 2000-2005 Julian Seward=20
- js...@ac...
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307, USA.
-
- The GNU General Public License is contained in the file COPYING.
-*/
-
-/* Note: This header contains the declarations shared between
- Addrcheck and Memcheck, and is #included by both. */
-
-#ifndef __MAC_SHARED_H
-#define __MAC_SHARED_H
-
-#define MAC_(str) VGAPPEND(vgMAC_,str)
-
-/*------------------------------------------------------------*/
-/*--- Errors and suppressions ---*/
-/*------------------------------------------------------------*/
-
-/* The classification of a faulting address. */
-typedef=20
- enum {=20
- Undescribed, // as-yet unclassified
- Stack,=20
- Unknown, // classification yielded nothing useful
- Freed, Mallocd,=20
- UserG, // in a user-defined block
- Mempool, // in a mempool
- Register, // in a register; for Param errors only
- }
- AddrKind;
-
-/* Records info about a faulting address. */
-typedef
- struct { // Used by:
- AddrKind akind; // ALL
- SizeT blksize; // Freed, Mallocd
- OffT rwoffset; // Freed, Mallocd
- ExeContext* lastchange; // Freed, Mallocd
- ThreadId stack_tid; // Stack
- const Char *desc; // UserG
- Bool maybe_gcc; // True if just below %esp -- could be a g=
cc bug.
- }
- AddrInfo;
-
-typedef=20
- enum {=20
- ParamSupp, // Bad syscall params
- CoreMemSupp, // Memory errors in core (pthread ops, signal handl=
ing)
-
- // Use of invalid values of given size (MemCheck only)
- Value0Supp, Value1Supp, Value2Supp, Value4Supp, Value8Supp, Value1=
6Supp,
-
- // Invalid read/write attempt at given size
- Addr1Supp, Addr2Supp, Addr4Supp, Addr8Supp, Addr16Supp,
-
- FreeSupp, // Invalid or mismatching free
- OverlapSupp, // Overlapping blocks in memcpy(), strcpy(), etc
- LeakSupp, // Something to be suppressed in a leak check.
- MempoolSupp, // Memory pool suppression.
- }=20
- MAC_SuppKind;
-
-/* What kind of error it is. */
-typedef=20
- enum { ValueErr, /* Memcheck only */
- CoreMemErr,
- AddrErr,=20
- ParamErr, UserErr, /* behaves like an anonymous ParamErr */
- FreeErr, FreeMismatchErr,
- OverlapErr,
- LeakErr,
- IllegalMempoolErr,
- }
- MAC_ErrorKind;
-
-/* What kind of memory access is involved in the error? */
-typedef
- enum { ReadAxs, WriteAxs, ExecAxs }
- AxsKind;
-
-/* Extra context for memory errors */
-typedef
- struct { // Used by:
- AxsKind axskind; // AddrErr
- Int size; // AddrErr, ValueErr
- AddrInfo addrinfo; // {Addr,Free,FreeMismatch,Param,User}Err
- Bool isUnaddr; // {CoreMem,Param,User}Err
- }
- MAC_Error;
-
-/* Extra info for overlap errors */
-typedef
- struct {
- Addr src;
- Addr dst;
- Int len; // -1 if unused
- }
- OverlapExtra;
-
-/* For malloc()/new/new[] vs. free()/delete/delete[] mismatch checking. =
*/
-typedef
- enum {
- MAC_AllocMalloc =3D 0,
- MAC_AllocNew =3D 1,
- MAC_AllocNewVec =3D 2,
- MAC_AllocCustom =3D 3
- }
- MAC_AllocKind;
- =20
-/* Nb: first two fields must match core's VgHashNode. */
-typedef
- struct _MAC_Chunk {
- struct _MAC_Chunk* next;
- Addr data; // ptr to actual block
- SizeT size : (sizeof(UWord)*8)-2; // size requested; 30 or=
62 bits
- MAC_AllocKind allockind : 2; // which wrapper did the allocation
- ExeContext* where; // where it was allocated
- }
- MAC_Chunk;
-
-/* Memory pool. Nb: first two fields must match core's VgHashNode. */
-typedef
- struct _MAC_Mempool {
- struct _MAC_Mempool* next;
- Addr pool; // pool identifier
- SizeT rzB; // pool red-zone size
- Bool is_zeroed; // allocations from this pool are ze=
roed
- VgHashTable chunks; // chunks associated with this pool
- }
- MAC_Mempool;
-
-
-/*------------------------------------------------------------*/
-/*--- Profiling of tools and memory events ---*/
-/*------------------------------------------------------------*/
-
-typedef=20
- enum {=20
- VgpCheckMem =3D VgpFini+1,
- VgpSetMem,
- VgpESPAdj
- }=20
- VgpToolCC;
-
-/* Define to collect detailed performance info. */
-/* #define MAC_PROFILE_MEMORY */
-
-#ifdef MAC_PROFILE_MEMORY
-# define N_PROF_EVENTS 500
-
-extern UInt MAC_(event_ctr)[N_PROF_EVENTS];
-extern HChar* MAC_(event_ctr_name)[N_PROF_EVENTS];
-
-# define PROF_EVENT(ev, name) \
- do { tl_assert((ev) >=3D 0 && (ev) < N_PROF_EVENTS); \
- /* crude and inaccurate check to ensure the same */ \
- /* event isn't being used with > 1 name */ \
- if (MAC_(event_ctr_name)[ev]) \
- tl_assert(name =3D=3D MAC_(event_ctr_name)[ev]); \
- MAC_(event_ctr)[ev]++; \
- MAC_(event_ctr_name)[ev] =3D (name); \
- } while (False);
-
-#else
-
-# define PROF_EVENT(ev, name) /* */
-
-#endif /* MAC_PROFILE_MEMORY */
-
-
-/*------------------------------------------------------------*/
-/*--- V and A bits (Victoria & Albert ?) ---*/
-/*------------------------------------------------------------*/
-
-/* expand 1 bit -> 8 */
-#define BIT_TO_BYTE(b) ((~(((UChar)(b) & 1) - 1)) & 0xFF)
-
-/* The number of entries in the primary map can be altered. However
- we hardwire the assumption that each secondary map covers precisely
- 64k of address space. */
-#define SM_SIZE 65536 /* DO NOT CHANGE */
-#define SM_MASK (SM_SIZE-1) /* DO NOT CHANGE */
-
-//zz #define SECONDARY_SHIFT 16
-//zz #define SECONDARY_SIZE (1 << SECONDARY_SHIFT)
-//zz #define SECONDARY_MASK (SECONDARY_SIZE - 1)
-//zz=20
-//zz #define PRIMARY_SIZE (1 << (32 - SECONDARY_SHIFT))
-//zz=20
-//zz #define SM_OFF(addr) ((addr) & SECONDARY_MASK)
-//zz #define PM_IDX(addr) ((addr) >> SECONDARY_SHIFT)
-/*
-#define IS_DISTINGUISHED_SM(smap) \
- ((smap) >=3D &distinguished_secondary_maps[0] && \
- (smap) < &distinguished_secondary_maps[N_SECONDARY_MAPS])
-
-#define IS_DISTINGUISHED(addr) (IS_DISTINGUISHED_SM(primary_map[PM_IDX(a=
ddr)]))
-
-#define ENSURE_MAPPABLE(addr,caller) \
- do { \
- if (IS_DISTINGUISHED(addr)) { \
- primary_map[PM_IDX(addr)] =3D alloc_secondary_map(caller, primary_map[=
PM_IDX(addr)]); \
- if (0) VG_(printf)("new 2map because of %p\n", addr); \
- } \
- } while(0)
-*/
-
-#define BITARR_SET(aaa_p,iii_p) \
- do { \
- UWord iii =3D (UWord)iii_p; \
- UChar* aaa =3D (UChar*)aaa_p; \
- aaa[iii >> 3] |=3D (1 << (iii & 7)); \
- } while (0)
-
-#define BITARR_CLEAR(aaa_p,iii_p) \
- do { \
- UWord iii =3D (UWord)iii_p; \
- UChar* aaa =3D (UChar*)aaa_p; \
- aaa[iii >> 3] &=3D ~(1 << (iii & 7)); \
- } while (0)
-
-#define BITARR_TEST(aaa_p,iii_p) \
- (0 !=3D (((UChar*)aaa_p)[ ((UWord)iii_p) >> 3 ] \
- & (1 << (((UWord)iii_p) & 7)))) \
-
-static inline=20
-void write_bit_array ( UChar* arr, UWord idx, UWord bit )=20
-{
- UWord shift =3D idx & 7;
- idx >>=3D 3;
- bit &=3D 1;
- arr[idx] =3D (arr[idx] & ~(1<<shift)) | (bit << shift);
-}
-
-static inline
-UWord read_bit_array ( UChar* arr, UWord idx )
-{
- UWord shift =3D idx & 7;
- idx >>=3D 3;
- return 1 & (arr[idx] >> shift);
-}
-
-
-#define VGM_BIT_VALID 0
-#define VGM_BIT_INVALID 1
-
-#define VGM_NIBBLE_VALID 0
-#define VGM_NIBBLE_INVALID 0xF
-
-#define VGM_BYTE_VALID 0
-#define VGM_BYTE_INVALID 0xFF
-
-#define VGM_SHORT_VALID 0
-#define VGM_SHORT_INVALID 0xFFFF
-
-#define VGM_WORD32_VALID 0
-#define VGM_WORD32_INVALID 0xFFFFFFFF
-
-#define VGM_WORD64_VALID 0ULL
-#define VGM_WORD64_INVALID 0xFFFFFFFFFFFFFFFFULL
-
-
-/*------------------------------------------------------------*/
-/*--- Command line options + defaults ---*/
-/*------------------------------------------------------------*/
-
-/* Memcheck defines a couple more. */
-
-/* Allow loads from partially-valid addresses? default: YES */
-extern Bool MAC_(clo_partial_loads_ok);
-
-/* Max volume of the freed blocks queue. */
-extern Int MAC_(clo_freelist_vol);
-
-/* Do leak check at exit? default: NO */
-typedef
- enum {
- LC_Off,
- LC_Summary,
- LC_Full,
- }
- LeakCheckMode;
-
-extern LeakCheckMode MAC_(clo_leak_check);
-
-/* How closely should we compare ExeContexts in leak records? default: 2=
*/
-extern VgRes MAC_(clo_leak_resolution);
-
-/* In leak check, show reachable-but-not-freed blocks? default: NO */
-extern Bool MAC_(clo_show_reachable);
-
-/* Assume accesses immediately below %esp are due to gcc-2.96 bugs.
- * default: NO */
-extern Bool MAC_(clo_workaround_gcc296_bugs);
-
-/* Do undefined value checking? "No" gives Addrcheck-style behaviour, ie=
.
- * faster but fewer errors found. Note that although Addrcheck had 1 bi=
t
- * per byte overhead vs the old Memcheck's 9 bits per byte, with this mo=
de
- * and compressed V bits, no memory is saved with this mode -- it's stil=
l
- * 2 bits per byte overhead. This is a little wasteful -- it could be d=
one
- * with 1 bit per byte -- but lets us reuse the many shadow memory acces=
s
- * functions. Note also that in this mode the secondary V bit table is
- * never used.
- *
- * default: YES */
-extern Bool MAC_(clo_undef_value_errors);
-
-extern Bool MAC_(process_common_cmd_line_option) ( Char* arg );
-extern void MAC_(print_common_usage) ( void );
-extern void MAC_(print_common_debug_usage) ( void );
-
-/* We want a 16B redzone on heap blocks for Addrcheck and Memcheck */
-#define MAC_MALLOC_REDZONE_SZB 16
-
-/*------------------------------------------------------------*/
-/*--- Variables ---*/
-/*------------------------------------------------------------*/
-
-/* For tracking malloc'd blocks */
-extern VgHashTable MAC_(malloc_list);
-
-/* For tracking memory pools. */
-extern VgHashTable MAC_(mempool_list);
-
-/* Function pointers for the two tools to track interesting events. */
-extern void (*MAC_(new_mem_heap)) ( Addr a, SizeT len, Bool is_inited );
-extern void (*MAC_(ban_mem_heap)) ( Addr a, SizeT len );
-extern void (*MAC_(die_mem_heap)) ( Addr a, SizeT len );
-extern void (*MAC_(copy_mem_heap))( Addr from, Addr to, SizeT len );
-
-/* Function pointers for internal sanity checking. */
-extern Bool (*MAC_(check_noaccess))( Addr a, SizeT len, Addr* bad_addr )=
;
-
-/* Used in describe_addr() */
-extern Bool (*MAC_(describe_addr_supp)) ( Addr a, AddrInfo* ai );
-
-/* For VALGRIND_COUNT_LEAKS client request */
-extern SizeT MAC_(bytes_leaked);
-extern SizeT MAC_(bytes_indirect);
-extern SizeT MAC_(bytes_dubious);
-extern SizeT MAC_(bytes_reachable);
-extern SizeT MAC_(bytes_suppressed);
-
-/*------------------------------------------------------------*/
-/*--- Functions ---*/
-/*------------------------------------------------------------*/
-
-extern void MAC_(pp_AddrInfo) ( Addr a, AddrInfo* ai );
-
-extern void MAC_(clear_MAC_Error) ( MAC_Error* err_extra );
-
-extern Bool MAC_(eq_Error) ( VgRes res, Error* e1, Error* e2 );
-extern UInt MAC_(update_extra)( Error* err );
-extern Bool MAC_(read_extra_suppression_info) ( Int fd, Char* buf, Int =
nBuf, Supp *su );
-extern Bool MAC_(error_matches_suppression)(Error* err, Supp* su);
-extern Char* MAC_(get_error_name) ( Error* err );
-extern void MAC_(print_extra_suppression_info) ( Error* err );
-
-extern Bool MAC_(shared_recognised_suppression) ( Char* name, Supp* su =
);
-
-extern void* MAC_(new_block) ( ThreadId tid,
- Addr p, SizeT size, SizeT align, UInt rzB=
,
- Bool is_zeroed, MAC_AllocKind kind,
- VgHashTable table);
-
-extern void MAC_(handle_free) ( ThreadId tid,
- Addr p, UInt rzB, MAC_AllocKind kind );
-
-extern void MAC_(create_mempool)(Addr pool, UInt rzB, Bool is_zeroed);
-
-extern void MAC_(destroy_mempool)(Addr pool);
-
-extern void MAC_(mempool_alloc)(ThreadId tid,=20
- Addr pool, Addr addr, SizeT size);
-
-extern void MAC_(mempool_free)(Addr pool, Addr addr);
-
-extern void MAC_(record_address_error) ( ThreadId tid, Addr a,
- Int size, Bool isWrite );
-extern void MAC_(record_core_mem_error) ( ThreadId tid, Bool isUnaddr=
,
- Char* s );
-extern void MAC_(record_param_error) ( ThreadId tid, Addr a, Bool =
isReg,
- Bool isUnaddr, Char* msg );
-extern void MAC_(record_jump_error) ( ThreadId tid, Addr a );
-extern void MAC_(record_free_error) ( ThreadId tid, Addr a );
-extern void MAC_(record_freemismatch_error)( ThreadId tid, Addr a,
- MAC_Chunk* mc);
-extern void MAC_(record_overlap_error) ( ThreadId tid,=20
- Char* function, OverlapExtr=
a* oe );
-extern void MAC_(record_illegal_mempool_error) ( ThreadId tid, Addr pool=
);
-
-extern void MAC_(pp_shared_Error) ( Error* err);
-
-extern MAC_Chunk* MAC_(get_freed_list_head)( void );
-
-extern void MAC_(common_pre_clo_init) ( void );
-extern void MAC_(common_fini) ( void (*leak_check)(ThreadId tid,
- LeakCheckMode=
mode) );
-
-extern Bool MAC_(handle_common_client_requests) ( ThreadId tid,=20
- UWord* arg_block, UWor=
d* ret );
-
-/* For leak checking */
-extern void MAC_(pp_LeakError)(void* extra);
- =20
-extern void MAC_(print_malloc_stats) ( void );
-
-extern void MAC_(do_detect_memory_leaks) (
- ThreadId tid, LeakCheckMode mode,
- Bool (*is_within_valid_secondary) ( Addr ),
- Bool (*is_valid_aligned_word) ( Addr )
- );
-
-extern VG_REGPARM(1) void MAC_(new_mem_stack_4) ( Addr old_ESP );
-extern VG_REGPARM(1) void MAC_(die_mem_stack_4) ( Addr old_ESP );
-extern VG_REGPARM(1) void MAC_(new_mem_stack_8) ( Addr old_ESP );
-extern VG_REGPARM(1) void MAC_(die_mem_stack_8) ( Addr old_ESP );
-extern VG_REGPARM(1) void MAC_(new_mem_stack_12) ( Addr old_ESP );
-extern VG_REGPARM(1) void MAC_(die_mem_stack_12) ( Addr old_ESP );
-extern VG_REGPARM(1) void MAC_(new_mem_stack_16) ( Addr old_ESP );
-extern VG_REGPARM(1) void MAC_(die_mem_stack_16) ( Addr old_ESP );
-extern VG_REGPARM(1) void MAC_(new_mem_stack_32) ( Addr old_ESP );
-extern VG_REGPARM(1) void MAC_(die_mem_stack_32) ( Addr old_ESP );
-extern void MAC_(die_mem_stack) ( Addr a, SizeT len);
-extern void MAC_(new_mem_stack) ( Addr a, SizeT len);
-
-extern void* MAC_(malloc) ( ThreadId tid, SizeT n );
-extern void* MAC_(__builtin_new) ( ThreadId tid, SizeT n );
-extern void* MAC_(__builtin_vec_new) ( ThreadId tid, SizeT n );
-extern void* MAC_(memalign) ( ThreadId tid, SizeT align, Siz=
eT n );
-extern void* MAC_(calloc) ( ThreadId tid, SizeT nmemb, Siz=
eT size1 );
-extern void MAC_(free) ( ThreadId tid, void* p );
-extern void MAC_(__builtin_delete) ( ThreadId tid, void* p );
-extern void MAC_(__builtin_vec_delete) ( ThreadId tid, void* p );
-extern void* MAC_(realloc) ( ThreadId tid, void* p, SizeT n=
ew_size );
-
-/*------------------------------------------------------------*/
-/*--- Stack pointer adjustment ---*/
-/*------------------------------------------------------------*/
-
-/* Some noble preprocessor abuse, to enable Memcheck and Addrcheck to
- share this code, but call different functions.
-
- Note that this code is executed very frequently and must be highly
- optimised, which is why I resort to the preprocessor to achieve the
- factoring, rather than eg. using function pointers. =20
-*/
-
-#define SP_UPDATE_HANDLERS(ALIGNED4_NEW, ALIGNED4_DIE, \
- ALIGNED8_NEW, ALIGNED8_DIE, \
- UNALIGNED_NEW, UNALIGNED_DIE) \
- \
-void VG_REGPARM(1) MAC_(new_mem_stack_4)(Addr new_SP) \
-{ \
- PROF_EVENT(110, "new_mem_stack_4"); \
- if (VG_IS_4_ALIGNED(new_SP)) { \
- ALIGNED4_NEW ( -VG_STACK_REDZONE_SZB + new_SP ); \
- } else { \
- UNALIGNED_NEW ( -VG_STACK_REDZONE_SZB + new_SP, 4 ); \
- } \
-} \
- \
-void VG_REGPARM(1) MAC_(die_mem_stack_4)(Addr new_SP) \
-{ \
- PROF_EVENT(120, "die_mem_stack_4"); \
- if (VG_IS_4_ALIGNED(new_SP)) { \
- ALIGNED4_DIE ( -VG_STACK_REDZONE_SZB + new_SP-4 ); \
- } else { \
- UNALIGNED_DIE ( -VG_STACK_REDZONE_SZB + new_SP-4, 4 ); \
- } \
-} \
- \
-void VG_REGPARM(1) MAC_(new_mem_stack_8)(Addr new_SP) \
-{ \
- PROF_EVENT(111, "new_mem_stack_8"); \
- if (VG_IS_8_ALIGNED(new_SP)) { \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP ); \
- } else if (VG_IS_4_ALIGNED(new_SP)) { \
- ALIGNED4_NEW ( -VG_STACK_REDZONE_SZB + new_SP ); \
- ALIGNED4_NEW ( -VG_STACK_REDZONE_SZB + new_SP+4 ); \
- } else { \
- UNALIGNED_NEW ( -VG_STACK_REDZONE_SZB + new_SP, 8 ); \
- } \
-} \
- \
-void VG_REGPARM(1) MAC_(die_mem_stack_8)(Addr new_SP) \
-{ \
- PROF_EVENT(121, "die_mem_stack_8"); \
- if (VG_IS_8_ALIGNED(new_SP)) { \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-8 ); \
- } else if (VG_IS_4_ALIGNED(new_SP)) { \
- ALIGNED4_DIE ( -VG_STACK_REDZONE_SZB + new_SP-8 ); \
- ALIGNED4_DIE ( -VG_STACK_REDZONE_SZB + new_SP-4 ); \
- } else { \
- UNALIGNED_DIE ( -VG_STACK_REDZONE_SZB + new_SP-8, 8 ); \
- } \
-} \
- \
-void VG_REGPARM(1) MAC_(new_mem_stack_12)(Addr new_SP) \
-{ \
- PROF_EVENT(112, "new_mem_stack_12"); \
- if (VG_IS_8_ALIGNED(new_SP)) { \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP ); \
- ALIGNED4_NEW ( -VG_STACK_REDZONE_SZB + new_SP+8 ); \
- } else if (VG_IS_4_ALIGNED(new_SP)) { \
- ALIGNED4_NEW ( -VG_STACK_REDZONE_SZB + new_SP ); \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP+4 ); \
- } else { \
- UNALIGNED_NEW ( -VG_STACK_REDZONE_SZB + new_SP, 12 ); \
- } \
-} \
- \
-void VG_REGPARM(1) MAC_(die_mem_stack_12)(Addr new_SP) \
-{ \
- PROF_EVENT(122, "die_mem_stack_12"); \
- /* Note the -12 in the test */ \
- if (VG_IS_8_ALIGNED(new_SP-12)) { \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-12 ); \
- ALIGNED4_DIE ( -VG_STACK_REDZONE_SZB + new_SP-4 ); \
- } else if (VG_IS_4_ALIGNED(new_SP)) { \
- ALIGNED4_DIE ( -VG_STACK_REDZONE_SZB + new_SP-12 ); \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-8 ); \
- } else { \
- UNALIGNED_DIE ( -VG_STACK_REDZONE_SZB + new_SP-12, 12 ); \
- } \
-} \
- \
-void VG_REGPARM(1) MAC_(new_mem_stack_16)(Addr new_SP) \
-{ \
- PROF_EVENT(113, "new_mem_stack_16"); \
- if (VG_IS_8_ALIGNED(new_SP)) { \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP ); \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP+8 ); \
- } else if (VG_IS_4_ALIGNED(new_SP)) { \
- ALIGNED4_NEW ( -VG_STACK_REDZONE_SZB + new_SP ); \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP+4 ); \
- ALIGNED4_NEW ( -VG_STACK_REDZONE_SZB + new_SP+12 ); \
- } else { \
- UNALIGNED_NEW ( -VG_STACK_REDZONE_SZB + new_SP, 16 ); \
- } \
-} \
- \
-void VG_REGPARM(1) MAC_(die_mem_stack_16)(Addr new_SP) \
-{ \
- PROF_EVENT(123, "die_mem_stack_16"); \
- if (VG_IS_8_ALIGNED(new_SP)) { \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-16 ); \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-8 ); \
- } else if (VG_IS_4_ALIGNED(new_SP)) { \
- ALIGNED4_DIE ( -VG_STACK_REDZONE_SZB + new_SP-16 ); \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-12 ); \
- ALIGNED4_DIE ( -VG_STACK_REDZONE_SZB + new_SP-4 ); \
- } else { \
- UNALIGNED_DIE ( -VG_STACK_REDZONE_SZB + new_SP-16, 16 ); \
- } \
-} \
- \
-void VG_REGPARM(1) MAC_(new_mem_stack_32)(Addr new_SP) \
-{ \
- PROF_EVENT(114, "new_mem_stack_32"); \
- if (VG_IS_8_ALIGNED(new_SP)) { \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP ); \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP+8 ); \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP+16 ); \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP+24 ); \
- } else if (VG_IS_4_ALIGNED(new_SP)) { \
- ALIGNED4_NEW ( -VG_STACK_REDZONE_SZB + new_SP ); \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP+4 ); \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP+12 ); \
- ALIGNED8_NEW ( -VG_STACK_REDZONE_SZB + new_SP+20 ); \
- ALIGNED4_NEW ( -VG_STACK_REDZONE_SZB + new_SP+28 ); \
- } else { \
- UNALIGNED_NEW ( -VG_STACK_REDZONE_SZB + new_SP, 32 ); \
- } \
-} \
- \
-void VG_REGPARM(1) MAC_(die_mem_stack_32)(Addr new_SP) \
-{ \
- PROF_EVENT(124, "die_mem_stack_32"); \
- if (VG_IS_8_ALIGNED(new_SP)) { \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-32 ); \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-24 ); \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-16 ); \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP- 8 ); \
- } else if (VG_IS_4_ALIGNED(new_SP)) { \
- ALIGNED4_DIE ( -VG_STACK_REDZONE_SZB + new_SP-32 ); \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-28 ); \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-20 ); \
- ALIGNED8_DIE ( -VG_STACK_REDZONE_SZB + new_SP-12 ); \
- ALIGNED4_DIE ( -VG_STACK_REDZONE_SZB + new_SP-4 ); \
- } else { \
- UNALIGNED_DIE ( -VG_STACK_REDZONE_SZB + new_SP-32, 32 ); \
- } \
-} \
- \
-void MAC_(new_mem_stack) ( Addr a, SizeT len ) \
-{ \
- PROF_EVENT(115, "new_mem_stack"); \
- UNALIGNED_NEW ( -VG_STACK_REDZONE_SZB + a, len ); \
-} \
- \
-void MAC_(die_mem_stack) ( Addr a, SizeT len ) \
-{ \
- PROF_EVENT(125, "die_mem_stack"); \
- UNALIGNED_DIE ( -VG_STACK_REDZONE_SZB + a, len ); \
-}
-
-#endif /* __MAC_SHARED_H */
-
-/*--------------------------------------------------------------------*/
-/*--- end ---*/
-/*--------------------------------------------------------------------*/
Modified: branches/COMPVBITS/memcheck/mc_include.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/COMPVBITS/memcheck/mc_include.h 2005-12-07 00:04:22 UTC (rev=
5307)
+++ branches/COMPVBITS/memcheck/mc_include.h 2005-12-07 00:36:51 UTC (rev=
5308)
@@ -29,25 +29,529 @@
The GNU General Public License is contained in the file COPYING.
*/
=20
-/* Note: this header should contain declarations that are for use by
- Memcheck only -- declarations shared with Addrcheck go in mac_shared.=
h.
-*/
-
#ifndef __MC_INCLUDE_H
#define __MC_INCLUDE_H
=20
-#include "mac_shared.h"
+#define MAC_(str) VGAPPEND(vgMAC_,str)
=20
+/*------------------------------------------------------------*/
+/*--- Errors and suppressions ---*/
+/*------------------------------------------------------------*/
+
+/* The classification of a faulting address. */
+typedef=20
+ enum {=20
+ Undescribed, // as-yet unclassified
+ Stack,=20
+ Unknown, // classification yielded nothing useful
+ Freed, Mallocd,=20
+ UserG, // in a user-defined block
+ Mempool, // in a mempool
+ Register, // in a register; for Param errors only
+ }
+ AddrKind;
+
+/* Records info about a faulting address. */
+typedef
+ struct { // Used by:
+ AddrKind akind; // ALL
+ SizeT blksize; // Freed, Mallocd
+ OffT rwoffset; // Freed, Mallocd
+ ExeContext* lastchange; // Freed, Mallocd
+ ThreadId stack_tid; // Stack
+ const Char *desc; // UserG
+ Bool maybe_gcc; // True if just below %esp -- could be a g=
cc bug.
+ }
+ AddrInfo;
+
+typedef=20
+ enum {=20
+ ParamSupp, // Bad syscall params
+ CoreMemSupp, // Memory errors in core (pthread ops, signal handl=
ing)
+
+ // Use of invalid values of given size (MemCheck only)
+ Value0Supp, Value1Supp, Value2Supp, Value4Supp, Value8Supp, Value1=
6Supp,
+
+ // Invalid read/write attempt at given size
+ Addr1Supp, Addr2Supp, Addr4Supp, Addr8Supp, Addr16Supp,
+
+ FreeSupp, // Invalid or mismatching free
+ OverlapSupp, // Overlapping blocks in memcpy(), strcpy(), etc
+ LeakSupp, // Something to be suppressed in a leak check.
+ MempoolSupp, // Memory pool suppression.
+ }=20
+ MAC_SuppKind;
+
+/* What kind of error it is. */
+typedef=20
+ enum { ValueErr, /* Memcheck only */
+ CoreMemErr,
+ AddrErr,=20
+ ParamErr, UserErr, /* behaves like an anonymous ParamErr */
+ FreeErr, FreeMismatchErr,
+ OverlapErr,
+ LeakErr,
+ IllegalMempoolErr,
+ }
+ MAC_ErrorKind;
+
+/* What kind of memory access is involved in the error? */
+typedef
+ enum { ReadAxs, WriteAxs, ExecAxs }
+ AxsKind;
+
+/* Extra context for memory errors */
+typedef
+ struct { // Used by:
+ AxsKind axskind; // AddrErr
+ Int size; // AddrErr, ValueErr
+ AddrInfo addrinfo; // {Addr,Free,FreeMismatch,Param,User}Err
+ Bool isUnaddr; // {CoreMem,Param,User}Err
+ }
+ MAC_Error;
+
+/* Extra info for overlap errors */
+typedef
+ struct {
+ Addr src;
+ Addr dst;
+ Int len; // -1 if unused
+ }
+ OverlapExtra;
+
+/* For malloc()/new/new[] vs. free()/delete/delete[] mismatch checking. =
*/
+typedef
+ enum {
+ MAC_AllocMalloc =3D 0,
+ MAC_AllocNew =3D 1,
+ MAC_AllocNewVec =3D 2,
+ MAC_AllocCustom =3D 3
+ }
+ MAC_AllocKind;
+ =20
+/* Nb: first two fields must match core's VgHashNode. */
+typedef
+ struct _MAC_Chunk {
+ struct _MAC_Chunk* next;
+ Addr data; // ptr to actual block
+ SizeT size : (sizeof(UWord)*8)-2; // size requested; 30 or=
62 bits
+ MAC_AllocKind allockind : 2; // which wrapper did the allocation
+ ExeContext* where; // where it was allocated
+ }
+ MAC_Chunk;
+
+/* Memory pool. Nb: first two fields must match core's VgHashNode. */
+typedef
+ struct _MAC_Mempool {
+ struct _MAC_Mempool* next;
+ Addr pool; // pool identifier
+ SizeT rzB; // pool red-zone size
+ Bool is_zeroed; // allocations from this pool are ze=
roed
+ VgHashTable chunks; // chunks associated with this pool
+ }
+ MAC_Mempool;
+
+
+/*------------------------------------------------------------*/
+/*--- Profiling of tools and memory events ---*/
+/*------------------------------------------------------------*/
+
+typedef=20
+ enum {=20
+ VgpCheckMem =3D VgpFini+1,
+ VgpSetMem,
+ VgpESPAdj
+ }=20
+ VgpToolCC;
+
+/* Define to collect detailed performance info. */
+/* #define MAC_PROFILE_MEMORY */
+
+#ifdef MAC_PROFILE_MEMORY
+# define N_PROF_EVENTS 500
+
+extern UInt MAC_(event_ctr)[N_PROF_EVENTS];
+extern HChar* MAC_(event_ctr_name)[N_PROF_EVENTS];
+
+# define PROF_EVENT(ev, name) \
+ do { tl_assert((ev) >=3D 0 && (ev) < N_PROF_EVENTS); \
+ /* crude and inaccurate check to ensure the same */ \
+ /* event isn't being used with > 1 name */ \
+ if (MAC_(event_ctr_name)[ev]) \
+ tl_assert(name =3D=3D MAC_(event_ctr_name)[ev]); \
+ MAC_(event_ctr)[ev]++; \
+ MAC_(event_ctr_name)[ev] =3D (name); \
+ } while (False);
+
+#else
+
+# define PROF_EVENT(ev, name) /* */
+
+#endif /* MAC_PROFILE_MEMORY */
+
+
+/*------------------------------------------------------------*/
+/*--- V and A bits (Victoria & Albert ?) ---*/
+/*------------------------------------------------------------*/
+
+/* The number of entries in the primary map can be altered. However
+ we hardwire the assumption that each secondary map covers precisely
+ 64k of address space. */
+#define SM_SIZE 65536 /* DO NOT CHANGE */
+#define SM_MASK (SM_SIZE-1) /* DO NOT CHANGE */
+
+#define VGM_BIT_VALID 0
+#define VGM_BIT_INVALID 1
+
+#define VGM_NIBBLE_VALID 0
+#define VGM_NIBBLE_INVALID 0xF
+
+#define VGM_BYTE_VALID 0
+#define VGM_BYTE_INVALID 0xFF
+
+#define VGM_SHORT_VALID 0
+#define VGM_SHORT_INVALID 0xFFFF
+
+#define VGM_WORD32_VALID 0
+#define VGM_WORD32_INVALID 0xFFFFFFFF
+
+#define VGM_WORD64_VALID 0ULL
+#define VGM_WORD64_INVALID 0xFFFFFFFFFFFFFFFFULL
+
+
+/* We want a 16B redzone on heap blocks for Memcheck */
+#define MAC_MALLOC_REDZONE_SZB 16
+
+/*------------------------------------------------------------*/
+/*--- Variables ---*/
+/*------------------------------------------------------------*/
+
+/* For tracking malloc'd blocks */
+extern VgHashTable MAC_(malloc_list);
+
+/* For tracking memory pools. */
+extern VgHashTable MAC_(mempool_list);
+
+/* Function pointers for the two tools to track interesting events. */
+extern void (*MAC_(new_mem_heap)) ( Addr a, SizeT len, Bool is_inited );
+extern void (*MAC_(ban_mem_heap)) ( Addr a, SizeT len );
+extern void (*MAC_(die_mem_heap)) ( Addr a, SizeT len );
+extern void (*MAC_(copy_mem_heap))( Addr from, Addr to, SizeT len );
+
+/* Function pointers for internal sanity checking. */
+extern Bool (*MAC_(check_noaccess))( Addr a, SizeT len, Addr* bad_addr )=
;
+
+/* Used in describe_addr() */
+extern Bool (*MAC_(describe_addr_supp)) ( Addr a, AddrInfo* ai );
+
+/* For VALGRIND_COUNT_LEAKS client request */
+extern SizeT MAC_(bytes_leaked);
+extern SizeT MAC_(bytes_indirect);
+extern SizeT MAC_(bytes_dubious);
+extern SizeT MAC_(bytes_reachable);
+extern SizeT MAC_(bytes_suppressed);
+
+/*------------------------------------------------------------*/
+/*--- Functions ---*/
+/*------------------------------------------------------------*/
+
+extern void MAC_(pp_AddrInfo) ( Addr a, AddrInfo* ai );
+
+extern void MAC_(clear_MAC_Error) ( MAC_Error* err_extra );
+
+extern Bool MAC_(eq_Error) ( VgRes res, Error* e1, Error* e2 );
+extern UInt MAC_(update_extra)( Error* err );
+extern Bool MAC_(read_extra_suppression_info) ( Int fd, Char* buf, Int =
nBuf, Supp *su );
+extern Bool MAC_(error_matches_suppression)(Error* err, Supp* su);
+extern Char* MAC_(get_error_name) ( Error* err );
+extern void MAC_(print_extra_suppression_info) ( Error* err );
+
+extern Bool MAC_(shared_recognised_suppression) ( Char* name, Supp* su =
);
+
+extern void* MAC_(new_block) ( ThreadId tid,
+ Addr p, SizeT size, SizeT align, UInt rzB=
,
+...
[truncated message content] |