]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added overlap checking to Addrcheck, mostly just moving things around. In
authorNicholas Nethercote <njn@valgrind.org>
Tue, 22 Jul 2003 09:12:33 +0000 (09:12 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Tue, 22 Jul 2003 09:12:33 +0000 (09:12 +0000)
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

addrcheck/Makefile.am
memcheck/Makefile.am
memcheck/mac_needs.c
memcheck/mac_replace_strmem.c [moved from memcheck/mc_replace_strmem.c with 96% similarity]
memcheck/mac_shared.h
memcheck/mc_errcontext.c
memcheck/mc_include.h
memcheck/tests/filter_stderr
memcheck/tests/overlap.stderr.exp

index 1a4f5060e488febd35992829391d3f1b9cf2540f..a3731e73001de1e06e22b23ed4a9717c79d90270 100644 (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
 
index e93850731271fe1bc42c3505ae41c2f5d356b2a2..3463d2cf3a3029e91324985bfb0eef35f5014f9e 100644 (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
 
index daec93849387c71b16ac47f27d70ad4282242aaf..e90151e00d8fa3567808a8b371881ff3305fa834 100644 (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 )
 {
similarity index 96%
rename from memcheck/mc_replace_strmem.c
rename to memcheck/mac_replace_strmem.c
index 0f1ce0778d68b7fe4bdb84a3b6081a30b9e39d0c..f40128fae9ecdffb9f7a845fec600a35d25dddb8 100644 (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 ---*/
 /*--------------------------------------------------------------------*/
index 5cb989316c8288c895ad361e09a40c6de3da4dfb..ffdf83b60fd71b156147faeeb9d53d43fa45a5d9 100644 (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);
 
index 9eb0ae8b31ecde4a32b0fe87acb36c8befe876ec..5539b220eed6a5a062fcbad984ac5fbcf4c76c84 100644 (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                                         ---*/
 /*------------------------------------------------------------*/
index 63aee187b820c5e554f1c2404ec0fc812f513696..40458dcc901b52388d484c942604f4ceec4729d2 100644 (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
index 1c0a29564c0bdd65d55b50aaf4dc7a0b757d2c65..4d7aaf8b1a7b10b541a6894238539e1df7bdb0e9 100755 (executable)
@@ -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                      |
 
index 02180eb020185bfd1c0b815d991ed991575fbe55..6468d486db5f6f64c817b694cb26e59145b74230 100644 (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........: ...