]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
DRD: Report an error if --free-is-write=yes is used on a program invoking custom...
authorBart Van Assche <bvanassche@acm.org>
Sun, 13 Mar 2011 09:08:10 +0000 (09:08 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sun, 13 Mar 2011 09:08:10 +0000 (09:08 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11640

drd/drd_clientreq.c
drd/drd_clientreq.h
drd/drd_main.c

index a64bd852e8fd2bad0db1d4e9ce748ce8a33c1d16..7e6bdf3a16dbc0b5fffd4bb3f8fc9e532a1b1d5a 100644 (file)
 #include "pub_tool_tooliface.h"   // VG_(needs_...)()
 
 
+/* Global variables. */
+
+Bool DRD_(g_free_is_write);
+
+
 /* Local function declarations. */
 
 static Bool handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret);
@@ -76,6 +81,18 @@ static Bool handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret)
    switch (arg[0])
    {
    case VG_USERREQ__MALLOCLIKE_BLOCK:
+      if (DRD_(g_free_is_write)) {
+         GenericErrInfo GEI = {
+            .tid = DRD_(thread_get_running_tid)(),
+            .addr = 0,
+         };
+         VG_(maybe_record_error)(vg_tid,
+                                 GenericErr,
+                                 VG_(get_IP)(vg_tid),
+                                 "--free-is-write=yes is incompatible with"
+                                 " custom memory allocator client requests",
+                                 &GEI);
+      }
       if (arg[1])
          DRD_(malloclike_block)(vg_tid, arg[1]/*addr*/, arg[2]/*size*/);
       break;
index 57268cbc264989c38550d51a59d2a26a3b92dbe2..c67e48e58a556b6c55ef88e9cc67b2e5a750c003 100644 (file)
@@ -258,6 +258,8 @@ typedef enum {
 } BarrierT;
 
 
+extern Bool DRD_(g_free_is_write);
+
 void DRD_(clientreq_init)(void);
 
 
index da021333fc01456fd827e11ba5521da27cbd1d66..a1729208754b60b4f199b2bf1e8108cc32793c40 100644 (file)
 
 /* Local variables. */
 
-static Bool s_free_is_write    = False;
-static Bool s_print_stats      = False;
-static Bool s_var_info         = False;
-static Bool s_show_stack_usage = False;
-static Bool s_trace_alloc      = False;
+static Bool s_print_stats;
+static Bool s_var_info;
+static Bool s_show_stack_usage;
+static Bool s_trace_alloc;
 
 
 /**
@@ -95,7 +94,7 @@ static Bool DRD_(process_cmd_line_option)(Char* arg)
    if      VG_BOOL_CLO(arg, "--check-stack-var",     check_stack_accesses) {}
    else if VG_BOOL_CLO(arg, "--drd-stats",           s_print_stats) {}
    else if VG_BOOL_CLO(arg, "--first-race-only",     first_race_only) {}
-   else if VG_BOOL_CLO(arg, "--free-is-write",       s_free_is_write) {}
+   else if VG_BOOL_CLO(arg, "--free-is-write",       DRD_(g_free_is_write)) {}
    else if VG_BOOL_CLO(arg,"--report-signal-unlocked",report_signal_unlocked)
    {}
    else if VG_BOOL_CLO(arg, "--segment-merging",     segment_merging) {}
@@ -312,7 +311,7 @@ void drd_start_using_mem(const Addr a1, const SizeT len,
                    a1, len, DRD_(running_thread_inside_pthread_create)()
                    ? " (inside pthread_create())" : "");
 
-   if (!is_stack_mem && s_free_is_write)
+   if (!is_stack_mem && DRD_(g_free_is_write))
       DRD_(thread_stop_using_mem)(a1, a2);
 
    if (UNLIKELY(DRD_(any_address_is_traced)()))
@@ -357,9 +356,9 @@ void drd_stop_using_mem(const Addr a1, const SizeT len,
 
    if (!is_stack_mem || DRD_(get_check_stack_accesses)())
    {
-      if (is_stack_mem || !s_free_is_write)
+      if (is_stack_mem || !DRD_(g_free_is_write))
         DRD_(thread_stop_using_mem)(a1, a2);
-      else if (s_free_is_write)
+      else if (DRD_(g_free_is_write))
         DRD_(trace_store)(a1, len);
       DRD_(clientobj_stop_using_mem)(a1, a2);
       DRD_(suppression_stop_using_mem)(a1, a2);