Added overlap checking to Addrcheck, mostly just moving things around. In

particular, renamed mc_replace_strmem.c as mac_replace_strmem.c;  the 'mac'
prefix indicates it's shared between Memcheck and Addrcheck.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1774
This commit is contained in:
Nicholas Nethercote 2003-07-22 09:12:33 +00:00
parent c3439e49db
commit ca84f991d3
9 changed files with 39 additions and 36 deletions

View File

@ -17,5 +17,6 @@ vgskin_addrcheck_so_LDADD = \
../memcheck/mac_leakcheck.o \
../memcheck/mac_malloc_wrappers.o \
../memcheck/mac_needs.o \
../memcheck/mac_replace_strmem.o \
../coregrind/vg_replace_malloc.o

View File

@ -16,11 +16,11 @@ vgskin_memcheck_so_SOURCES = \
mac_leakcheck.c \
mac_malloc_wrappers.c \
mac_needs.c \
mac_replace_strmem.c \
mc_main.c \
mc_clientreqs.c \
mc_errcontext.c \
mc_from_ucode.c \
mc_replace_strmem.c \
mc_translate.c \
mc_helpers.S
vgskin_memcheck_so_LDFLAGS = -shared
@ -36,5 +36,5 @@ noinst_HEADERS = \
mc_constants.h \
mc_include.h
mc_replace_strmem.o: CFLAGS += -fno-omit-frame-pointer
mac_replace_strmem.o: CFLAGS += -fno-omit-frame-pointer

View File

@ -287,6 +287,13 @@ void MAC_(pp_shared_SkinError) ( Error* err )
MAC_(pp_AddrInfo)(VG_(get_error_address)(err), &err_extra->addrinfo);
break;
case OverlapErr:
VG_(message)(Vg_UserMsg,
"Source and destination overlap in %s",
VG_(get_error_string)(err));
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
break;
case LeakErr: {
/* Totally abusing the types of these spare fields... oh well. */
UInt n_this_record = (UInt)VG_(get_error_address)(err);
@ -464,6 +471,16 @@ void MAC_(record_freemismatch_error) ( ThreadState* tst, Addr a )
VG_(maybe_record_error)( tst, FreeMismatchErr, a, /*s*/NULL, &err_extra );
}
void MAC_(record_overlap_error) ( ThreadState* tst, Char* function )
{
MAC_Error err_extra;
MAC_(clear_MAC_Error)( &err_extra );
VG_(maybe_record_error)( tst, OverlapErr, /*addr*/0, function, &err_extra );
}
/* Updates the copy with address info if necessary (but not for LeakErrs). */
UInt SK_(update_extra)( Error* err )
{

View File

@ -2,7 +2,7 @@
/*--------------------------------------------------------------------*/
/*--- Replacements for strcpy(), memcpy() et al, which run on the ---*/
/*--- simulated CPU. ---*/
/*--- mc_replace_strmem.c ---*/
/*--- mac_replace_strmem.c ---*/
/*--------------------------------------------------------------------*/
/*
@ -84,7 +84,7 @@ void complain2 ( Char* s, char* dst, const char* src )
{
Char buf[256];
snprintf(buf, 100, "%s(%p, %p)", s, dst, src );
VALGRIND_NON_SIMD_tstCALL1( MC_(record_overlap_error), buf );
VALGRIND_NON_SIMD_tstCALL1( MAC_(record_overlap_error), buf );
}
static __inline__
@ -92,7 +92,7 @@ void complain3 ( Char* s, void* dst, const void* src, int n )
{
Char buf[256];
snprintf(buf, 100, "%s(%p, %p, %d)", s, dst, src, n );
VALGRIND_NON_SIMD_tstCALL1( MC_(record_overlap_error), buf );
VALGRIND_NON_SIMD_tstCALL1( MAC_(record_overlap_error), buf );
}
char* strrchr ( const char* s, int c )
@ -281,5 +281,5 @@ void* memcpy( void *dst, const void *src, unsigned int len )
/*--------------------------------------------------------------------*/
/*--- end mc_replace_strmem.c ---*/
/*--- end mac_replace_strmem.c ---*/
/*--------------------------------------------------------------------*/

View File

@ -304,6 +304,7 @@ extern void MAC_(record_param_error) ( ThreadState* tst, Addr a,
extern void MAC_(record_jump_error) ( ThreadState* tst, Addr a );
extern void MAC_(record_free_error) ( ThreadState* tst, Addr a );
extern void MAC_(record_freemismatch_error)( ThreadState* tst, Addr a );
extern void MAC_(record_overlap_error) ( ThreadState* tst, Char* function );
extern void MAC_(pp_shared_SkinError) ( Error* err);

View File

@ -114,13 +114,6 @@ void SK_(pp_SkinError) ( Error* err )
MAC_(pp_AddrInfo)(VG_(get_error_address)(err), &err_extra->addrinfo);
break;
case OverlapErr:
VG_(message)(Vg_UserMsg,
"Source and destination overlap in %s",
VG_(get_error_string)(err));
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
break;
default:
MAC_(pp_shared_SkinError)(err);
break;
@ -143,7 +136,7 @@ void MC_(record_value_error) ( ThreadState* tst, Int size )
VG_(maybe_record_error)( tst, ValueErr, /*addr*/0, /*s*/NULL, &err_extra );
}
/* These two called from non-generated code */
/* This called from non-generated code */
void MC_(record_user_error) ( ThreadState* tst, Addr a, Bool isWrite )
{
@ -157,14 +150,6 @@ void MC_(record_user_error) ( ThreadState* tst, Addr a, Bool isWrite )
VG_(maybe_record_error)( tst, UserErr, a, /*s*/NULL, &err_extra );
}
void MC_(record_overlap_error) ( ThreadState* tst, Char* function )
{
MAC_Error err_extra;
MAC_(clear_MAC_Error)( &err_extra );
VG_(maybe_record_error)( tst, OverlapErr, /*addr*/0, function, &err_extra );
}
/*------------------------------------------------------------*/
/*--- Suppressions ---*/
/*------------------------------------------------------------*/

View File

@ -113,14 +113,14 @@ extern Bool MC_(clo_avoid_strlen_errors);
/*--- Functions ---*/
/*------------------------------------------------------------*/
/* Functions defined in vg_memcheck_helpers.S */
/* Functions defined in mc_helpers.S */
extern void MC_(helper_value_check4_fail) ( void );
extern void MC_(helper_value_check2_fail) ( void );
extern void MC_(helper_value_check1_fail) ( void );
extern void MC_(helper_value_check0_fail) ( void );
/* Functions defined in vg_memcheck.c */
/* Functions defined in mc_main.c */
extern void MC_(helperc_STOREV4) ( Addr, UInt );
extern void MC_(helperc_STOREV2) ( Addr, UInt );
extern void MC_(helperc_STOREV1) ( Addr, UInt );
@ -151,15 +151,14 @@ extern Int MC_(get_or_set_vbits_for_client) (
Bool setting /* True <=> set vbits, False <=> get vbits */
);
/* Functions defined in vg_memcheck_clientreqs.c */
/* Functions defined in mc_clientreqs.c */
extern Bool MC_(client_perm_maybe_describe)( Addr a, AddrInfo* ai );
extern void MC_(show_client_block_stats) ( void );
/* Functions defined in vg_memcheck_errcontext.c */
/* Functions defined in mc_errcontext.c */
extern void MC_(record_value_error) ( ThreadState* tst, Int size );
extern void MC_(record_user_error) ( ThreadState* tst, Addr a, Bool isWrite );
extern void MC_(record_overlap_error)( ThreadState* tst, Char* function );
#endif

View File

@ -7,8 +7,8 @@ $dir/../../tests/filter_stderr_basic |
# Anonymise addresses
$dir/../../tests/filter_addresses |
# Anonymise line numbers in mc_replace_strmem.c
sed "s/mc_replace_strmem.c:[0-9]\+/mc_replace_strmem.c:.../" |
# Anonymise line numbers in mac_replace_strmem.c
sed "s/mac_replace_strmem.c:[0-9]\+/mac_replace_strmem.c:.../" |
$dir/../../tests/filter_test_paths |

View File

@ -1,41 +1,41 @@
Source and destination overlap in memcpy(0x........, 0x........, 21)
at 0x........: memcpy (mc_replace_strmem.c:...)
at 0x........: memcpy (mac_replace_strmem.c:...)
by 0x........: main (overlap.c:40)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Source and destination overlap in memcpy(0x........, 0x........, 21)
at 0x........: memcpy (mc_replace_strmem.c:...)
at 0x........: memcpy (mac_replace_strmem.c:...)
by 0x........: main (overlap.c:42)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Source and destination overlap in strncpy(0x........, 0x........, 21)
at 0x........: strncpy (mc_replace_strmem.c:...)
at 0x........: strncpy (mac_replace_strmem.c:...)
by 0x........: main (overlap.c:45)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Source and destination overlap in strncpy(0x........, 0x........, 21)
at 0x........: strncpy (mc_replace_strmem.c:...)
at 0x........: strncpy (mac_replace_strmem.c:...)
by 0x........: main (overlap.c:47)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Source and destination overlap in strcpy(0x........, 0x........)
at 0x........: strcpy (mc_replace_strmem.c:...)
at 0x........: strcpy (mac_replace_strmem.c:...)
by 0x........: main (overlap.c:54)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Source and destination overlap in strncat(0x........, 0x........, 21)
at 0x........: strncat (mc_replace_strmem.c:...)
at 0x........: strncat (mac_replace_strmem.c:...)
by 0x........: main (overlap.c:112)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
Source and destination overlap in strncat(0x........, 0x........, 21)
at 0x........: strncat (mc_replace_strmem.c:...)
at 0x........: strncat (mac_replace_strmem.c:...)
by 0x........: main (overlap.c:113)
by 0x........: __libc_start_main (...libc...)
by 0x........: ...