|
From: <sv...@va...> - 2008-10-20 23:34:01
|
Author: sewardj
Date: 2008-10-21 00:33:49 +0100 (Tue, 21 Oct 2008)
New Revision: 8686
Log:
On ppc32/64 we don't have a reliable way to detect function entries
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.
Modified:
trunk/exp-ptrcheck/h_main.c
trunk/exp-ptrcheck/pc_common.c
trunk/exp-ptrcheck/pc_common.h
trunk/exp-ptrcheck/pc_main.c
trunk/exp-ptrcheck/sg_main.c
Modified: trunk/exp-ptrcheck/h_main.c
===================================================================
--- trunk/exp-ptrcheck/h_main.c 2008-10-20 22:27:52 UTC (rev 8685)
+++ trunk/exp-ptrcheck/h_main.c 2008-10-20 23:33:49 UTC (rev 8686)
@@ -2654,9 +2654,9 @@
static inline
void check_load_or_store(Bool is_write, Addr m, UWord sz, Seg* mptr_vseg)
{
+#if 0
+ tl_assert(0);
if (h_clo_lossage_check) {
- tl_assert(0);
-#if 0
Seg* seg;
stats__tot_mem_refs++;
if (ISList__findI0( seglist, (Addr)m, &seg )) {
@@ -2693,8 +2693,8 @@
}
}
}
+ } /* clo_lossage_check */
#endif
- } /* clo_lossage_check */
# if SC_SEGS
checkSeg(mptr_vseg);
@@ -4732,6 +4732,7 @@
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 @@
} else {
tl_assert( 0 == VG_(OSetGen_Size)(lossage) );
}
+#endif
}
Modified: trunk/exp-ptrcheck/pc_common.c
===================================================================
--- trunk/exp-ptrcheck/pc_common.c 2008-10-20 22:27:52 UTC (rev 8685)
+++ trunk/exp-ptrcheck/pc_common.c 2008-10-20 23:33:49 UTC (rev 8686)
@@ -58,13 +58,15 @@
// //
//////////////////////////////////////////////////////////////
-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 @@
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)();
}
Modified: trunk/exp-ptrcheck/pc_common.h
===================================================================
--- trunk/exp-ptrcheck/pc_common.h 2008-10-20 22:27:52 UTC (rev 8685)
+++ trunk/exp-ptrcheck/pc_common.h 2008-10-20 23:33:49 UTC (rev 8686)
@@ -58,7 +58,8 @@
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);
Modified: trunk/exp-ptrcheck/pc_main.c
===================================================================
--- trunk/exp-ptrcheck/pc_main.c 2008-10-20 22:27:52 UTC (rev 8685)
+++ trunk/exp-ptrcheck/pc_main.c 2008-10-20 23:33:49 UTC (rev 8686)
@@ -37,11 +37,11 @@
#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 @@
{
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)
Modified: trunk/exp-ptrcheck/sg_main.c
===================================================================
--- trunk/exp-ptrcheck/sg_main.c 2008-10-20 22:27:52 UTC (rev 8685)
+++ trunk/exp-ptrcheck/sg_main.c 2008-10-20 23:33:49 UTC (rev 8686)
@@ -2107,6 +2107,9 @@
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 @@
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;
|