|
From: <sv...@va...> - 2009-05-02 14:52:36
|
Author: bart
Date: 2009-05-02 15:52:31 +0100 (Sat, 02 May 2009)
New Revision: 9719
Log:
Merged trunk revisions r9153:9164.
Modified:
branches/DRDDEV/Makefile.am
branches/DRDDEV/drd/drd_barrier.c
branches/DRDDEV/drd/drd_barrier.h
branches/DRDDEV/drd/drd_basics.h
branches/DRDDEV/drd/drd_bitmap.c
branches/DRDDEV/drd/drd_clientobj.c
branches/DRDDEV/drd/drd_clientreq.c
branches/DRDDEV/drd/drd_clientreq.h
branches/DRDDEV/drd/drd_error.c
branches/DRDDEV/drd/drd_error.h
branches/DRDDEV/drd/drd_load_store.c
branches/DRDDEV/drd/drd_load_store.h
branches/DRDDEV/drd/drd_main.c
branches/DRDDEV/drd/drd_mutex.c
branches/DRDDEV/drd/drd_mutex.h
branches/DRDDEV/drd/drd_pthread_intercepts.c
branches/DRDDEV/drd/drd_rwlock.c
branches/DRDDEV/drd/drd_rwlock.h
branches/DRDDEV/drd/drd_segment.c
branches/DRDDEV/drd/drd_segment.h
branches/DRDDEV/drd/drd_semaphore.c
branches/DRDDEV/drd/drd_semaphore.h
branches/DRDDEV/drd/drd_suppression.c
branches/DRDDEV/drd/drd_suppression.h
branches/DRDDEV/drd/drd_thread.c
branches/DRDDEV/drd/drd_thread.h
branches/DRDDEV/drd/drd_vc.c
branches/DRDDEV/drd/drd_vc.h
branches/DRDDEV/drd/tests/atomic_var.c
branches/DRDDEV/drd/tests/atomic_var.stderr.exp-with-atomic-builtins-1
branches/DRDDEV/drd/tests/atomic_var.stderr.exp-with-atomic-builtins-2
branches/DRDDEV/drd/tests/drd_bitmap_test.c
branches/DRDDEV/glibc-2.X-drd.supp
branches/DRDDEV/memcheck/mc_machine.c
Modified: branches/DRDDEV/Makefile.am
===================================================================
--- branches/DRDDEV/Makefile.am 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/Makefile.am 2009-05-02 14:52:31 UTC (rev 9719)
@@ -215,26 +215,26 @@
$(CC) @FLAG_M32@ -Wl,--verbose -nostdlib 2>&1 | sed \
-e '1,/^=====\+$$/d' \
-e '/^=====\+$$/,/.\*/d' \
- -e '/\. = 0x[0-9A-Fa-f]\+ + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
+ -e '/\. = \(0x[0-9A-Fa-f]\+\|SEGMENT_START("[^"]\+", 0x[0-9A-Fa-f]\+)\) + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
|| rm -f $@
valt_load_address_amd64_linux.lds: Makefile
$(CC) -m64 -Wl,--verbose -nostdlib 2>&1 | sed \
-e '1,/^=====\+$$/d' \
-e '/^=====\+$$/,/.\*/d' \
- -e '/\. = 0x[0-9A-Fa-f]\+ + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
+ -e '/\. = \(0x[0-9A-Fa-f]\+\|SEGMENT_START("[^"]\+", 0x[0-9A-Fa-f]\+)\) + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
|| rm -f $@
valt_load_address_ppc32_linux.lds: Makefile
$(CC) @FLAG_M32@ -Wl,--verbose -nostdlib 2>&1 | sed \
-e '1,/^=====\+$$/d' \
-e '/^=====\+$$/,/.\*/d' \
- -e '/\. = 0x[0-9A-Fa-f]\+ + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
+ -e '/\. = \(0x[0-9A-Fa-f]\+\|SEGMENT_START("[^"]\+", 0x[0-9A-Fa-f]\+)\) + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
|| rm -f $@
valt_load_address_ppc64_linux.lds: Makefile
$(CC) -m64 -Wl,--verbose -nostdlib 2>&1 | sed \
-e '1,/^=====\+$$/d' \
-e '/^=====\+$$/,/.\*/d' \
- -e '/\. = 0x[0-9A-Fa-f]\+ + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
+ -e '/\. = \(0x[0-9A-Fa-f]\+\|SEGMENT_START("[^"]\+", 0x[0-9A-Fa-f]\+)\) + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/valt_load_address/g' > $@ \
|| rm -f $@
Modified: branches/DRDDEV/drd/drd_barrier.c
===================================================================
--- branches/DRDDEV/drd/drd_barrier.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_barrier.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -85,8 +85,8 @@
static void barrier_thread_destroy(struct barrier_thread_info* const p)
{
tl_assert(p);
- sg_put(p->sg[0]);
- sg_put(p->sg[1]);
+ DRD_(sg_put)(p->sg[0]);
+ DRD_(sg_put)(p->sg[1]);
}
/** Initialize the structure *p with the specified client-side barrier address,
Modified: branches/DRDDEV/drd/drd_barrier.h
===================================================================
--- branches/DRDDEV/drd/drd_barrier.h 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_barrier.h 2009-05-02 14:52:31 UTC (rev 9719)
@@ -23,7 +23,7 @@
*/
-// Barrier state information.
+/* Barrier state information. */
#ifndef __DRD_BARRIER_H
@@ -32,7 +32,6 @@
#include "drd_clientreq.h" // BarrierT
#include "drd_thread.h" // DrdThreadId
-#include "drd_vc.h"
#include "pub_tool_basics.h" // Addr
Modified: branches/DRDDEV/drd/drd_basics.h
===================================================================
--- branches/DRDDEV/drd/drd_basics.h 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_basics.h 2009-05-02 14:52:31 UTC (rev 9719)
@@ -35,4 +35,7 @@
#define DRD_(str) VGAPPEND(vgDrd_, str)
+typedef UInt DrdThreadId;
+
+
#endif /* __DRD_BASICS_H */
Modified: branches/DRDDEV/drd/drd_bitmap.c
===================================================================
--- branches/DRDDEV/drd/drd_bitmap.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_bitmap.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -877,7 +877,7 @@
| ((bm1r->bm0_r[k] & bm0_mask(b)) ? RHS_R : 0)
| ((bm1r->bm0_w[k] & bm0_mask(b)) ? RHS_W : 0);
Addr const a = make_address(bm2l->addr, k * BITS_PER_UWORD | b);
- if (HAS_RACE(access_mask) && ! drd_is_suppressed(a, a + 1))
+ if (HAS_RACE(access_mask) && ! DRD_(is_suppressed)(a, a + 1))
{
return 1;
}
Modified: branches/DRDDEV/drd/drd_clientobj.c
===================================================================
--- branches/DRDDEV/drd/drd_clientobj.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_clientobj.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -134,7 +134,7 @@
p->any.first_observed_at = VG_(record_ExeContext)(VG_(get_running_tid)(), 0);
VG_(OSetGen_Insert)(s_clientobj, p);
tl_assert(VG_(OSetGen_Lookup)(s_clientobj, &a1) == p);
- drd_start_suppression(a1, a1 + 1, "clientobj");
+ DRD_(start_suppression)(a1, a1 + 1, "clientobj");
return p;
}
@@ -173,7 +173,7 @@
tl_assert(s_clientobj);
- if (! drd_is_any_suppressed(a1, a2))
+ if (! DRD_(is_any_suppressed)(a1, a2))
return;
VG_(OSetGen_ResetIter)(s_clientobj);
Modified: branches/DRDDEV/drd/drd_clientreq.c
===================================================================
--- branches/DRDDEV/drd/drd_clientreq.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_clientreq.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -47,48 +47,15 @@
static Addr DRD_(highest_used_stack_address)(const ThreadId vg_tid);
+/* Function definitions. */
+
/**
- * Walk the stack up to the highest stack frame, and return the stack pointer
- * of the highest stack frame. It is assumed that there are no more than
- * ten stack frames above the current frame. This should be no problem
- * since this function is either called indirectly from the _init() function
- * in vgpreload_exp-drd-*.so or from the thread wrapper for a newly created
- * thread. See also drd_pthread_intercepts.c.
+ * Tell the Valgrind core the address of the DRD function that processes
+ * client requests. Must be called before any client code is run.
*/
-static Addr DRD_(highest_used_stack_address)(const ThreadId vg_tid)
+void DRD_(clientreq_init)(void)
{
- UInt nframes;
- const UInt n_ips = 10;
- UInt i;
- Addr ips[n_ips], sps[n_ips];
- Addr husa;
-
- nframes = VG_(get_StackTrace)(vg_tid, ips, n_ips, sps, 0, 0);
- tl_assert(1 <= nframes && nframes <= n_ips);
-
- /* A hack to work around VG_(get_StackTrace)()'s behavior that sometimes */
- /* the topmost stackframes it returns are bogus (this occurs sometimes */
- /* at least on amd64, ppc32 and ppc64). */
-
- husa = sps[0];
-
- tl_assert(VG_(thread_get_stack_max)(vg_tid)
- - VG_(thread_get_stack_size)(vg_tid) <= husa
- && husa < VG_(thread_get_stack_max)(vg_tid));
-
- for (i = 1; i < nframes; i++)
- {
- if (sps[i] == 0)
- break;
- if (husa < sps[i] && sps[i] < VG_(thread_get_stack_max)(vg_tid))
- husa = sps[i];
- }
-
- tl_assert(VG_(thread_get_stack_max)(vg_tid)
- - VG_(thread_get_stack_size)(vg_tid) <= husa
- && husa < VG_(thread_get_stack_max)(vg_tid));
-
- return husa;
+ VG_(needs_client_requests)(DRD_(handle_client_request));
}
/**
@@ -115,11 +82,11 @@
break;
case VG_USERREQ__DRD_START_SUPPRESSION:
- drd_start_suppression(arg[1], arg[1] + arg[2], "client");
+ DRD_(start_suppression)(arg[1], arg[1] + arg[2], "client");
break;
case VG_USERREQ__DRD_FINISH_SUPPRESSION:
- drd_finish_suppression(arg[1], arg[1] + arg[2]);
+ DRD_(finish_suppression)(arg[1], arg[1] + arg[2]);
break;
case VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK:
@@ -143,8 +110,8 @@
}
#endif
thread_set_stack_startup(drd_tid, VG_(get_SP)(vg_tid));
- drd_start_suppression(topmost_sp, VG_(thread_get_stack_max)(vg_tid),
- "stack top");
+ DRD_(start_suppression)(topmost_sp, VG_(thread_get_stack_max)(vg_tid),
+ "stack top");
break;
}
@@ -153,11 +120,11 @@
break;
case VG_USERREQ__DRD_START_TRACE_ADDR:
- drd_start_tracing_address_range(arg[1], arg[1] + arg[2]);
+ DRD_(start_tracing_address_range)(arg[1], arg[1] + arg[2]);
break;
case VG_USERREQ__DRD_STOP_TRACE_ADDR:
- drd_stop_tracing_address_range(arg[1], arg[1] + arg[2]);
+ DRD_(stop_tracing_address_range)(arg[1], arg[1] + arg[2]);
break;
case VG_USERREQ__DRD_STOP_RECORDING:
@@ -411,10 +378,45 @@
}
/**
- * Tell the Valgrind core the address of the DRD function that processes
- * client requests. Must be called before any client code is run.
+ * Walk the stack up to the highest stack frame, and return the stack pointer
+ * of the highest stack frame. It is assumed that there are no more than
+ * ten stack frames above the current frame. This should be no problem
+ * since this function is either called indirectly from the _init() function
+ * in vgpreload_exp-drd-*.so or from the thread wrapper for a newly created
+ * thread. See also drd_pthread_intercepts.c.
*/
-void DRD_(clientreq_init)(void)
+static Addr DRD_(highest_used_stack_address)(const ThreadId vg_tid)
{
- VG_(needs_client_requests)(DRD_(handle_client_request));
+ UInt nframes;
+ const UInt n_ips = 10;
+ UInt i;
+ Addr ips[n_ips], sps[n_ips];
+ Addr husa;
+
+ nframes = VG_(get_StackTrace)(vg_tid, ips, n_ips, sps, 0, 0);
+ tl_assert(1 <= nframes && nframes <= n_ips);
+
+ /* A hack to work around VG_(get_StackTrace)()'s behavior that sometimes */
+ /* the topmost stackframes it returns are bogus (this occurs sometimes */
+ /* at least on amd64, ppc32 and ppc64). */
+
+ husa = sps[0];
+
+ tl_assert(VG_(thread_get_stack_max)(vg_tid)
+ - VG_(thread_get_stack_size)(vg_tid) <= husa
+ && husa < VG_(thread_get_stack_max)(vg_tid));
+
+ for (i = 1; i < nframes; i++)
+ {
+ if (sps[i] == 0)
+ break;
+ if (husa < sps[i] && sps[i] < VG_(thread_get_stack_max)(vg_tid))
+ husa = sps[i];
+ }
+
+ tl_assert(VG_(thread_get_stack_max)(vg_tid)
+ - VG_(thread_get_stack_size)(vg_tid) <= husa
+ && husa < VG_(thread_get_stack_max)(vg_tid));
+
+ return husa;
}
Modified: branches/DRDDEV/drd/drd_clientreq.h
===================================================================
--- branches/DRDDEV/drd/drd_clientreq.h 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_clientreq.h 2009-05-02 14:52:31 UTC (rev 9719)
@@ -22,6 +22,7 @@
The GNU General Public License is contained in the file COPYING.
*/
+
/*
* This header file contains the tool-internal interface for the code that
* processes client requests.
Modified: branches/DRDDEV/drd/drd_error.c
===================================================================
--- branches/DRDDEV/drd/drd_error.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_error.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -413,7 +413,7 @@
}
}
-void drd_register_error_handlers(void)
+void DRD_(register_error_handlers)(void)
{
// Tool error reporting.
VG_(needs_tool_errors)(drd_tool_error_eq,
Modified: branches/DRDDEV/drd/drd_error.h
===================================================================
--- branches/DRDDEV/drd/drd_error.h 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_error.h 2009-05-02 14:52:31 UTC (rev 9719)
@@ -148,7 +148,7 @@
void set_show_conflicting_segments(const Bool scs);
-void drd_register_error_handlers(void);
+void DRD_(register_error_handlers)(void);
#endif /* __DRD_ERROR_H */
Modified: branches/DRDDEV/drd/drd_load_store.c
===================================================================
--- branches/DRDDEV/drd/drd_load_store.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_load_store.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -24,6 +24,7 @@
#include "drd_bitmap.h"
#include "drd_thread_bitmap.h"
+#include "drd_vc.h" /* DRD_(vc_snprint)() */
/* Include several source files here in order to allow the compiler to */
/* do more inlining. */
@@ -67,13 +68,13 @@
s_drd_check_stack_accesses = c;
}
-void drd_trace_mem_access(const Addr addr, const SizeT size,
+void DRD_(trace_mem_access)(const Addr addr, const SizeT size,
const BmAccessTypeT access_type)
{
- if (drd_is_any_traced(addr, addr + size))
+ if (DRD_(is_any_traced)(addr, addr + size))
{
char vc[80];
- vc_snprint(vc, sizeof(vc), thread_get_vc(thread_get_running_tid()));
+ DRD_(vc_snprint)(vc, sizeof(vc), thread_get_vc(thread_get_running_tid()));
VG_(message)(Vg_UserMsg,
"%s 0x%lx size %ld (vg %d / drd %d / vc %s)",
access_type == eLoad
@@ -99,12 +100,12 @@
static VG_REGPARM(2) void drd_trace_mem_load(const Addr addr, const SizeT size)
{
- return drd_trace_mem_access(addr, size, eLoad);
+ return DRD_(trace_mem_access)(addr, size, eLoad);
}
static VG_REGPARM(2) void drd_trace_mem_store(const Addr addr,const SizeT size)
{
- return drd_trace_mem_access(addr, size, eStore);
+ return DRD_(trace_mem_access)(addr, size, eStore);
}
static void drd_report_race(const Addr addr, const SizeT size,
@@ -134,7 +135,7 @@
if (running_thread_is_recording()
&& (s_drd_check_stack_accesses || ! thread_address_on_stack(addr))
&& bm_access_load_triggers_conflict(addr, addr + size)
- && ! drd_is_suppressed(addr, addr + size))
+ && ! DRD_(is_suppressed)(addr, addr + size))
{
drd_report_race(addr, size, eLoad);
}
@@ -145,7 +146,7 @@
if (running_thread_is_recording()
&& (s_drd_check_stack_accesses || ! thread_address_on_stack(addr))
&& bm_access_load_1_triggers_conflict(addr)
- && ! drd_is_suppressed(addr, addr + 1))
+ && ! DRD_(is_suppressed)(addr, addr + 1))
{
drd_report_race(addr, 1, eLoad);
}
@@ -156,7 +157,7 @@
if (running_thread_is_recording()
&& (s_drd_check_stack_accesses || ! thread_address_on_stack(addr))
&& bm_access_load_2_triggers_conflict(addr)
- && ! drd_is_suppressed(addr, addr + 2))
+ && ! DRD_(is_suppressed)(addr, addr + 2))
{
drd_report_race(addr, 2, eLoad);
}
@@ -167,7 +168,7 @@
if (running_thread_is_recording()
&& (s_drd_check_stack_accesses || ! thread_address_on_stack(addr))
&& bm_access_load_4_triggers_conflict(addr)
- && ! drd_is_suppressed(addr, addr + 4))
+ && ! DRD_(is_suppressed)(addr, addr + 4))
{
drd_report_race(addr, 4, eLoad);
}
@@ -178,7 +179,7 @@
if (running_thread_is_recording()
&& (s_drd_check_stack_accesses || ! thread_address_on_stack(addr))
&& bm_access_load_8_triggers_conflict(addr)
- && ! drd_is_suppressed(addr, addr + 8))
+ && ! DRD_(is_suppressed)(addr, addr + 8))
{
drd_report_race(addr, 8, eLoad);
}
@@ -195,7 +196,7 @@
if (running_thread_is_recording()
&& (s_drd_check_stack_accesses || ! thread_address_on_stack(addr))
&& bm_access_store_triggers_conflict(addr, addr + size)
- && ! drd_is_suppressed(addr, addr + size))
+ && ! DRD_(is_suppressed)(addr, addr + size))
{
drd_report_race(addr, size, eStore);
}
@@ -206,7 +207,7 @@
if (running_thread_is_recording()
&& (s_drd_check_stack_accesses || ! thread_address_on_stack(addr))
&& bm_access_store_1_triggers_conflict(addr)
- && ! drd_is_suppressed(addr, addr + 1))
+ && ! DRD_(is_suppressed)(addr, addr + 1))
{
drd_report_race(addr, 1, eStore);
}
@@ -217,7 +218,7 @@
if (running_thread_is_recording()
&& (s_drd_check_stack_accesses || ! thread_address_on_stack(addr))
&& bm_access_store_2_triggers_conflict(addr)
- && ! drd_is_suppressed(addr, addr + 2))
+ && ! DRD_(is_suppressed)(addr, addr + 2))
{
drd_report_race(addr, 2, eStore);
}
@@ -228,7 +229,7 @@
if (running_thread_is_recording()
&& (s_drd_check_stack_accesses || ! thread_address_on_stack(addr))
&& bm_access_store_4_triggers_conflict(addr)
- && ! drd_is_suppressed(addr, addr + 4))
+ && ! DRD_(is_suppressed)(addr, addr + 4))
{
drd_report_race(addr, 4, eStore);
}
@@ -239,7 +240,7 @@
if (running_thread_is_recording()
&& (s_drd_check_stack_accesses || ! thread_address_on_stack(addr))
&& bm_access_store_8_triggers_conflict(addr)
- && ! drd_is_suppressed(addr, addr + 8))
+ && ! DRD_(is_suppressed)(addr, addr + 8))
{
drd_report_race(addr, 8, eStore);
}
@@ -285,7 +286,7 @@
IRExpr** argv;
IRDirty* di;
- if (UNLIKELY(drd_any_address_is_traced()))
+ if (UNLIKELY(DRD_(any_address_is_traced)()))
{
addStmtToIRSB(bb,
IRStmt_Dirty(
@@ -350,7 +351,7 @@
IRExpr** argv;
IRDirty* di;
- if (UNLIKELY(drd_any_address_is_traced()))
+ if (UNLIKELY(DRD_(any_address_is_traced)()))
{
addStmtToIRSB(bb,
IRStmt_Dirty(
@@ -407,7 +408,7 @@
addStmtToIRSB(bb, IRStmt_Dirty(di));
}
-IRSB* drd_instrument(VgCallbackClosure* const closure,
+IRSB* DRD_(instrument)(VgCallbackClosure* const closure,
IRSB* const bb_in,
VexGuestLayout* const layout,
VexGuestExtents* const vge,
Modified: branches/DRDDEV/drd/drd_load_store.h
===================================================================
--- branches/DRDDEV/drd/drd_load_store.h 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_load_store.h 2009-05-02 14:52:31 UTC (rev 9719)
@@ -37,14 +37,14 @@
Bool DRD_(get_check_stack_accesses)(void);
void DRD_(set_check_stack_accesses)(const Bool c);
-IRSB* drd_instrument(VgCallbackClosure* const closure,
- IRSB* const bb_in,
- VexGuestLayout* const layout,
- VexGuestExtents* const vge,
- IRType const gWordTy,
- IRType const hWordTy);
-void drd_trace_mem_access(const Addr addr, const SizeT size,
- const BmAccessTypeT access_type);
+IRSB* DRD_(instrument)(VgCallbackClosure* const closure,
+ IRSB* const bb_in,
+ VexGuestLayout* const layout,
+ VexGuestExtents* const vge,
+ IRType const gWordTy,
+ IRType const hWordTy);
+void DRD_(trace_mem_access)(const Addr addr, const SizeT size,
+ const BmAccessTypeT access_type);
VG_REGPARM(2) void drd_trace_load(Addr addr, SizeT size);
VG_REGPARM(2) void drd_trace_store(Addr addr, SizeT size);
Modified: branches/DRDDEV/drd/drd_main.c
===================================================================
--- branches/DRDDEV/drd/drd_main.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_main.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -35,7 +35,6 @@
#include "drd_semaphore.h"
#include "drd_suppression.h"
#include "drd_thread.h"
-#include "drd_vc.h"
#include "libvex_guest_offsets.h"
#include "pub_drd_bitmap.h"
#include "pub_tool_vki.h" // Must be included before pub_tool_libcproc
@@ -53,24 +52,18 @@
#include "pub_tool_tooliface.h"
-// Function declarations.
+/* Local variables. */
-static void drd_start_client_code(const ThreadId tid, const ULong bbs_done);
+static Bool DRD_(s_drd_first_race_only) = False;
+static Bool DRD_(s_print_stats) = False;
+static Bool DRD_(s_var_info) = False;
+static Bool DRD_(s_show_stack_usage) = False;
-// Local variables.
-
-static Bool s_drd_print_stats = False;
-static Bool s_drd_var_info = False;
-static Bool s_drd_first_race_only = False;
-static Bool s_show_stack_usage = False;
-
-
-//
-// Implement the needs_command_line_options for drd.
-//
-
-static Bool drd_process_cmd_line_option(Char* arg)
+/**
+ * Implement the needs_command_line_options for drd.
+ */
+static Bool DRD_(process_cmd_line_option)(Char* arg)
{
int check_stack_accesses = -1;
int exclusive_threshold_ms = -1;
@@ -91,12 +84,12 @@
Char* trace_address = 0;
VG_BOOL_CLO (arg, "--check-stack-var", check_stack_accesses)
- else VG_BOOL_CLO(arg, "--drd-stats", s_drd_print_stats)
- else VG_BOOL_CLO(arg, "--first-race-only", s_drd_first_race_only)
+ else VG_BOOL_CLO(arg, "--drd-stats", DRD_(s_print_stats))
+ else VG_BOOL_CLO(arg, "--first-race-only", DRD_(s_drd_first_race_only))
else VG_BOOL_CLO(arg,"--report-signal-unlocked",s_drd_report_signal_unlocked)
else VG_BOOL_CLO(arg, "--segment-merging", segment_merging)
else VG_BOOL_CLO(arg, "--show-confl-seg", show_confl_seg)
- else VG_BOOL_CLO(arg, "--show-stack-usage", s_show_stack_usage)
+ else VG_BOOL_CLO(arg, "--show-stack-usage", DRD_(s_show_stack_usage))
else VG_BOOL_CLO(arg, "--trace-barrier", trace_barrier)
else VG_BOOL_CLO(arg, "--trace-clientobj", trace_clientobj)
else VG_BOOL_CLO(arg, "--trace-cond", trace_cond)
@@ -108,7 +101,7 @@
else VG_BOOL_CLO(arg, "--trace-segment", trace_segment)
else VG_BOOL_CLO(arg, "--trace-semaphore", trace_semaphore)
else VG_BOOL_CLO(arg, "--trace-suppr", trace_suppression)
- else VG_BOOL_CLO(arg, "--var-info", s_drd_var_info)
+ else VG_BOOL_CLO(arg, "--var-info", DRD_(s_var_info))
else VG_NUM_CLO (arg, "--exclusive-threshold", exclusive_threshold_ms)
else VG_NUM_CLO (arg, "--shared-threshold", shared_threshold_ms)
else VG_STR_CLO (arg, "--trace-addr", trace_address)
@@ -133,7 +126,7 @@
if (trace_address)
{
const Addr addr = VG_(strtoll16)(trace_address, 0);
- drd_start_tracing_address_range(addr, addr + 1);
+ DRD_(start_tracing_address_range)(addr, addr + 1);
}
if (trace_barrier != -1)
barrier_set_trace(trace_barrier);
@@ -152,16 +145,16 @@
if (trace_rwlock != -1)
rwlock_set_trace(trace_rwlock);
if (trace_segment != -1)
- sg_set_trace(trace_segment);
+ DRD_(sg_set_trace)(trace_segment);
if (trace_semaphore != -1)
semaphore_set_trace(trace_semaphore);
if (trace_suppression != -1)
- suppression_set_trace(trace_suppression);
+ DRD_(suppression_set_trace)(trace_suppression);
return True;
}
-static void drd_print_usage(void)
+static void DRD_(print_usage)(void)
{
VG_(printf)(
" --check-stack-var=yes|no Whether or not to report data races on\n"
@@ -203,7 +196,7 @@
VG_(replacement_malloc_print_usage)();
}
-static void drd_print_debug_usage(void)
+static void DRD_(print_debug_usage)(void)
{
VG_(printf)(
" --drd-stats=yes|no Print statistics about DRD activity [no].\n"
@@ -273,9 +266,9 @@
{
tl_assert(a1 < a1 + len);
- if (UNLIKELY(drd_any_address_is_traced()))
+ if (UNLIKELY(DRD_(any_address_is_traced)()))
{
- drd_trace_mem_access(a1, len, eStart);
+ DRD_(trace_mem_access)(a1, len, eStart);
}
}
@@ -301,15 +294,15 @@
tl_assert(a1 < a2);
- if (UNLIKELY(drd_any_address_is_traced()))
+ if (UNLIKELY(DRD_(any_address_is_traced)()))
{
- drd_trace_mem_access(a1, len, eEnd);
+ DRD_(trace_mem_access)(a1, len, eEnd);
}
if (! is_stack_mem || DRD_(get_check_stack_accesses)())
{
thread_stop_using_mem(a1, a2);
clientobj_stop_using_mem(a1, a2);
- drd_suppression_stop_using_mem(a1, a2);
+ DRD_(suppression_stop_using_mem)(a1, a2);
}
}
@@ -319,16 +312,17 @@
drd_stop_using_mem(a1, len, False);
}
-/** Suppress data race reports on all addresses contained in .plt and
- * .got.plt sections inside the address range [ a, a + len [. The data in
- * these sections is modified by _dl_relocate_object() every time a function
- * in a shared library is called for the first time. Since the first call
- * to a function in a shared library can happen from a multithreaded context,
- * such calls can cause conflicting accesses. See also Ulrich Drepper's
- * paper "How to Write Shared Libraries" for more information about relocation
- * (http://people.redhat.com/drepper/dsohowto.pdf).
+/**
+ * Suppress data race reports on all addresses contained in .plt and
+ * .got.plt sections inside the address range [ a, a + len [. The data in
+ * these sections is modified by _dl_relocate_object() every time a function
+ * in a shared library is called for the first time. Since the first call
+ * to a function in a shared library can happen from a multithreaded context,
+ * such calls can cause conflicting accesses. See also Ulrich Drepper's
+ * paper "How to Write Shared Libraries" for more information about relocation
+ * (http://people.redhat.com/drepper/dsohowto.pdf).
*/
-static void suppress_relocation_conflicts(const Addr a, const SizeT len)
+static void DRD_(suppress_relocation_conflicts)(const Addr a, const SizeT len)
{
const DebugInfo* di;
@@ -350,7 +344,7 @@
VG_(printf)("Suppressing .plt @ 0x%lx size %ld\n", avma, size);
#endif
tl_assert(VG_(seginfo_sect_kind)(NULL, 0, avma) == Vg_SectPLT);
- drd_start_suppression(avma, avma + size, ".plt");
+ DRD_(start_suppression)(avma, avma + size, ".plt");
}
avma = VG_(seginfo_get_gotplt_avma)(di);
@@ -362,7 +356,7 @@
VG_(printf)("Suppressing .got.plt @ 0x%lx size %ld\n", avma, size);
#endif
tl_assert(VG_(seginfo_sect_kind)(NULL, 0, avma) == Vg_SectGOTPLT);
- drd_start_suppression(avma, avma + size, ".gotplt");
+ DRD_(start_suppression)(avma, avma + size, ".gotplt");
}
}
}
@@ -376,7 +370,7 @@
drd_start_using_mem(a, len);
- suppress_relocation_conflicts(a, len);
+ DRD_(suppress_relocation_conflicts)(a, len);
}
/* Called by the core when the stack of a thread grows, to indicate that */
@@ -452,10 +446,10 @@
}
if (! DRD_(get_check_stack_accesses)())
{
- drd_start_suppression(thread_get_stack_max(drd_created)
- - thread_get_stack_size(drd_created),
- thread_get_stack_max(drd_created),
- "stack");
+ DRD_(start_suppression)(thread_get_stack_max(drd_created)
+ - thread_get_stack_size(drd_created),
+ thread_get_stack_max(drd_created),
+ "stack");
}
}
@@ -477,7 +471,7 @@
? ""
: " (which is a detached thread)");
}
- if (s_show_stack_usage)
+ if (DRD_(s_show_stack_usage))
{
const SizeT stack_size = thread_get_stack_size(drd_tid);
const SizeT used_stack
@@ -507,8 +501,7 @@
// Implementation of the tool interface.
//
-static
-void drd_post_clo_init(void)
+static void DRD_(post_clo_init)(void)
{
# if defined(VGP_x86_linux) || defined(VGP_amd64_linux) \
|| defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux)
@@ -517,7 +510,7 @@
VG_(printf)("\nWARNING: DRD has only been tested on Linux.\n\n");
# endif
- if (s_drd_var_info)
+ if (DRD_(s_var_info))
{
VG_(needs_var_info)();
}
@@ -529,11 +522,10 @@
thread_set_vg_running_tid(tid);
}
-static
-void drd_fini(Int exitcode)
+static void DRD_(fini)(Int exitcode)
{
// thread_print_all();
- if (VG_(clo_verbosity) > 1 || s_drd_print_stats)
+ if (VG_(clo_verbosity) > 1 || DRD_(s_print_stats))
{
ULong update_conflict_set_count;
ULong dsnsc;
@@ -558,8 +550,8 @@
VG_(message)(Vg_UserMsg,
" segments: created %lld segments, max %lld alive,"
" %lld discard points,",
- sg_get_created_segments_count(),
- sg_get_max_alive_segments_count(),
+ DRD_(sg_get_segments_created_count)(),
+ DRD_(sg_get_max_segments_alive_count)(),
thread_get_discard_ordered_segments_count());
VG_(message)(Vg_UserMsg,
" %lld merges.",
@@ -601,17 +593,17 @@
" by Bart Van Assche.");
VG_(details_bug_reports_to) (VG_BUGS_TO);
- VG_(basic_tool_funcs) (drd_post_clo_init,
- drd_instrument,
- drd_fini);
+ VG_(basic_tool_funcs) (DRD_(post_clo_init),
+ DRD_(instrument),
+ DRD_(fini));
// Command line stuff.
- VG_(needs_command_line_options)(drd_process_cmd_line_option,
- drd_print_usage,
- drd_print_debug_usage);
+ VG_(needs_command_line_options)(DRD_(process_cmd_line_option),
+ DRD_(print_usage),
+ DRD_(print_debug_usage));
// Error handling.
- drd_register_error_handlers();
+ DRD_(register_error_handlers)();
// Core event tracking.
VG_(track_pre_mem_read) (drd_pre_mem_read);
@@ -637,7 +629,7 @@
DRD_(clientreq_init)();
- drd_suppression_init();
+ DRD_(suppression_init)();
clientobj_init();
}
Modified: branches/DRDDEV/drd/drd_mutex.c
===================================================================
--- branches/DRDDEV/drd/drd_mutex.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_mutex.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -107,7 +107,7 @@
&MEI);
}
- sg_put(p->last_locked_segment);
+ DRD_(sg_put)(p->last_locked_segment);
p->last_locked_segment = 0;
}
Modified: branches/DRDDEV/drd/drd_mutex.h
===================================================================
--- branches/DRDDEV/drd/drd_mutex.h 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_mutex.h 2009-05-02 14:52:31 UTC (rev 9719)
@@ -29,7 +29,6 @@
#include "drd_clientreq.h" // MutexT
#include "drd_thread.h" // DrdThreadId
-#include "drd_vc.h"
#include "pub_tool_basics.h" // Addr
Modified: branches/DRDDEV/drd/drd_pthread_intercepts.c
===================================================================
--- branches/DRDDEV/drd/drd_pthread_intercepts.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_pthread_intercepts.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -40,9 +40,9 @@
------------------------------------------------------------------ */
/*
- Define _GNU_SOURCE to make sure that pthread_spinlock_t is available when
- compiling with older glibc versions (2.3 or before).
-*/
+ * Define _GNU_SOURCE to make sure that pthread_spinlock_t is available when
+ * compiling with older glibc versions (2.3 or before).
+ */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
@@ -73,7 +73,8 @@
void* (*start)(void*);
void* arg;
int detachstate;
-} VgPosixThreadArgs;
+ int wrapper_started;
+} DrdPosixThreadArgs;
/* Local function declarations. */
@@ -173,21 +174,16 @@
static void* DRD_(thread_wrapper)(void* arg)
{
int res;
- VgPosixThreadArgs* arg_ptr;
- VgPosixThreadArgs arg_copy;
+ DrdPosixThreadArgs* arg_ptr;
+ DrdPosixThreadArgs arg_copy;
VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK,
0, 0, 0, 0, 0);
- arg_ptr = (VgPosixThreadArgs*)arg;
+ arg_ptr = (DrdPosixThreadArgs*)arg;
arg_copy = *arg_ptr;
+ arg_ptr->wrapper_started = 1;
- /*
- * Free the memory 'arg_ptr' points at now such that it does not get
- * leaked when the function called below throws a C++ exception.
- */
- free(arg_ptr);
-
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SET_PTHREADID,
pthread_self(), 0, 0, 0, 0);
@@ -276,42 +272,52 @@
int res;
int ret;
OrigFn fn;
- VgPosixThreadArgs* vgargs;
+ DrdPosixThreadArgs thread_args;
VALGRIND_GET_ORIG_FN(fn);
- vgargs = malloc(sizeof *vgargs);
- assert(vgargs);
- vgargs->start = start;
- vgargs->arg = arg;
+ DRD_IGNORE_VAR(thread_args.wrapper_started);
+ thread_args.start = start;
+ thread_args.arg = arg;
+ thread_args.wrapper_started = 0;
/*
* Find out whether the thread will be started as a joinable thread
* or as a detached thread. If no thread attributes have been specified,
* the new thread will be started as a joinable thread.
*/
- vgargs->detachstate = PTHREAD_CREATE_JOINABLE;
+ thread_args.detachstate = PTHREAD_CREATE_JOINABLE;
if (attr)
{
- if (pthread_attr_getdetachstate(attr, &vgargs->detachstate) != 0)
+ if (pthread_attr_getdetachstate(attr, &thread_args.detachstate) != 0)
{
assert(0);
}
}
- assert(vgargs->detachstate == PTHREAD_CREATE_JOINABLE
- || vgargs->detachstate == PTHREAD_CREATE_DETACHED);
+ assert(thread_args.detachstate == PTHREAD_CREATE_JOINABLE
+ || thread_args.detachstate == PTHREAD_CREATE_DETACHED);
/* Suppress NPTL-specific conflicts between creator and created thread. */
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__DRD_STOP_RECORDING,
0, 0, 0, 0, 0);
- CALL_FN_W_WWWW(ret, fn, thread, attr, DRD_(thread_wrapper), vgargs);
+ CALL_FN_W_WWWW(ret, fn, thread, attr, DRD_(thread_wrapper), &thread_args);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__DRD_START_RECORDING,
0, 0, 0, 0, 0);
- /* Free the memory 'vgargs' points at if pthread_create() failed. */
- if (ret != 0)
- free(vgargs);
+ if (ret == 0)
+ {
+ /*
+ * Wait until the thread wrapper started.
+ * @todo Find out why some regression tests fail if thread arguments are
+ * passed via dynamically allocated memory and if the loop below is
+ * removed.
+ */
+ while (! thread_args.wrapper_started)
+ {
+ sched_yield();
+ }
+ }
return ret;
}
Modified: branches/DRDDEV/drd/drd_rwlock.c
===================================================================
--- branches/DRDDEV/drd/drd_rwlock.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_rwlock.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -215,7 +215,7 @@
VG_(OSetGen_ResetIter)(p->thread_info);
for ( ; (q = VG_(OSetGen_Next)(p->thread_info)) != 0; )
{
- sg_put(q->last_unlock_segment);
+ DRD_(sg_put)(q->last_unlock_segment);
}
VG_(OSetGen_Destroy)(p->thread_info);
}
Modified: branches/DRDDEV/drd/drd_rwlock.h
===================================================================
--- branches/DRDDEV/drd/drd_rwlock.h 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_rwlock.h 2009-05-02 14:52:31 UTC (rev 9719)
@@ -32,7 +32,6 @@
#include "drd_clientobj.h" // struct rwlock_info
#include "drd_thread.h" // DrdThreadId
-#include "drd_vc.h"
#include "pub_tool_basics.h" // Addr
Modified: branches/DRDDEV/drd/drd_segment.c
===================================================================
--- branches/DRDDEV/drd/drd_segment.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_segment.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -36,24 +36,25 @@
#include "pub_tool_threadstate.h" // VG_INVALID_THREADID
-// Local variables.
+/* Local variables. */
-static ULong s_created_segments_count;
-static ULong s_alive_segments_count;
-static ULong s_max_alive_segments_count;
-static ULong s_segment_merge_count;
-static Bool drd_trace_segment = False;
+static ULong DRD_(s_segments_created_count);
+static ULong DRD_(s_segments_alive_count);
+static ULong DRD_(s_max_segments_alive_count);
+static ULong DRD_(s_segment_merge_count);
+static Bool DRD_(s_trace_segment) = False;
-// Function definitions.
+/* Function definitions. */
-/** Initialize the memory pointed at by sg.
+/**
+ * Initialize the memory 'sg' points at.
* @note The creator and created thread ID's may be equal.
*/
static
-void sg_init(Segment* const sg,
- DrdThreadId const creator,
- DrdThreadId const created)
+void DRD_(sg_init)(Segment* const sg,
+ DrdThreadId const creator,
+ DrdThreadId const created)
{
Segment* creator_sg;
ThreadId vg_created = DrdThreadIdToVgThreadId(created);
@@ -74,13 +75,13 @@
sg->stacktrace = 0;
if (creator_sg)
- vc_copy(&sg->vc, &creator_sg->vc);
+ DRD_(vc_copy)(&sg->vc, &creator_sg->vc);
else
- vc_init(&sg->vc, 0, 0);
- vc_increment(&sg->vc, created);
+ DRD_(vc_init)(&sg->vc, 0, 0);
+ DRD_(vc_increment)(&sg->vc, created);
sg->bm = bm_new();
- if (drd_trace_segment)
+ if (DRD_(s_trace_segment))
{
char msg[256];
VG_(snprintf)(msg, sizeof(msg),
@@ -89,64 +90,62 @@
? DrdThreadIdToVgThreadId(created)
: DRD_INVALID_THREADID,
created);
- vc_snprint(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
&sg->vc);
VG_(message)(Vg_UserMsg, "%s", msg);
}
}
/** Deallocate the memory that was allocated by sg_init(). */
-static
-void sg_cleanup(Segment* const sg)
+static void DRD_(sg_cleanup)(Segment* const sg)
{
tl_assert(sg);
tl_assert(sg->refcnt == 0);
- vc_cleanup(&sg->vc);
+ DRD_(vc_cleanup)(&sg->vc);
bm_delete(sg->bm);
sg->bm = 0;
}
/** Allocate and initialize a new segment. */
-Segment* sg_new(ThreadId const creator, ThreadId const created)
+Segment* DRD_(sg_new)(ThreadId const creator, ThreadId const created)
{
Segment* sg;
- s_created_segments_count++;
- s_alive_segments_count++;
- if (s_max_alive_segments_count < s_alive_segments_count)
- s_max_alive_segments_count = s_alive_segments_count;
+ DRD_(s_segments_created_count)++;
+ DRD_(s_segments_alive_count)++;
+ if (DRD_(s_max_segments_alive_count) < DRD_(s_segments_alive_count))
+ DRD_(s_max_segments_alive_count) = DRD_(s_segments_alive_count);
sg = VG_(malloc)("drd.segment.sn.1", sizeof(*sg));
tl_assert(sg);
- sg_init(sg, creator, created);
+ DRD_(sg_init)(sg, creator, created);
return sg;
}
-static
-void sg_delete(Segment* const sg)
+static void DRD_(sg_delete)(Segment* const sg)
{
#if 1
- if (sg_get_trace())
+ if (DRD_(sg_get_trace)())
{
char msg[256];
VG_(snprintf)(msg, sizeof(msg),
"Discarding the segment with vector clock ");
- vc_snprint(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
&sg->vc);
VG_(message)(Vg_UserMsg, "%s", msg);
}
#endif
- s_alive_segments_count--;
+ DRD_(s_segments_alive_count)--;
tl_assert(sg);
- sg_cleanup(sg);
+ DRD_(sg_cleanup)(sg);
VG_(free)(sg);
}
/** Query the reference count of the specified segment. */
-int sg_get_refcnt(const Segment* const sg)
+int DRD_(sg_get_refcnt)(const Segment* const sg)
{
tl_assert(sg);
@@ -154,7 +153,7 @@
}
/** Increment the reference count of the specified segment. */
-Segment* sg_get(Segment* const sg)
+Segment* DRD_(sg_get)(Segment* const sg)
{
tl_assert(sg);
@@ -162,21 +161,22 @@
return sg;
}
-/** Decrement the reference count of the specified segment and deallocate the
- * segment if the reference count became zero.
+/**
+ * Decrement the reference count of the specified segment and deallocate the
+ * segment if the reference count became zero.
*/
-void sg_put(Segment* const sg)
+void DRD_(sg_put)(Segment* const sg)
{
if (sg == 0)
return;
- if (drd_trace_segment)
+ if (DRD_(s_trace_segment))
{
char msg[256];
VG_(snprintf)(msg, sizeof(msg),
"Decrementing segment reference count %d -> %d with vc ",
sg->refcnt, sg->refcnt - 1);
- vc_snprint(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
&sg->vc);
VG_(message)(Vg_UserMsg, "%s", msg);
}
@@ -185,33 +185,33 @@
if (--sg->refcnt == 0)
{
- sg_delete(sg);
+ DRD_(sg_delete)(sg);
}
}
/** Merge sg1 and sg2 into sg1. */
-void sg_merge(const Segment* const sg1, Segment* const sg2)
+void DRD_(sg_merge)(const Segment* const sg1, Segment* const sg2)
{
tl_assert(sg1);
tl_assert(sg1->refcnt == 1);
tl_assert(sg2);
tl_assert(sg2->refcnt == 1);
- if (drd_trace_segment)
+ if (DRD_(s_trace_segment))
{
char msg[256];
VG_(snprintf)(msg, sizeof(msg), "Merging segments with vector clocks ");
- vc_snprint(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
&sg1->vc);
VG_(snprintf)(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
" and ");
- vc_snprint(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
&sg2->vc);
VG_(message)(Vg_UserMsg, "%s", msg);
}
- s_segment_merge_count++;
+ DRD_(s_segment_merge_count)++;
// Keep sg1->stacktrace.
// Keep sg1->vc.
@@ -219,42 +219,45 @@
bm_merge(sg1->bm, sg2->bm);
}
-void sg_print(const Segment* const sg)
+/** Print the vector clock and the bitmap of the specified segment. */
+void DRD_(sg_print)(const Segment* const sg)
{
tl_assert(sg);
VG_(printf)("vc: ");
- vc_print(&sg->vc);
+ DRD_(vc_print)(&sg->vc);
VG_(printf)("\n");
bm_print(sg->bm);
}
-Bool sg_get_trace(void)
+/** Query whether segment tracing has been enabled. */
+Bool DRD_(sg_get_trace)(void)
{
- return drd_trace_segment;
+ return DRD_(s_trace_segment);
}
-void sg_set_trace(Bool const trace_segment)
+/** Enable or disable segment tracing. */
+void DRD_(sg_set_trace)(Bool const trace_segment)
{
tl_assert(trace_segment == False || trace_segment == True);
- drd_trace_segment = trace_segment;
+ DRD_(s_trace_segment) = trace_segment;
}
-ULong sg_get_created_segments_count(void)
+ULong DRD_(sg_get_segments_created_count)(void)
{
- return s_created_segments_count;
+ return DRD_(s_segments_created_count);
}
-ULong sg_get_alive_segments_count(void)
+ULong DRD_(sg_get_segments_alive_count)(void)
{
- return s_alive_segments_count;
+ return DRD_(s_segments_alive_count);
}
-ULong sg_get_max_alive_segments_count(void)
+ULong DRD_(sg_get_max_segments_alive_count)(void)
{
- return s_max_alive_segments_count;
+ return DRD_(s_max_segments_alive_count);
}
ULong sg_get_segment_merge_count(void)
{
- return s_segment_merge_count;
+ return DRD_(s_segment_merge_count);
}
Modified: branches/DRDDEV/drd/drd_segment.h
===================================================================
--- branches/DRDDEV/drd/drd_segment.h 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_segment.h 2009-05-02 14:52:31 UTC (rev 9719)
@@ -27,9 +27,11 @@
#define __SEGMENT_H
-// Segments and segment lists. A segment represents information about
-// a contiguous group of statements of a specific thread. There is a vector
-// clock associated with each segment.
+/*
+ * Segments and segment lists. A segment represents information about
+ * a contiguous group of statements of a specific thread. There is a vector
+ * clock associated with each segment.
+ */
#include "drd_vc.h"
@@ -40,26 +42,34 @@
typedef struct segment
{
+ /** Pointers to next and previous segments executed by the same thread. */
struct segment* next;
struct segment* prev;
+ /** Reference count: number of pointers that point to this segment. */
int refcnt;
+ /** Stack trace of the first instruction of the segment. */
ExeContext* stacktrace;
+ /** Vector clock associated with the segment. */
VectorClock vc;
+ /**
+ * Bitmap representing the memory accesses by the instructions associated
+ * with the segment.
+ */
struct bitmap* bm;
} Segment;
-Segment* sg_new(const ThreadId creator, const ThreadId created);
-int sg_get_refcnt(const Segment* const sg);
-Segment* sg_get(Segment* const sg);
-void sg_put(Segment* const sg);
-void sg_merge(const Segment* const sg1, Segment* const sg2);
-void sg_print(const Segment* const sg);
-Bool sg_get_trace(void);
-void sg_set_trace(const Bool trace_segment);
-ULong sg_get_created_segments_count(void);
-ULong sg_get_alive_segments_count(void);
-ULong sg_get_max_alive_segments_count(void);
+Segment* DRD_(sg_new)(const ThreadId creator, const ThreadId created);
+int DRD_(sg_get_refcnt)(const Segment* const sg);
+Segment* DRD_(sg_get)(Segment* const sg);
+void DRD_(sg_put)(Segment* const sg);
+void DRD_(sg_merge)(const Segment* const sg1, Segment* const sg2);
+void DRD_(sg_print)(const Segment* const sg);
+Bool DRD_(sg_get_trace)(void);
+void DRD_(sg_set_trace)(const Bool trace_segment);
+ULong DRD_(sg_get_segments_created_count)(void);
+ULong DRD_(sg_get_segments_alive_count)(void);
+ULong DRD_(sg_get_max_segments_alive_count)(void);
ULong sg_get_segment_merge_count(void);
Modified: branches/DRDDEV/drd/drd_semaphore.c
===================================================================
--- branches/DRDDEV/drd/drd_semaphore.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_semaphore.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -120,7 +120,7 @@
&sei);
}
while ((sg = segment_pop(p)))
- sg_put(sg);
+ DRD_(sg_put)(sg);
VG_(deleteXA)(p->last_sem_post_seg);
}
@@ -176,7 +176,7 @@
// Remove all segments from the segment stack.
while ((sg = segment_pop(p)))
{
- sg_put(sg);
+ DRD_(sg_put)(sg);
}
}
else
@@ -283,7 +283,7 @@
{
thread_combine_vc2(tid, &sg->vc);
}
- sg_put(sg);
+ DRD_(sg_put)(sg);
thread_new_segment(tid);
s_semaphore_segment_creation_count++;
}
Modified: branches/DRDDEV/drd/drd_semaphore.h
===================================================================
--- branches/DRDDEV/drd/drd_semaphore.h 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_semaphore.h 2009-05-02 14:52:31 UTC (rev 9719)
@@ -31,7 +31,6 @@
#include "drd_thread.h" // DrdThreadId
-#include "drd_vc.h"
#include "pub_tool_basics.h" // Addr
Modified: branches/DRDDEV/drd/drd_suppression.c
===================================================================
--- branches/DRDDEV/drd/drd_suppression.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_suppression.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -31,31 +31,35 @@
#include "pub_tool_libcprint.h" // Vg_DebugMsg
-// Local variables.
+/* Global variables. */
-static struct bitmap* s_suppressed;
-static Bool s_trace_suppression;
-Bool g_any_address_traced = False;
+Bool DRD_(g_any_address_traced) = False;
-// Function definitions.
+/* Local variables. */
-void suppression_set_trace(const Bool trace_suppression)
+static struct bitmap* DRD_(s_suppressed);
+static Bool DRD_(s_trace_suppression);
+
+
+/* Function definitions. */
+
+void DRD_(suppression_set_trace)(const Bool trace_suppression)
{
- s_trace_suppression = trace_suppression;
+ DRD_(s_trace_suppression) = trace_suppression;
}
-void drd_suppression_init(void)
+void DRD_(suppression_init)(void)
{
- tl_assert(s_suppressed == 0);
- s_suppressed = bm_new();
- tl_assert(s_suppressed);
+ tl_assert(DRD_(s_suppressed) == 0);
+ DRD_(s_suppressed) = bm_new();
+ tl_assert(DRD_(s_suppressed));
}
-void drd_start_suppression(const Addr a1, const Addr a2,
- const char* const reason)
+void DRD_(start_suppression)(const Addr a1, const Addr a2,
+ const char* const reason)
{
- if (s_trace_suppression)
+ if (DRD_(s_trace_suppression))
{
VG_(message)(Vg_DebugMsg, "start suppression of 0x%lx sz %ld (%s)",
a1, a2 - a1, reason);
@@ -63,12 +67,12 @@
tl_assert(a1 < a2);
// tl_assert(! drd_is_any_suppressed(a1, a2));
- bm_access_range_store(s_suppressed, a1, a2);
+ bm_access_range_store(DRD_(s_suppressed), a1, a2);
}
-void drd_finish_suppression(const Addr a1, const Addr a2)
+void DRD_(finish_suppression)(const Addr a1, const Addr a2)
{
- if (s_trace_suppression)
+ if (DRD_(s_trace_suppression))
{
VG_(message)(Vg_DebugMsg, "finish suppression of 0x%lx sz %ld",
a1, a2 - a1);
@@ -76,13 +80,13 @@
}
tl_assert(a1 < a2);
- if (! drd_is_suppressed(a1, a2))
+ if (! DRD_(is_suppressed)(a1, a2))
{
VG_(message)(Vg_DebugMsg, "?? [0x%lx,0x%lx[ not suppressed ??", a1, a2);
VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(), 12);
tl_assert(False);
}
- bm_clear_store(s_suppressed, a1, a2);
+ bm_clear_store(DRD_(s_suppressed), a1, a2);
}
/**
@@ -90,9 +94,9 @@
* bytes in the range a1 .. a2 - 1 inclusive. Return false in case the range
* is only partially suppressed or not suppressed at all.
*/
-Bool drd_is_suppressed(const Addr a1, const Addr a2)
+Bool DRD_(is_suppressed)(const Addr a1, const Addr a2)
{
- return bm_has(s_suppressed, a1, a2, eStore);
+ return bm_has(DRD_(s_suppressed), a1, a2, eStore);
}
/**
@@ -100,46 +104,47 @@
* of the bytes in the range a1 .. a2 - 1 inclusive. Return false in case none
* of the bytes in the specified range is suppressed.
*/
-Bool drd_is_any_suppressed(const Addr a1, const Addr a2)
+Bool DRD_(is_any_suppressed)(const Addr a1, const Addr a2)
{
- return bm_has_any_store(s_suppressed, a1, a2);
+ return bm_has_any_store(DRD_(s_suppressed), a1, a2);
}
-void drd_start_tracing_address_range(const Addr a1, const Addr a2)
+void DRD_(start_tracing_address_range)(const Addr a1, const Addr a2)
{
tl_assert(a1 < a2);
- bm_access_range_load(s_suppressed, a1, a2);
- if (! g_any_address_traced)
+ bm_access_range_load(DRD_(s_suppressed), a1, a2);
+ if (! DRD_(g_any_address_traced))
{
- g_any_address_traced = True;
+ DRD_(g_any_address_traced) = True;
}
}
-void drd_stop_tracing_address_range(const Addr a1, const Addr a2)
+void DRD_(stop_tracing_address_range)(const Addr a1, const Addr a2)
{
tl_assert(a1 < a2);
- bm_clear_load(s_suppressed, a1, a2);
- if (g_any_address_traced)
+ bm_clear_load(DRD_(s_suppressed), a1, a2);
+ if (DRD_(g_any_address_traced))
{
- g_any_address_traced = bm_has_any_load(s_suppressed, 0, ~(Addr)0);
+ DRD_(g_any_address_traced)
+ = bm_has_any_load(DRD_(s_suppressed), 0, ~(Addr)0);
}
}
-Bool drd_is_any_traced(const Addr a1, const Addr a2)
+Bool DRD_(is_any_traced)(const Addr a1, const Addr a2)
{
- return bm_has_any_load(s_suppressed, a1, a2);
+ return bm_has_any_load(DRD_(s_suppressed), a1, a2);
}
-void drd_suppression_stop_using_mem(const Addr a1, const Addr a2)
+void DRD_(suppression_stop_using_mem)(const Addr a1, const Addr a2)
{
- if (s_trace_suppression)
+ if (DRD_(s_trace_suppression))
{
Addr b;
for (b = a1; b < a2; b++)
{
- if (bm_has_1(s_suppressed, b, eStore))
+ if (bm_has_1(DRD_(s_suppressed), b, eStore))
{
VG_(message)(Vg_DebugMsg,
"stop_using_mem(0x%lx, %ld) finish suppression of 0x%lx",
@@ -149,5 +154,5 @@
}
tl_assert(a1);
tl_assert(a1 < a2);
- bm_clear(s_suppressed, a1, a2);
+ bm_clear(DRD_(s_suppressed), a1, a2);
}
Modified: branches/DRDDEV/drd/drd_suppression.h
===================================================================
--- branches/DRDDEV/drd/drd_suppression.h 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_suppression.h 2009-05-02 14:52:31 UTC (rev 9719)
@@ -2,28 +2,29 @@
#define __PUB_CORE_DRD_H
+#include "drd_basics.h"
#include "pub_tool_basics.h"
-extern Bool g_any_address_traced;
+extern Bool DRD_(g_any_address_traced);
-void suppression_set_trace(const Bool trace_suppression);
-void drd_suppression_init(void);
-void drd_start_suppression(const Addr a1, const Addr a2,
+void DRD_(suppression_set_trace)(const Bool trace_suppression);
+void DRD_(suppression_init)(void);
+void DRD_(start_suppression)(const Addr a1, const Addr a2,
const char* const reason);
-void drd_finish_suppression(const Addr a1, const Addr a2);
-Bool drd_is_suppressed(const Addr a1, const Addr a2);
-Bool drd_is_any_suppressed(const Addr a1, const Addr a2);
-void drd_start_tracing_address_range(const Addr a1, const Addr a2);
-void drd_stop_tracing_address_range(const Addr a1, const Addr a2);
-Bool drd_is_any_traced(const Addr a1, const Addr a2);
-void drd_suppression_stop_using_mem(const Addr a1, const Addr a2);
+void DRD_(finish_suppression)(const Addr a1, const Addr a2);
+Bool DRD_(is_suppressed)(const Addr a1, const Addr a2);
+Bool DRD_(is_any_suppressed)(const Addr a1, const Addr a2);
+void DRD_(start_tracing_address_range)(const Addr a1, const Addr a2);
+void DRD_(stop_tracing_address_range)(const Addr a1, const Addr a2);
+Bool DRD_(is_any_traced)(const Addr a1, const Addr a2);
+void DRD_(suppression_stop_using_mem)(const Addr a1, const Addr a2);
-static __inline__ Bool drd_any_address_is_traced(void)
+static __inline__ Bool DRD_(any_address_is_traced)(void)
{
- return g_any_address_traced;
+ return DRD_(g_any_address_traced);
}
Modified: branches/DRDDEV/drd/drd_thread.c
===================================================================
--- branches/DRDDEV/drd/drd_thread.c 2009-05-02 14:20:09 UTC (rev 9718)
+++ branches/DRDDEV/drd/drd_thread.c 2009-05-02 14:52:31 UTC (rev 9719)
@@ -213,6 +213,14 @@
}
#endif
+/**
+ * Create the first segment for a newly started thread.
+ *
+ * This function is called from the handler installed via
+ * VG_(track_pre_thread_ll_create)(). The Valgrind core invokes this handler
+ * from the context of the creator thread, before the new thread has been
+ * created.
+ */
DrdThreadId thread_pre_create(const DrdThreadId creator,
const ThreadId vg_created)
{
@@ -225,12 +233,34 @@
tl_assert(s_threadinfo[created].first == 0);
tl_assert(s_threadinfo[created].last == 0);
- thread_append_segment(created, sg_new(creator, created));
+ thread_append_segment(created, DRD_(sg_new)(creator, created));
return created;
}
+/**
+ * Initialize s_threadinfo[] for a newly created thread. Must be called after
+ * the thread has been created and before any client instructioins are run
+ * on the newly created thread, e.g. from the handler installed via
+ * VG_(track_pre_thread_first_insn)().
+ */
+DrdThreadId thread_post_create(const ThreadId vg_created)
+{
+ const DrdThreadId created = VgThreadIdToDrdThreadId(vg_created);
+ tl_assert(0 <= (int)created && created < DRD_N_THREADS
+ && created != DRD_INVALID_THREADID);
+
+ s_threadinfo[created].stack_max = VG_(thread_get_stack_max)(vg_created);
+ s_threadinfo[created].stack_startup = s_threadinfo[created].stack_max;
+ s_threadinfo[created].stack_min = s_threadinfo[created].stack_max;
+ s_threadinfo[created].stack_min_min = s_threadinfo[created].stack_max;
+ s_threadinfo[created].stack_size = VG_(thread_get_stack_size)(vg_created);
+ tl_assert(s_threadinfo[created].stack_max != 0);
+
+ return created;
+}
+
/* Process VG_USERREQ__POST_THREAD_JOIN. This client request is invoked just */
/* after thread drd_joiner joined thread drd_joinee. */
void DRD_(thread_post_join)(DrdThreadId drd_joiner, DrdThreadId drd_joinee)
@@ -257,8 +287,8 @@
{
VG_(snprintf)(msg + VG_(strlen)(msg), msg_size - VG_(strlen)(msg),
", new vc: ");
- vc_snprint(msg + VG_(strlen)(msg), msg_size - VG_(strlen)(msg),
- thread_get_vc(drd_joiner));
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg), msg_size - VG_(strlen)(msg),
+ thread_get_vc(drd_joiner));
}
VG_(message)(Vg_DebugMsg, "%s", msg);
VG_(free)(msg);
@@ -266,9 +296,9 @@
if (! DRD_(get_check_stack_accesses)())
{
- drd_finish_suppression(thread_get_stack_max(drd_joinee)
- - thread_get_stack_size(drd_joinee),
- thread_get_stack_max(drd_joinee));
+ DRD_(finish_suppression)(thread_get_stack_max(drd_joinee)
+ - thread_get_stack_size(drd_joinee),
+ thread_get_stack_max(drd_joinee));
}
thread_delete(drd_joinee);
mutex_thread_delete(drd_joinee);
@@ -277,26 +307,6 @@
barrier_thread_delete(drd_joinee);
}
-/** Allocate the first segment for a thread. Call this just after
- * pthread_create().
- */
-DrdThreadId thread_post_create(const ThreadId vg_created)
-{
- const DrdThreadId created = VgThreadIdToDrdThreadId(vg_created);
-
- tl_assert(0 <= (int)created && created < DRD_N_THREADS
- && created != DRD_INVALID_THREADID);
-
- s_threadinfo[created].stack_max = VG_(thread_get_stack_max)(vg_created);
- s_threadinfo[created].stack_startup = s_threadinfo[created].stack_max;
- s_threadinfo[created].stack_min = s_threadinfo[created].stack_max;
- s_threadinfo[created].stack_min_min = s_threadinfo[created].stack_max;
- s_threadinfo[created].stack_size = VG_(thread_get_stack_size)(vg_created);
- tl_assert(s_threadinfo[created].stack_max != 0);
-
- return created;
-}
-
/* NPTL hack: NPTL allocates the 'struct pthread' on top of the stack, */
/* and accesses this data structure from multiple threads without locking. */
/* Any conflicting accesses in the range stack_startup..stack_max will be */
@@ -355,7 +365,7 @@
sg_prev = sg->prev;
sg->prev = 0;
sg->next = 0;
- sg_put(sg);
+ DRD_(sg_put)(sg);
}
s_threadinfo[tid].vg_thread_exists = False;
s_threadinfo[tid].posix_thread_exists = False;
@@ -459,7 +469,7 @@
" segments: %llu",
s_vg_running_tid, s_drd_running_tid,
DrdThreadIdToVgThreadId(drd_tid), drd_tid,
- sg_get_alive_segments_count());
+ DRD_(sg_get_segments_alive_count)());
}
s_vg_running_tid = vg_tid;
s_drd_running_tid = drd_tid;
@@ -523,7 +533,7 @@
s_threadinfo[tid].first = sg->next;
if (sg == s_threadinfo[tid].last)
s_threadinfo[tid].last = sg->prev;
- sg_put(sg);
+ DRD_(sg_put)(sg);
//tl_assert(sane_ThreadInfo(&s_threadinfo[tid]));
}
@@ -546,8 +556,8 @@
&& tid != DRD_INVALID_THREADID);
tl_assert(s_threadinfo[tid].last);
- sg_put(*sg);
- *sg = sg_get(s_threadinfo[tid].last);
+ DRD_(sg_put)(*sg);
+ *sg = DRD_(sg_get)(s_threadinfo[tid].last);
}
/**
@@ -568,9 +578,9 @@
if (latest_sg)
{
if (first)
- vc_assign(vc, &latest_sg->vc);
+ DRD_(vc_assign)(vc, &latest_sg->vc);
else
- vc_min(vc, &latest_sg->vc);
+ DRD_(vc_min)(vc, &latest_sg->vc);
first = False;
}
}
@@ -589,9 +599,9 @@
if (latest_sg)
{
if (first)
- vc_assign(vc, &latest_sg->vc);
+ DRD_(vc_assign)(vc, &latest_sg->vc);
else
- vc_combine(vc, &latest_sg->vc);
+ DRD_(vc_combine)(vc, &latest_sg->vc);
first = False;
}
}
@@ -609,25 +619,25 @@
s_discard_ordered_segments_count++;
- vc_init(&thread_vc_min, 0, 0);
+ DRD_(vc_init)(&thread_vc_min, 0, 0);
thread_compute_minimum_vc(&thread_vc_min);
- if (sg_get_trace())
+ if (DRD_(sg_get_trace)())
{
char msg[256];
VectorClock thread_vc_max;
- vc_init(&thread_vc_max, 0, 0);
+ DRD_(vc_init)(&thread_vc_max, 0, 0);
thread_compute_maximum_vc(&thread_vc_max);
VG_(snprintf)(msg, sizeof(msg),
"Discarding ordered s...
[truncated message content] |