]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
On ppc32/64 we don't have a reliable way to detect function entries
authorJulian Seward <jseward@acm.org>
Mon, 20 Oct 2008 23:33:49 +0000 (23:33 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 20 Oct 2008 23:33:49 +0000 (23:33 +0000)
and exits at the moment.  So disable stack array bounds checking for
ppc32/64 platforms.  Also (unnecessarily) disables global array bounds
checking on those platforms.

Add a flag --enable-sg-checks=no|yes [yes] so that stack and global
checking can be optionally disabled on any platform.  This is useful
because stack and global checking is much more expensive than heap
checking, and so it may be desirable to disable it.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8686

exp-ptrcheck/h_main.c
exp-ptrcheck/pc_common.c
exp-ptrcheck/pc_common.h
exp-ptrcheck/pc_main.c
exp-ptrcheck/sg_main.c

index 426bdbffa5a108fabb278066b20e983ebdf3e2f0..db25fc7498b3092e5b9a005f49566a4470953b28 100644 (file)
@@ -2654,9 +2654,9 @@ static void show_lossage ( void )
 static inline
 void check_load_or_store(Bool is_write, Addr m, UWord sz, Seg* mptr_vseg)
 {
-   if (h_clo_lossage_check) {
-     tl_assert(0);
 #if 0
+   tl_assert(0);
+   if (h_clo_lossage_check) {
       Seg* seg;
       stats__tot_mem_refs++;
       if (ISList__findI0( seglist, (Addr)m, &seg )) {
@@ -2693,8 +2693,8 @@ void check_load_or_store(Bool is_write, Addr m, UWord sz, Seg* mptr_vseg)
             }
          }
       }
-#endif
    } /* clo_lossage_check */
+#endif
 
 #  if SC_SEGS
    checkSeg(mptr_vseg);
@@ -4732,6 +4732,7 @@ void h_fini ( Int exitcode )
                    stats__segs_allocd, stats__segs_recycled);
    }
 
+#if 0
    if (h_clo_lossage_check) {
       VG_(message)(Vg_UserMsg, "");
       VG_(message)(Vg_UserMsg, "%12lld total memory references",
@@ -4746,6 +4747,7 @@ void h_fini ( Int exitcode )
    } else {
       tl_assert( 0 == VG_(OSetGen_Size)(lossage) );
    }
+#endif
 }
 
 
index a08f0f1720dc60532e9f442dd9c5cc2afa98f85f..26c81270f35679b92b386d628c6807ecdbbae0ea 100644 (file)
 //                                                          //
 //////////////////////////////////////////////////////////////
 
-Bool h_clo_partial_loads_ok = True;   /* user visible */
-Bool h_clo_lossage_check    = False;  /* dev flag only */
+Bool h_clo_partial_loads_ok  = True;   /* user visible */
+/* Bool h_clo_lossage_check     = False; */ /* dev flag only */
+Bool sg_clo_enable_sg_checks = True;   /* user visible */
 
 Bool pc_process_cmd_line_options(Char* arg)
 {
         VG_BOOL_CLO(arg, "--partial-loads-ok", h_clo_partial_loads_ok)
-   else VG_BOOL_CLO(arg, "--lossage-check",    h_clo_lossage_check)
+   /* else VG_BOOL_CLO(arg, "--lossage-check",    h_clo_lossage_check) */
+   else VG_BOOL_CLO(arg, "--enable-sg-checks", sg_clo_enable_sg_checks)
    else
       return VG_(replacement_malloc_process_cmd_line_option)(arg);
 
@@ -74,16 +76,19 @@ Bool pc_process_cmd_line_options(Char* arg)
 void pc_print_usage(void)
 {
    VG_(printf)(
-   "    --partial-loads-ok=no|yes same as for Memcheck [yes]\n"
+   "    --partial-loads-ok=no|yes  same as for Memcheck [yes]\n"
+   "    --enable-sg-checks=no|yes  enable stack & global array checking? [yes]\n"
    );
    VG_(replacement_malloc_print_usage)();
 }
 
 void pc_print_debug_usage(void)
 {
+  /*
    VG_(printf)(
-   "    --lossage-check=no|yes gather stats for quality control [no]\n"
+   "    --lossage-check=no|yes    gather stats for quality control [no]\n"
    );
+  */
    VG_(replacement_malloc_print_debug_usage)();
 }
 
index ac4e4d4b746e9a95dff61e7307463cfcf71b7da0..77bab6e08c8efb25e3683c82d48834fa6407ac0a 100644 (file)
@@ -58,7 +58,8 @@ Char* pc_get_error_name ( Error* err );
 void pc_print_extra_suppression_info ( Error* err );
 
 extern Bool h_clo_partial_loads_ok;
-extern Bool h_clo_lossage_check;
+/* extern Bool h_clo_lossage_check; */
+extern Bool sg_clo_enable_sg_checks;
 
 Bool pc_process_cmd_line_options(Char* arg);
 void pc_print_usage(void);
index 1492de313fc318ea8695fe7a3ca48f22b0712d31..3183f9980bc872056de55e01e885acf44b1645c8 100644 (file)
 
 #include "pub_tool_basics.h"
 #include "pub_tool_libcassert.h"
+#include "pub_tool_libcprint.h"
 #include "pub_tool_execontext.h"
 #include "pub_tool_tooliface.h"
 #include "pub_tool_options.h"
 
-//#include "h_list.h"      // Seg
 #include "sg_main.h"
 #include "pc_common.h"
 #include "h_main.h"
@@ -125,6 +125,21 @@ static void pc_post_clo_init ( void )
 {
    h_post_clo_init();
    sg_post_clo_init();
+#  if defined(VGA_x86) || defined(VGA_amd64)
+   /* nothing */
+#  elif defined(VGA_ppc32) || defined(VGA_ppc64)
+   if (VG_(clo_verbosity) >= 1 && sg_clo_enable_sg_checks) {
+      VG_(message)(Vg_UserMsg, 
+         "WARNING: exp-ptrcheck on ppc32/ppc64 platforms: stack and global array");
+      VG_(message)(Vg_UserMsg, 
+         "WARNING: checking is not currently supported.  Only heap checking is");
+      VG_(message)(Vg_UserMsg, 
+         "WARNING: supported.  Disabling s/g checks (like --enable-sg-checks=no).");
+   }
+   sg_clo_enable_sg_checks = False;
+#  else
+#    error "Unsupported architecture"
+#  endif
 }
 
 static void pc_pre_clo_init(void)
index 27a703eae7a7d55829e86e4b69a34338bc37b3c7..e5c82bd1aff95d5ab78e246a2b320eb3fbab4e37 100644 (file)
@@ -2107,6 +2107,9 @@ void sg_instrument_IRStmt ( /*MOD*/struct _SGEnv * env,
                             VexGuestLayout* layout,
                             IRType gWordTy, IRType hWordTy )
 {
+   if (!sg_clo_enable_sg_checks)
+      return;
+
    tl_assert(st);
    tl_assert(isFlatIRStmt(st));
    switch (st->tag) {
@@ -2212,6 +2215,9 @@ void sg_instrument_final_jump ( /*MOD*/struct _SGEnv * env,
                                 VexGuestLayout* layout,
                                 IRType gWordTy, IRType hWordTy )
 {
+   if (!sg_clo_enable_sg_checks)
+      return;
+
    if (jumpkind == Ijk_Call) {
       // Assumes x86 or amd64
       IRTemp   sp_post_call_insn, fp_post_call_insn;