You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
1
(8) |
2
(8) |
3
(15) |
4
(14) |
5
(12) |
6
(40) |
7
(9) |
|
8
(5) |
9
(12) |
10
(9) |
11
(13) |
12
(7) |
13
(7) |
14
(19) |
|
15
(18) |
16
(13) |
17
(16) |
18
(8) |
19
(16) |
20
(16) |
21
(12) |
|
22
(21) |
23
(39) |
24
(27) |
25
(33) |
26
(41) |
27
(17) |
28
(15) |
|
From: <sv...@va...> - 2009-02-14 17:20:03
|
Author: bart
Date: 2009-02-14 17:19:58 +0000 (Sat, 14 Feb 2009)
New Revision: 9160
Log:
Wrapped DRD_() macro around all segment function names.
Modified:
trunk/drd/drd_barrier.c
trunk/drd/drd_main.c
trunk/drd/drd_mutex.c
trunk/drd/drd_rwlock.c
trunk/drd/drd_segment.c
trunk/drd/drd_segment.h
trunk/drd/drd_semaphore.c
trunk/drd/drd_thread.c
Modified: trunk/drd/drd_barrier.c
===================================================================
--- trunk/drd/drd_barrier.c 2009-02-14 16:55:19 UTC (rev 9159)
+++ trunk/drd/drd_barrier.c 2009-02-14 17:19:58 UTC (rev 9160)
@@ -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: trunk/drd/drd_main.c
===================================================================
--- trunk/drd/drd_main.c 2009-02-14 16:55:19 UTC (rev 9159)
+++ trunk/drd/drd_main.c 2009-02-14 17:19:58 UTC (rev 9160)
@@ -143,7 +143,7 @@
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)
@@ -542,8 +542,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 m, %lld rw, %lld s, %lld b)",
Modified: trunk/drd/drd_mutex.c
===================================================================
--- trunk/drd/drd_mutex.c 2009-02-14 16:55:19 UTC (rev 9159)
+++ trunk/drd/drd_mutex.c 2009-02-14 17:19:58 UTC (rev 9160)
@@ -107,7 +107,7 @@
&MEI);
}
- sg_put(p->last_locked_segment);
+ DRD_(sg_put)(p->last_locked_segment);
p->last_locked_segment = 0;
}
Modified: trunk/drd/drd_rwlock.c
===================================================================
--- trunk/drd/drd_rwlock.c 2009-02-14 16:55:19 UTC (rev 9159)
+++ trunk/drd/drd_rwlock.c 2009-02-14 17:19:58 UTC (rev 9160)
@@ -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: trunk/drd/drd_segment.c
===================================================================
--- trunk/drd/drd_segment.c 2009-02-14 16:55:19 UTC (rev 9159)
+++ trunk/drd/drd_segment.c 2009-02-14 17:19:58 UTC (rev 9160)
@@ -36,23 +36,24 @@
#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 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 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);
@@ -79,7 +80,7 @@
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),
@@ -95,8 +96,7 @@
}
/** 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);
@@ -107,26 +107,25 @@
}
/** 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),
@@ -137,15 +136,15 @@
}
#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);
@@ -153,7 +152,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);
@@ -161,15 +160,16 @@
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),
@@ -184,19 +184,19 @@
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];
@@ -216,7 +216,8 @@
bm_merge2(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: ");
@@ -225,28 +226,30 @@
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);
}
Modified: trunk/drd/drd_segment.h
===================================================================
--- trunk/drd/drd_segment.h 2009-02-14 16:55:19 UTC (rev 9159)
+++ trunk/drd/drd_segment.h 2009-02-14 17:19:58 UTC (rev 9160)
@@ -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);
#endif // __SEGMENT_H
Modified: trunk/drd/drd_semaphore.c
===================================================================
--- trunk/drd/drd_semaphore.c 2009-02-14 16:55:19 UTC (rev 9159)
+++ trunk/drd/drd_semaphore.c 2009-02-14 17:19:58 UTC (rev 9160)
@@ -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: trunk/drd/drd_thread.c
===================================================================
--- trunk/drd/drd_thread.c 2009-02-14 16:55:19 UTC (rev 9159)
+++ trunk/drd/drd_thread.c 2009-02-14 17:19:58 UTC (rev 9160)
@@ -225,7 +225,7 @@
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;
}
@@ -355,7 +355,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 +459,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 +523,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 +546,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);
}
/**
@@ -611,7 +611,7 @@
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;
@@ -664,13 +664,13 @@
for (sg = s_threadinfo[i].first; sg; sg = sg->next)
{
- if (sg_get_refcnt(sg) == 1
+ if (DRD_(sg_get_refcnt)(sg) == 1
&& sg->next
- && sg_get_refcnt(sg->next) == 1
+ && DRD_(sg_get_refcnt)(sg->next) == 1
&& sg->next->next)
{
/* Merge sg and sg->next into sg. */
- sg_merge(sg, sg->next);
+ DRD_(sg_merge)(sg, sg->next);
thread_discard_segment(i, sg->next);
}
}
@@ -756,7 +756,7 @@
tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
&& tid != DRD_INVALID_THREADID);
- new_sg = sg_new(tid, tid);
+ new_sg = DRD_(sg_new)(tid, tid);
thread_append_segment(tid, new_sg);
if (conflict_set_update_needed(tid, new_sg))
@@ -884,7 +884,7 @@
s_threadinfo[i].detached_posix_thread);
for (p = s_threadinfo[i].first; p; p = p->next)
{
- sg_print(p);
+ DRD_(sg_print)(p);
}
}
}
|
|
From: <sv...@va...> - 2009-02-14 16:55:24
|
Author: bart
Date: 2009-02-14 16:55:19 +0000 (Sat, 14 Feb 2009)
New Revision: 9159
Log:
Wrapped DRD_() macro around all vector clock function names.
Modified:
trunk/drd/drd_barrier.h
trunk/drd/drd_basics.h
trunk/drd/drd_load_store.c
trunk/drd/drd_main.c
trunk/drd/drd_mutex.h
trunk/drd/drd_rwlock.h
trunk/drd/drd_segment.c
trunk/drd/drd_semaphore.h
trunk/drd/drd_thread.c
trunk/drd/drd_thread.h
trunk/drd/drd_vc.c
trunk/drd/drd_vc.h
Modified: trunk/drd/drd_barrier.h
===================================================================
--- trunk/drd/drd_barrier.h 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_barrier.h 2009-02-14 16:55:19 UTC (rev 9159)
@@ -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: trunk/drd/drd_basics.h
===================================================================
--- trunk/drd/drd_basics.h 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_basics.h 2009-02-14 16:55:19 UTC (rev 9159)
@@ -35,4 +35,7 @@
#define DRD_(str) VGAPPEND(vgDrd_, str)
+typedef UInt DrdThreadId;
+
+
#endif /* __DRD_BASICS_H */
Modified: trunk/drd/drd_load_store.c
===================================================================
--- trunk/drd/drd_load_store.c 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_load_store.c 2009-02-14 16:55:19 UTC (rev 9159)
@@ -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. */
@@ -73,7 +74,7 @@
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
Modified: trunk/drd/drd_main.c
===================================================================
--- trunk/drd/drd_main.c 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_main.c 2009-02-14 16:55:19 UTC (rev 9159)
@@ -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
Modified: trunk/drd/drd_mutex.h
===================================================================
--- trunk/drd/drd_mutex.h 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_mutex.h 2009-02-14 16:55:19 UTC (rev 9159)
@@ -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: trunk/drd/drd_rwlock.h
===================================================================
--- trunk/drd/drd_rwlock.h 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_rwlock.h 2009-02-14 16:55:19 UTC (rev 9159)
@@ -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: trunk/drd/drd_segment.c
===================================================================
--- trunk/drd/drd_segment.c 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_segment.c 2009-02-14 16:55:19 UTC (rev 9159)
@@ -73,10 +73,10 @@
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)
@@ -88,7 +88,7 @@
? 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);
}
@@ -101,7 +101,7 @@
tl_assert(sg);
tl_assert(sg->refcnt == 0);
- vc_cleanup(&sg->vc);
+ DRD_(vc_cleanup)(&sg->vc);
bm_delete(sg->bm);
sg->bm = 0;
}
@@ -131,7 +131,7 @@
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);
}
@@ -175,7 +175,7 @@
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);
}
@@ -201,11 +201,11 @@
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);
}
@@ -220,7 +220,7 @@
{
tl_assert(sg);
VG_(printf)("vc: ");
- vc_print(&sg->vc);
+ DRD_(vc_print)(&sg->vc);
VG_(printf)("\n");
bm_print(sg->bm);
}
Modified: trunk/drd/drd_semaphore.h
===================================================================
--- trunk/drd/drd_semaphore.h 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_semaphore.h 2009-02-14 16:55:19 UTC (rev 9159)
@@ -31,7 +31,6 @@
#include "drd_thread.h" // DrdThreadId
-#include "drd_vc.h"
#include "pub_tool_basics.h" // Addr
Modified: trunk/drd/drd_thread.c
===================================================================
--- trunk/drd/drd_thread.c 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_thread.c 2009-02-14 16:55:19 UTC (rev 9159)
@@ -257,8 +257,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);
@@ -568,9 +568,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 +589,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 +609,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())
{
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 segments -- min vc is ");
- vc_snprint(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
- &thread_vc_min);
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
+ &thread_vc_min);
VG_(snprintf)(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
", max vc is ");
- vc_snprint(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
- &thread_vc_max);
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg), sizeof(msg) - VG_(strlen)(msg),
+ &thread_vc_max);
VG_(message)(Vg_UserMsg, "%s", msg);
- vc_cleanup(&thread_vc_max);
+ DRD_(vc_cleanup)(&thread_vc_max);
}
for (i = 0; i < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); i++)
@@ -635,13 +635,13 @@
Segment* sg;
Segment* sg_next;
for (sg = s_threadinfo[i].first;
- sg && (sg_next = sg->next) && vc_lte(&sg->vc, &thread_vc_min);
+ sg && (sg_next = sg->next) && DRD_(vc_lte)(&sg->vc, &thread_vc_min);
sg = sg_next)
{
thread_discard_segment(i, sg);
}
}
- vc_cleanup(&thread_vc_min);
+ DRD_(vc_cleanup)(&thread_vc_min);
}
/** Merge all segments that may be merged without triggering false positives
@@ -690,7 +690,7 @@
* @param new_sg Pointer to the most recent segment of thread tid.
*/
static Bool conflict_set_update_needed(const DrdThreadId tid,
- const Segment* const new_sg)
+ const Segment* const new_sg)
{
#if 0
unsigned i;
@@ -721,19 +721,19 @@
/* If the expression below evaluates to false, this expression will */
/* also evaluate to false for all subsequent iterations. So stop */
/* iterating. */
- if (vc_lte(&q->vc, &old_sg->vc))
+ if (DRD_(vc_lte)(&q->vc, &old_sg->vc))
break;
/* If the vector clock of the 2nd the last segment is not ordered */
/* to the vector clock of segment q, and the last segment is, ask */
/* the caller to update the conflict set. */
- if (! vc_lte(&old_sg->vc, &q->vc))
+ if (! DRD_(vc_lte)(&old_sg->vc, &q->vc))
{
return True;
}
/* If the vector clock of the last segment is not ordered to the */
/* vector clock of segment q, ask the caller to update the conflict */
/* set. */
- if (! vc_lte(&q->vc, &new_sg->vc) && ! vc_lte(&new_sg->vc, &q->vc))
+ if (! DRD_(vc_lte)(&q->vc, &new_sg->vc) && ! DRD_(vc_lte)(&new_sg->vc, &q->vc))
{
return True;
}
@@ -785,7 +785,7 @@
&& joinee != DRD_INVALID_THREADID);
tl_assert(s_threadinfo[joiner].last);
tl_assert(s_threadinfo[joinee].last);
- vc_combine(&s_threadinfo[joiner].last->vc, &s_threadinfo[joinee].last->vc);
+ DRD_(vc_combine)(&s_threadinfo[joiner].last->vc, &s_threadinfo[joinee].last->vc);
thread_discard_ordered_segments();
if (joiner == s_drd_running_tid)
@@ -804,7 +804,7 @@
&& tid != DRD_INVALID_THREADID);
tl_assert(s_threadinfo[tid].last);
tl_assert(vc);
- vc_combine(&s_threadinfo[tid].last->vc, vc);
+ DRD_(vc_combine)(&s_threadinfo[tid].last->vc, vc);
thread_compute_conflict_set(&s_conflict_set, tid);
thread_discard_ordered_segments();
s_conflict_set_combine_vc_count++;
@@ -940,9 +940,9 @@
// decreasing vector clocks, if q->vc <= p->vc, then
// q->next->vc <= p->vc will also hold. Hence, break out of the
// loop once this condition is met.
- if (vc_lte(&q->vc, &p->vc))
+ if (DRD_(vc_lte)(&q->vc, &p->vc))
break;
- if (! vc_lte(&p->vc, &q->vc))
+ if (! DRD_(vc_lte)(&p->vc, &q->vc))
{
if (bm_has_conflict_with(q->bm, addr, addr + size, access_type))
{
@@ -1030,9 +1030,9 @@
VG_(snprintf)(msg, sizeof(msg),
"computing conflict set for thread %d/%d with vc ",
DrdThreadIdToVgThreadId(tid), tid);
- vc_snprint(msg + VG_(strlen)(msg),
- sizeof(msg) - VG_(strlen)(msg),
- &s_threadinfo[tid].last->vc);
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg),
+ sizeof(msg) - VG_(strlen)(msg),
+ &s_threadinfo[tid].last->vc);
VG_(message)(Vg_UserMsg, "%s", msg);
}
@@ -1047,9 +1047,9 @@
VG_(snprintf)(msg, sizeof(msg),
"conflict set: thread [%d] at vc ",
tid);
- vc_snprint(msg + VG_(strlen)(msg),
- sizeof(msg) - VG_(strlen)(msg),
- &p->vc);
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg),
+ sizeof(msg) - VG_(strlen)(msg),
+ &p->vc);
VG_(message)(Vg_UserMsg, "%s", msg);
}
@@ -1060,16 +1060,16 @@
const Segment* q;
for (q = s_threadinfo[j].last; q; q = q->prev)
{
- if (! vc_lte(&q->vc, &p->vc) && ! vc_lte(&p->vc, &q->vc))
+ if (! DRD_(vc_lte)(&q->vc, &p->vc) && ! DRD_(vc_lte)(&p->vc, &q->vc))
{
if (s_trace_conflict_set)
{
char msg[256];
VG_(snprintf)(msg, sizeof(msg),
"conflict set: [%d] merging segment ", j);
- vc_snprint(msg + VG_(strlen)(msg),
- sizeof(msg) - VG_(strlen)(msg),
- &q->vc);
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg),
+ sizeof(msg) - VG_(strlen)(msg),
+ &q->vc);
VG_(message)(Vg_UserMsg, "%s", msg);
}
bm_merge2(*conflict_set, q->bm);
@@ -1081,9 +1081,9 @@
char msg[256];
VG_(snprintf)(msg, sizeof(msg),
"conflict set: [%d] ignoring segment ", j);
- vc_snprint(msg + VG_(strlen)(msg),
- sizeof(msg) - VG_(strlen)(msg),
- &q->vc);
+ DRD_(vc_snprint)(msg + VG_(strlen)(msg),
+ sizeof(msg) - VG_(strlen)(msg),
+ &q->vc);
VG_(message)(Vg_UserMsg, "%s", msg);
}
}
Modified: trunk/drd/drd_thread.h
===================================================================
--- trunk/drd/drd_thread.h 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_thread.h 2009-02-14 16:55:19 UTC (rev 9159)
@@ -53,7 +53,6 @@
// Type definitions.
-typedef UInt DrdThreadId;
typedef UWord PThreadId;
typedef struct
Modified: trunk/drd/drd_vc.c
===================================================================
--- trunk/drd/drd_vc.c 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_vc.c 2009-02-14 16:55:19 UTC (rev 9159)
@@ -26,25 +26,33 @@
#include "drd_vc.h"
#include "pub_tool_basics.h" // Addr, SizeT
#include "pub_tool_libcassert.h" // tl_assert()
-#include "pub_tool_libcbase.h" // VG_(memset), VG_(memmove)
+#include "pub_tool_libcbase.h" // VG_(memcpy)
#include "pub_tool_libcprint.h" // VG_(printf)
#include "pub_tool_mallocfree.h" // VG_(malloc), VG_(free)
-#include "pub_tool_threadstate.h" // VG_(get_running_tid)
+/* Local function declarations. */
+
static
-void vc_reserve(VectorClock* const vc, const unsigned new_capacity);
+void DRD_(vc_reserve)(VectorClock* const vc, const unsigned new_capacity);
-void vc_init(VectorClock* const vc,
- const VCElem* const vcelem,
- const unsigned size)
+/* Function definitions. */
+
+/**
+ * Initialize the memory 'vc' points at as a vector clock with size 'size'.
+ * If the pointer 'vcelem' is not null, it is assumed to be an array with
+ * 'size' elements and it becomes the initial value of the vector clock.
+ */
+void DRD_(vc_init)(VectorClock* const vc,
+ const VCElem* const vcelem,
+ const unsigned size)
{
tl_assert(vc);
vc->size = 0;
vc->capacity = 0;
vc->vc = 0;
- vc_reserve(vc, size);
+ DRD_(vc_reserve)(vc, size);
tl_assert(size == 0 || vc->vc != 0);
if (vcelem)
{
@@ -53,32 +61,32 @@
}
}
-void vc_cleanup(VectorClock* const vc)
+/** Reset vc to the empty vector clock. */
+void DRD_(vc_cleanup)(VectorClock* const vc)
{
- vc_reserve(vc, 0);
+ DRD_(vc_reserve)(vc, 0);
}
/** Copy constructor -- initializes *new. */
-void vc_copy(VectorClock* const new,
- const VectorClock* const rhs)
+void DRD_(vc_copy)(VectorClock* const new, const VectorClock* const rhs)
{
- vc_init(new, rhs->vc, rhs->size);
+ DRD_(vc_init)(new, rhs->vc, rhs->size);
}
/** Assignment operator -- *lhs is already a valid vector clock. */
-void vc_assign(VectorClock* const lhs,
- const VectorClock* const rhs)
+void DRD_(vc_assign)(VectorClock* const lhs, const VectorClock* const rhs)
{
- vc_cleanup(lhs);
- vc_copy(lhs, rhs);
+ DRD_(vc_cleanup)(lhs);
+ DRD_(vc_copy)(lhs, rhs);
}
-void vc_increment(VectorClock* const vc, ThreadId const threadid)
+/** Increment the clock of thread 'tid' in vector clock 'vc'. */
+void DRD_(vc_increment)(VectorClock* const vc, DrdThreadId const tid)
{
unsigned i;
for (i = 0; i < vc->size; i++)
{
- if (vc->vc[i].threadid == threadid)
+ if (vc->vc[i].threadid == tid)
{
typeof(vc->vc[i].count) const oldcount = vc->vc[i].count;
vc->vc[i].count++;
@@ -88,14 +96,16 @@
}
}
- // The specified thread ID does not yet exist in the vector clock
- // -- insert it.
+ /*
+ * The specified thread ID does not yet exist in the vector clock
+ * -- insert it.
+ */
{
- VCElem vcelem = { threadid, 1 };
+ const VCElem vcelem = { tid, 1 };
VectorClock vc2;
- vc_init(&vc2, &vcelem, 1);
- vc_combine(vc, &vc2);
- vc_cleanup(&vc2);
+ DRD_(vc_init)(&vc2, &vcelem, 1);
+ DRD_(vc_combine)(vc, &vc2);
+ DRD_(vc_cleanup)(&vc2);
}
}
@@ -103,14 +113,14 @@
* @return True if vector clocks vc1 and vc2 are ordered, and false otherwise.
* Order is as imposed by thread synchronization actions ("happens before").
*/
-Bool vc_ordered(const VectorClock* const vc1,
- const VectorClock* const vc2)
+Bool DRD_(vc_ordered)(const VectorClock* const vc1,
+ const VectorClock* const vc2)
{
- return vc_lte(vc1, vc2) || vc_lte(vc2, vc1);
+ return DRD_(vc_lte)(vc1, vc2) || DRD_(vc_lte)(vc2, vc1);
}
/** Compute elementwise minimum. */
-void vc_min(VectorClock* const result, const VectorClock* const rhs)
+void DRD_(vc_min)(VectorClock* const result, const VectorClock* const rhs)
{
unsigned i;
unsigned j;
@@ -118,7 +128,7 @@
tl_assert(result);
tl_assert(rhs);
- vc_check(result);
+ DRD_(vc_check)(result);
/* Next, combine both vector clocks into one. */
i = 0;
@@ -145,26 +155,26 @@
}
}
}
- vc_check(result);
+ DRD_(vc_check)(result);
}
/**
* Compute elementwise maximum.
*/
-void vc_combine(VectorClock* const result,
- const VectorClock* const rhs)
+void DRD_(vc_combine)(VectorClock* const result, const VectorClock* const rhs)
{
- vc_combine2(result, rhs, -1);
+ DRD_(vc_combine2)(result, rhs, -1);
}
-/** Compute elementwise maximum.
+/**
+ * Compute elementwise maximum.
*
- * @return True if *result and *rhs are equal, or if *result and *rhs only
- * differ in the component with thread ID tid.
+ * @return True if *result and *rhs are equal, or if *result and *rhs only
+ * differ in the component with thread ID tid.
*/
-Bool vc_combine2(VectorClock* const result,
- const VectorClock* const rhs,
- const ThreadId tid)
+Bool DRD_(vc_combine2)(VectorClock* const result,
+ const VectorClock* const rhs,
+ const DrdThreadId tid)
{
unsigned i;
unsigned j;
@@ -188,13 +198,13 @@
shared++;
}
- vc_check(result);
+ DRD_(vc_check)(result);
new_size = result->size + rhs->size - shared;
if (new_size > result->capacity)
- vc_reserve(result, new_size);
+ DRD_(vc_reserve)(result, new_size);
- vc_check(result);
+ DRD_(vc_check)(result);
// Next, combine both vector clocks into one.
i = 0;
@@ -251,13 +261,14 @@
}
}
}
- vc_check(result);
+ DRD_(vc_check)(result);
tl_assert(result->size == new_size);
return almost_equal;
}
-void vc_print(const VectorClock* const vc)
+/** Print the contents of vector clock 'vc'. */
+void DRD_(vc_print)(const VectorClock* const vc)
{
unsigned i;
@@ -272,8 +283,12 @@
VG_(printf)(" ]");
}
-void vc_snprint(Char* const str, Int const size,
- const VectorClock* const vc)
+/**
+ * Print the contents of vector clock 'vc' to the character array 'str' that
+ * has 'size' elements.
+ */
+void DRD_(vc_snprint)(Char* const str, const Int size,
+ const VectorClock* const vc)
{
unsigned i;
unsigned j = 1;
@@ -296,8 +311,15 @@
/**
* Invariant test.
+ *
+ * The function below tests whether the following two conditions are
+ * satisfied:
+ * - size <= capacity.
+ * - Vector clock elements are stored in thread ID order.
+ *
+ * If one of these conditions is not met, an assertion failure is triggered.
*/
-void vc_check(const VectorClock* const vc)
+void DRD_(vc_check)(const VectorClock* const vc)
{
unsigned i;
tl_assert(vc->size <= vc->capacity);
@@ -313,7 +335,7 @@
* block is increased, the newly allocated memory is not initialized.
*/
static
-void vc_reserve(VectorClock* const vc, const unsigned new_capacity)
+void DRD_(vc_reserve)(VectorClock* const vc, const unsigned new_capacity)
{
tl_assert(vc);
if (new_capacity > vc->capacity)
@@ -337,10 +359,11 @@
tl_assert(new_capacity == 0 || vc->vc != 0);
}
+#if 0
/**
* Unit test.
*/
-void vc_test(void)
+void DRD_(vc_test)(void)
{
VectorClock vc1;
VCElem vc1elem[] = { { 3, 7 }, { 5, 8 }, };
@@ -378,3 +401,4 @@
vc_cleanup(&vc2);
vc_cleanup(&vc3);
}
+#endif
Modified: trunk/drd/drd_vc.h
===================================================================
--- trunk/drd/drd_vc.h 2009-02-14 16:10:53 UTC (rev 9158)
+++ trunk/drd/drd_vc.h 2009-02-14 16:55:19 UTC (rev 9159)
@@ -27,67 +27,69 @@
#define __DRD_VC_H
-// DRD vector clock implementation:
-// - One counter per thread.
-// - A vector clock is implemented as multiple pairs of (thread id, counter).
-// - Pairs are stored in an array sorted by thread id.
-// Semantics:
-// - Each time a thread performs an action that implies an ordering between
-// intra-thread events, the counter of that thread is incremented.
-// - Vector clocks are compared by comparing all counters of all threads.
-// - When a thread synchronization action is performed that guarantees that
-// new actions of the current thread are executed after the actions of the
-// other thread, the vector clock of the synchronization object and the
-// current thread are combined (by taking the component-wise maximum).
-// - A vector clock is incremented during actions such as
-// pthread_create(), pthread_mutex_unlock(), sem_post(). (Actions where
-// an inter-thread ordering "arrow" starts).
+/*
+ * DRD vector clock implementation:
+ * - One counter per thread.
+ * - A vector clock is implemented as multiple pairs of (thread id, counter).
+ * - Pairs are stored in an array sorted by thread id.
+ *
+ * Semantics:
+ * - Each time a thread performs an action that implies an ordering between
+ * intra-thread events, the counter of that thread is incremented.
+ * - Vector clocks are compared by comparing all counters of all threads.
+ * - When a thread synchronization action is performed that guarantees that
+ * new actions of the current thread are executed after the actions of the
+ * other thread, the vector clock of the synchronization object and the
+ * current thread are combined (by taking the component-wise maximum).
+ * - A vector clock is incremented during actions such as
+ * pthread_create(), pthread_mutex_unlock(), sem_post(). (Actions where
+ * an inter-thread ordering "arrow" starts).
+ */
#include "pub_tool_basics.h" // Addr, SizeT
+/** Vector clock element. */
typedef struct
{
- ThreadId threadid;
- UInt count;
+ DrdThreadId threadid;
+ UInt count;
} VCElem;
typedef struct
{
- unsigned capacity;
- unsigned size;
- VCElem* vc;
+ unsigned capacity; /**< number of elements allocated for array vc. */
+ unsigned size; /**< number of elements used of array vc. */
+ VCElem* vc; /**< vector clock elements. */
} VectorClock;
-void vc_init(VectorClock* const vc,
- const VCElem* const vcelem,
- const unsigned size);
-void vc_cleanup(VectorClock* const vc);
-void vc_copy(VectorClock* const new,
- const VectorClock* const rhs);
-void vc_assign(VectorClock* const lhs,
- const VectorClock* const rhs);
-UInt vc_get(VectorClock* const vc, const ThreadId tid);
-void vc_increment(VectorClock* const vc, ThreadId const threadid);
+void DRD_(vc_init)(VectorClock* const vc,
+ const VCElem* const vcelem,
+ const unsigned size);
+void DRD_(vc_cleanup)(VectorClock* const vc);
+void DRD_(vc_copy)(VectorClock* const new, const VectorClock* const rhs);
+void DRD_(vc_assign)(VectorClock* const lhs, const VectorClock* const rhs);
+UInt DRD_(vc_get)(VectorClock* const vc, const DrdThreadId tid);
+void DRD_(vc_increment)(VectorClock* const vc, DrdThreadId const tid);
static __inline__
-Bool vc_lte(const VectorClock* const vc1,
- const VectorClock* const vc2);
-Bool vc_ordered(const VectorClock* const vc1,
- const VectorClock* const vc2);
-void vc_min(VectorClock* const result,
- const VectorClock* const rhs);
-void vc_combine(VectorClock* const result,
- const VectorClock* const rhs);
-Bool vc_combine2(VectorClock* const result,
- const VectorClock* const rhs,
- const ThreadId tid);
-void vc_print(const VectorClock* const vc);
-void vc_snprint(Char* const str, Int const size,
- const VectorClock* const vc);
-void vc_check(const VectorClock* const vc);
-void vc_test(void);
+Bool DRD_(vc_lte)(const VectorClock* const vc1,
+ const VectorClock* const vc2);
+Bool DRD_(vc_ordered)(const VectorClock* const vc1,
+ const VectorClock* const vc2);
+void DRD_(vc_min)(VectorClock* const result,
+ const VectorClock* const rhs);
+void DRD_(vc_combine)(VectorClock* const result,
+ const VectorClock* const rhs);
+Bool DRD_(vc_combine2)(VectorClock* const result,
+ const VectorClock* const rhs,
+ const DrdThreadId tid);
+void DRD_(vc_print)(const VectorClock* const vc);
+void DRD_(vc_snprint)(Char* const str, const Int size,
+ const VectorClock* const vc);
+void DRD_(vc_check)(const VectorClock* const vc);
+void DRD_(vc_test)(void);
@@ -97,7 +99,7 @@
* equal.
*/
static __inline__
-Bool vc_lte(const VectorClock* const vc1, const VectorClock* const vc2)
+Bool DRD_(vc_lte)(const VectorClock* const vc1, const VectorClock* const vc2)
{
unsigned i;
unsigned j = 0;
|
|
From: <sv...@va...> - 2009-02-14 16:11:02
|
Author: bart
Date: 2009-02-14 16:10:53 +0000 (Sat, 14 Feb 2009)
New Revision: 9158
Log:
Introduced more DRD_ prefixes.
Modified:
trunk/drd/drd_bitmap.c
trunk/drd/drd_clientobj.c
trunk/drd/drd_clientreq.c
trunk/drd/drd_clientreq.h
trunk/drd/drd_error.c
trunk/drd/drd_error.h
trunk/drd/drd_load_store.c
trunk/drd/drd_load_store.h
trunk/drd/drd_main.c
trunk/drd/drd_suppression.c
trunk/drd/drd_suppression.h
trunk/drd/drd_thread.c
trunk/drd/tests/drd_bitmap_test.c
Modified: trunk/drd/drd_bitmap.c
===================================================================
--- trunk/drd/drd_bitmap.c 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_bitmap.c 2009-02-14 16:10:53 UTC (rev 9158)
@@ -858,7 +858,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: trunk/drd/drd_clientobj.c
===================================================================
--- trunk/drd/drd_clientobj.c 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_clientobj.c 2009-02-14 16:10:53 UTC (rev 9158)
@@ -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: trunk/drd/drd_clientreq.c
===================================================================
--- trunk/drd/drd_clientreq.c 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_clientreq.c 2009-02-14 16:10:53 UTC (rev 9158)
@@ -115,11 +115,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 +143,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 +153,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:
Modified: trunk/drd/drd_clientreq.h
===================================================================
--- trunk/drd/drd_clientreq.h 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_clientreq.h 2009-02-14 16:10:53 UTC (rev 9158)
@@ -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: trunk/drd/drd_error.c
===================================================================
--- trunk/drd/drd_error.c 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_error.c 2009-02-14 16:10:53 UTC (rev 9158)
@@ -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: trunk/drd/drd_error.h
===================================================================
--- trunk/drd/drd_error.h 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_error.h 2009-02-14 16:10:53 UTC (rev 9158)
@@ -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: trunk/drd/drd_load_store.c
===================================================================
--- trunk/drd/drd_load_store.c 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_load_store.c 2009-02-14 16:10:53 UTC (rev 9158)
@@ -67,10 +67,10 @@
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()));
@@ -99,12 +99,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 +134,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 +145,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 +156,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 +167,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 +178,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 +195,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 +206,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 +217,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 +228,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 +239,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 +285,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 +350,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 +407,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: trunk/drd/drd_load_store.h
===================================================================
--- trunk/drd/drd_load_store.h 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_load_store.h 2009-02-14 16:10:53 UTC (rev 9158)
@@ -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: trunk/drd/drd_main.c
===================================================================
--- trunk/drd/drd_main.c 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_main.c 2009-02-14 16:10:53 UTC (rev 9158)
@@ -53,23 +53,17 @@
#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_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_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;
@@ -90,11 +84,11 @@
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, "--drd-stats", DRD_(s_print_stats))
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)
@@ -106,7 +100,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)
@@ -131,7 +125,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);
@@ -154,12 +148,12 @@
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"
@@ -198,7 +192,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"
@@ -268,9 +262,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);
}
}
@@ -296,15 +290,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);
}
}
@@ -314,16 +308,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;
@@ -345,7 +340,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);
@@ -357,7 +352,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");
}
}
}
@@ -371,7 +366,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 */
@@ -447,10 +442,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");
}
}
@@ -472,7 +467,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
@@ -502,8 +497,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)
@@ -512,7 +506,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)();
}
@@ -524,11 +518,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;
@@ -585,17 +578,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);
@@ -621,7 +614,7 @@
DRD_(clientreq_init)();
- drd_suppression_init();
+ DRD_(suppression_init)();
clientobj_init();
}
Modified: trunk/drd/drd_suppression.c
===================================================================
--- trunk/drd/drd_suppression.c 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_suppression.c 2009-02-14 16:10:53 UTC (rev 9158)
@@ -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: trunk/drd/drd_suppression.h
===================================================================
--- trunk/drd/drd_suppression.h 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_suppression.h 2009-02-14 16:10:53 UTC (rev 9158)
@@ -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: trunk/drd/drd_thread.c
===================================================================
--- trunk/drd/drd_thread.c 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/drd_thread.c 2009-02-14 16:10:53 UTC (rev 9158)
@@ -266,9 +266,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);
Modified: trunk/drd/tests/drd_bitmap_test.c
===================================================================
--- trunk/drd/tests/drd_bitmap_test.c 2009-02-14 16:07:40 UTC (rev 9157)
+++ trunk/drd/tests/drd_bitmap_test.c 2009-02-14 16:10:53 UTC (rev 9158)
@@ -39,7 +39,7 @@
{ UInt ret; va_list vargs; va_start(vargs, format); ret = vprintf(format, vargs); va_end(vargs); return ret; }
UInt VG_(message)(VgMsgKind kind, const HChar* format, ...)
{ UInt ret; va_list vargs; va_start(vargs, format); ret = vprintf(format, vargs); va_end(vargs); printf("\n"); return ret; }
-Bool drd_is_suppressed(const Addr a1, const Addr a2)
+Bool DRD_(is_suppressed)(const Addr a1, const Addr a2)
{ assert(0); }
|
|
From: <sv...@va...> - 2009-02-14 16:07:44
|
Author: sewardj
Date: 2009-02-14 16:07:40 +0000 (Sat, 14 Feb 2009)
New Revision: 9157
Log:
Update the sed expressions that handle the output of ld --verbose:
GNU ld changed the output of ld --verbose recently, it used to emit:
PROVIDE (__executable_start = 0x400000); . = 0x400000 + SIZEOF_HEADERS;
and now emits:
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x08048000)); . = SEGMENT_START("text-segment", 0x08048000) + SIZEOF_HEADERS;
(Jakub Jelinek)
Modified:
trunk/Makefile.am
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2009-02-14 15:48:23 UTC (rev 9156)
+++ trunk/Makefile.am 2009-02-14 16:07:40 UTC (rev 9157)
@@ -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 $@
|
|
From: Julian S. <js...@ac...> - 2009-02-14 16:04:39
|
> So, what is the process to get this into valgrind proper?
Two things. First, address Bart's question some days back:
> Regarding your patch: are you sure that the construct cited below is
> foolproof ?
>
> + if(VG_(strstr)(VG_(clo_trace_children_skip), (Char*)ARG1)) {
> + VG_(message)(Vg_UserMsg, "Skip trace child %s %s\n", ARG1,
> VG_(clo_trace_children_skip));
> + VG_(clo_trace_children) = 0;
> + }
I agree with Bart; merely using strstr seems a bit prone to getting
false matches.
Secondly, could you also supply a suitable entry to docs/xml/manual-core.xml,
please? (Look for the string "--trace-children=" in this file, and
copy the varlistentry).
J
|
|
From: <sv...@va...> - 2009-02-14 15:48:27
|
Author: bart Date: 2009-02-14 15:48:23 +0000 (Sat, 14 Feb 2009) New Revision: 9156 Log: Removed configure test that is no longer used. Modified: trunk/configure.in Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2009-02-14 15:47:53 UTC (rev 9155) +++ trunk/configure.in 2009-02-14 15:48:23 UTC (rev 9156) @@ -799,26 +799,6 @@ ]) -# Check whether FILE has a member called _lock and whether it's a pointer. - -AC_MSG_CHECKING([for FILE::_lock]) - -AC_TRY_COMPILE( -[ - #include <stdio.h> -], [ - void *p; - p = stdout->_lock; - return 0; -], [ -AC_MSG_RESULT([yes]) -AC_DEFINE([HAVE_LIBC_FILE_LOCK], 1, - [Define to 1 if FILE has a member called _lock.]) -], [ -AC_MSG_RESULT([no]) -]) - - # Check whether pthread_mutex_t has a member called __m_kind. AC_MSG_CHECKING([for pthread_mutex_t::__m_kind]) |
|
From: <sv...@va...> - 2009-02-14 15:47:58
|
Author: bart
Date: 2009-02-14 15:47:53 +0000 (Sat, 14 Feb 2009)
New Revision: 9155
Log:
Added yet another suppression pattern.
Modified:
trunk/glibc-2.X-drd.supp
Modified: trunk/glibc-2.X-drd.supp
===================================================================
--- trunk/glibc-2.X-drd.supp 2009-02-14 15:28:46 UTC (rev 9154)
+++ trunk/glibc-2.X-drd.supp 2009-02-14 15:47:53 UTC (rev 9155)
@@ -317,6 +317,13 @@
fun:g_get_language_names
}
{
+ libQtCore-deref-that-calls-QThreadData-destructor
+ drd:ConflictingAccess
+ fun:_ZN11QThreadDataD1Ev
+ fun:_ZN11QThreadData5derefEv
+ obj:/usr/lib*/libQtCore.so.4.*
+}
+{
libQtCore-4.0/4.1-Q_GLOBAL_STATIC-connectionList
drd:ConflictingAccess
obj:/usr/lib*/libQtCore.so.4.*
|
|
From: <sv...@va...> - 2009-02-14 15:28:50
|
Author: sewardj
Date: 2009-02-14 15:28:46 +0000 (Sat, 14 Feb 2009)
New Revision: 9154
Log:
get_otrack_shadow_offset_wrk(ppc32): handle a missing case that caused
an assertion failure (Chris Wilson).
Modified:
trunk/memcheck/mc_machine.c
Modified: trunk/memcheck/mc_machine.c
===================================================================
--- trunk/memcheck/mc_machine.c 2009-02-14 15:13:31 UTC (rev 9153)
+++ trunk/memcheck/mc_machine.c 2009-02-14 15:28:46 UTC (rev 9154)
@@ -343,6 +343,7 @@
if (o == GOF(CIA_AT_SC) && sz == 4) return -1;
if (o == GOF(RESVN) && sz == 4) return -1;
if (o == GOF(FPROUND) && sz == 4) return -1;
+ if (o == GOF(VRSAVE) && sz == 4) return -1;
if (o == GOF(EMWARN) && sz == 4) return -1;
if (o == GOF(TISTART) && sz == 4) return -1;
if (o == GOF(TILEN) && sz == 4) return -1;
|
|
From: <sv...@va...> - 2009-02-14 15:13:38
|
Author: bart
Date: 2009-02-14 15:13:31 +0000 (Sat, 14 Feb 2009)
New Revision: 9153
Log:
- Moved several functions and variables from one source file to another.
- Created two new source files: drd_load_store.h and .c.
- Removed the header file drd_track.h.
Added:
trunk/drd/drd_load_store.c
trunk/drd/drd_load_store.h
Removed:
trunk/drd/drd_track.h
Modified:
trunk/drd/Makefile.am
trunk/drd/drd_clientreq.c
trunk/drd/drd_clientreq.h
trunk/drd/drd_main.c
trunk/drd/drd_thread.c
trunk/drd/drd_thread.h
trunk/drd/drd_thread_bitmap.h
Modified: trunk/drd/Makefile.am
===================================================================
--- trunk/drd/Makefile.am 2009-02-14 14:49:23 UTC (rev 9152)
+++ trunk/drd/Makefile.am 2009-02-14 15:13:31 UTC (rev 9153)
@@ -92,12 +92,13 @@
$(LIBREPLACEMALLOC_LDFLAGS_PPC64_AIX5)
-DRD_SOURCES = \
+DRD_SOURCES = \
drd_barrier.c \
drd_clientobj.c \
drd_clientreq.c \
drd_cond.c \
drd_error.c \
+ drd_load_store.c \
drd_main.c \
drd_malloc_wrappers.c \
drd_mutex.c \
@@ -111,12 +112,14 @@
noinst_HEADERS = \
drd_barrier.h \
+ drd_basics.h \
drd_bitmap.c \
drd_bitmap.h \
drd_clientobj.h \
drd_clientreq.h \
drd_cond.h \
drd_error.h \
+ drd_load_store.h \
drd_malloc_wrappers.h \
drd_mutex.h \
drd_rwlock.h \
@@ -127,7 +130,6 @@
drd_thread.c \
drd_thread.h \
drd_thread_bitmap.h \
- drd_track.h \
drd_vc.c \
drd_vc.h \
pub_drd_bitmap.h
Modified: trunk/drd/drd_clientreq.c
===================================================================
--- trunk/drd/drd_clientreq.c 2009-02-14 14:49:23 UTC (rev 9152)
+++ trunk/drd/drd_clientreq.c 2009-02-14 15:13:31 UTC (rev 9153)
@@ -1,8 +1,7 @@
/*
This file is part of drd, a data race detector.
- Copyright (C) 2006-2008 Bart Van Assche
- bar...@gm...
+ Copyright (C) 2006-2009 Bart Van Assche <bar...@gm...>.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -23,14 +22,14 @@
*/
+#include "drd_barrier.h"
#include "drd_clientreq.h"
#include "drd_cond.h"
#include "drd_mutex.h"
+#include "drd_rwlock.h"
#include "drd_semaphore.h"
#include "drd_suppression.h" // drd_start_suppression()
#include "drd_thread.h"
-#include "drd_track.h"
-#include "drd_rwlock.h"
#include "pub_tool_basics.h" // Bool
#include "pub_tool_debuginfo.h" // VG_(describe_IP)()
#include "pub_tool_libcassert.h"
@@ -41,52 +40,22 @@
#include "pub_tool_tooliface.h" // VG_(needs_...)()
-static void drd_spin_init_or_unlock(const Addr spinlock)
-{
- struct mutex_info* mutex_p = mutex_get(spinlock);
- if (mutex_p)
- {
- mutex_unlock(spinlock, mutex_type_spinlock);
- }
- else
- {
- mutex_init(spinlock, mutex_type_spinlock);
- }
-}
+/* Local function declarations. */
-static void drd_pre_cond_wait(const Addr cond,
- const Addr mutex, const MutexT mutex_type)
-{
- mutex_unlock(mutex, mutex_type);
- cond_pre_wait(cond, mutex);
-}
+static
+Bool DRD_(handle_client_request)(ThreadId vg_tid, UWord* arg, UWord* ret);
+static Addr DRD_(highest_used_stack_address)(const ThreadId vg_tid);
-static void drd_post_cond_wait(const Addr cond,
- const Addr mutex,
- const Bool took_lock)
-{
- cond_post_wait(cond);
- mutex_post_lock(mutex, took_lock, True);
-}
-static void drd_pre_cond_signal(const Addr cond)
-{
- cond_pre_signal(cond);
-}
-
-static void drd_pre_cond_broadcast(const Addr cond)
-{
- cond_pre_broadcast(cond);
-}
-
-/** 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.
+/**
+ * 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.
*/
-static Addr highest_used_stack_address(const ThreadId vg_tid)
+static Addr DRD_(highest_used_stack_address)(const ThreadId vg_tid)
{
UInt nframes;
const UInt n_ips = 10;
@@ -122,7 +91,12 @@
return husa;
}
-static Bool drd_handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret)
+/**
+ * DRD's handler for Valgrind client requests. The code below handles both
+ * DRD's public and tool-internal client requests.
+ */
+static
+Bool DRD_(handle_client_request)(ThreadId vg_tid, UWord* arg, UWord* ret)
{
UWord result = 0;
const DrdThreadId drd_tid = thread_get_running_tid();
@@ -150,7 +124,7 @@
case VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK:
{
- const Addr topmost_sp = highest_used_stack_address(vg_tid);
+ const Addr topmost_sp = DRD_(highest_used_stack_address)(vg_tid);
#if 0
UInt nframes;
const UInt n_ips = 20;
@@ -206,23 +180,21 @@
case VG_USERREQ__POST_THREAD_JOIN:
tl_assert(arg[1]);
- drd_post_thread_join(drd_tid,
- PtThreadIdToDrdThreadId(arg[1]));
+ DRD_(thread_post_join)(drd_tid, PtThreadIdToDrdThreadId(arg[1]));
break;
case VG_USERREQ__PRE_THREAD_CANCEL:
tl_assert(arg[1]);
- drd_pre_thread_cancel(drd_tid, PtThreadIdToDrdThreadId(arg[1]));
+ thread_pre_cancel(drd_tid);
break;
case VG_USERREQ__POST_THREAD_CANCEL:
tl_assert(arg[1]);
- drd_post_thread_cancel(drd_tid, PtThreadIdToDrdThreadId(arg[1]), arg[2]);
break;
case VG_USERREQ__PRE_MUTEX_INIT:
if (thread_enter_synchr(drd_tid) == 0)
- drd_pre_mutex_init(arg[1], arg[2]);
+ mutex_init(arg[1], arg[2]);
break;
case VG_USERREQ__POST_MUTEX_INIT:
@@ -235,22 +207,22 @@
case VG_USERREQ__POST_MUTEX_DESTROY:
if (thread_leave_synchr(drd_tid) == 0)
- drd_post_mutex_destroy(arg[1], arg[2]);
+ mutex_post_destroy(arg[1]);
break;
case VG_USERREQ__PRE_MUTEX_LOCK:
if (thread_enter_synchr(drd_tid) == 0)
- drd_pre_mutex_lock(arg[1], arg[2], arg[3]);
+ mutex_pre_lock(arg[1], arg[2], arg[3]);
break;
case VG_USERREQ__POST_MUTEX_LOCK:
if (thread_leave_synchr(drd_tid) == 0)
- drd_post_mutex_lock(arg[1], arg[2]);
+ mutex_post_lock(arg[1], arg[2], False/*post_cond_wait*/);
break;
case VG_USERREQ__PRE_MUTEX_UNLOCK:
if (thread_enter_synchr(drd_tid) == 0)
- drd_pre_mutex_unlock(arg[1], arg[2]);
+ mutex_unlock(arg[1], arg[2]);
break;
case VG_USERREQ__POST_MUTEX_UNLOCK:
@@ -259,7 +231,7 @@
case VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK:
if (thread_enter_synchr(drd_tid) == 0)
- drd_spin_init_or_unlock(arg[1]);
+ DRD_(spinlock_init_or_unlock)(arg[1]);
break;
case VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK:
@@ -268,7 +240,7 @@
case VG_USERREQ__PRE_COND_INIT:
if (thread_enter_synchr(drd_tid) == 0)
- drd_pre_cond_init(arg[1]);
+ cond_pre_init(arg[1]);
break;
case VG_USERREQ__POST_COND_INIT:
@@ -281,22 +253,34 @@
case VG_USERREQ__POST_COND_DESTROY:
if (thread_leave_synchr(drd_tid) == 0)
- drd_post_cond_destroy(arg[1]);
+ cond_post_destroy(arg[1]);
break;
case VG_USERREQ__PRE_COND_WAIT:
if (thread_enter_synchr(drd_tid) == 0)
- drd_pre_cond_wait(arg[1], arg[2], arg[3]);
+ {
+ const Addr cond = arg[1];
+ const Addr mutex = arg[2];
+ const MutexT mutex_type = arg[3];
+ mutex_unlock(mutex, mutex_type);
+ cond_pre_wait(cond, mutex);
+ }
break;
case VG_USERREQ__POST_COND_WAIT:
if (thread_leave_synchr(drd_tid) == 0)
- drd_post_cond_wait(arg[1], arg[2], arg[3]);
+ {
+ const Addr cond = arg[1];
+ const Addr mutex = arg[2];
+ const Bool took_lock = arg[3];
+ cond_post_wait(cond);
+ mutex_post_lock(mutex, took_lock, True);
+ }
break;
case VG_USERREQ__PRE_COND_SIGNAL:
if (thread_enter_synchr(drd_tid) == 0)
- drd_pre_cond_signal(arg[1]);
+ cond_pre_signal(arg[1]);
break;
case VG_USERREQ__POST_COND_SIGNAL:
@@ -305,7 +289,7 @@
case VG_USERREQ__PRE_COND_BROADCAST:
if (thread_enter_synchr(drd_tid) == 0)
- drd_pre_cond_broadcast(arg[1]);
+ cond_pre_broadcast(arg[1]);
break;
case VG_USERREQ__POST_COND_BROADCAST:
@@ -314,7 +298,7 @@
case VG_USERREQ__PRE_SEM_INIT:
if (thread_enter_synchr(drd_tid) == 0)
- drd_semaphore_init(arg[1], arg[2], arg[3]);
+ semaphore_init(arg[1], arg[2], arg[3]);
break;
case VG_USERREQ__POST_SEM_INIT:
@@ -327,32 +311,32 @@
case VG_USERREQ__POST_SEM_DESTROY:
if (thread_leave_synchr(drd_tid) == 0)
- drd_semaphore_destroy(arg[1]);
+ semaphore_destroy(arg[1]);
break;
case VG_USERREQ__PRE_SEM_WAIT:
if (thread_enter_synchr(drd_tid) == 0)
- drd_semaphore_pre_wait(drd_tid, arg[1]);
+ semaphore_pre_wait(arg[1]);
break;
case VG_USERREQ__POST_SEM_WAIT:
if (thread_leave_synchr(drd_tid) == 0)
- drd_semaphore_post_wait(drd_tid, arg[1], arg[2]);
+ semaphore_post_wait(drd_tid, arg[1], arg[2]);
break;
case VG_USERREQ__PRE_SEM_POST:
if (thread_enter_synchr(drd_tid) == 0)
- drd_semaphore_pre_post(drd_tid, arg[1]);
+ semaphore_pre_post(drd_tid, arg[1]);
break;
case VG_USERREQ__POST_SEM_POST:
if (thread_leave_synchr(drd_tid) == 0)
- drd_semaphore_post_post(drd_tid, arg[1], arg[2]);
+ semaphore_post_post(drd_tid, arg[1], arg[2]);
break;
case VG_USERREQ__PRE_BARRIER_INIT:
if (thread_enter_synchr(drd_tid) == 0)
- drd_barrier_init(arg[1], arg[2], arg[3], arg[4]);
+ barrier_init(arg[1], arg[2], arg[3], arg[4]);
break;
case VG_USERREQ__POST_BARRIER_INIT:
@@ -365,17 +349,17 @@
case VG_USERREQ__POST_BARRIER_DESTROY:
if (thread_leave_synchr(drd_tid) == 0)
- drd_barrier_destroy(arg[1], arg[2]);
+ barrier_destroy(arg[1], arg[2]);
break;
case VG_USERREQ__PRE_BARRIER_WAIT:
if (thread_enter_synchr(drd_tid) == 0)
- drd_barrier_pre_wait(drd_tid, arg[1], arg[2]);
+ barrier_pre_wait(drd_tid, arg[1], arg[2]);
break;
case VG_USERREQ__POST_BARRIER_WAIT:
if (thread_leave_synchr(drd_tid) == 0)
- drd_barrier_post_wait(drd_tid, arg[1], arg[2], arg[3]);
+ barrier_post_wait(drd_tid, arg[1], arg[2], arg[3]);
break;
case VG_USERREQ__PRE_RWLOCK_INIT:
@@ -426,7 +410,11 @@
return True;
}
-void drd_clientreq_init(void)
+/**
+ * Tell the Valgrind core the address of the DRD function that processes
+ * client requests. Must be called before any client code is run.
+ */
+void DRD_(clientreq_init)(void)
{
- VG_(needs_client_requests)(drd_handle_client_request);
+ VG_(needs_client_requests)(DRD_(handle_client_request));
}
Modified: trunk/drd/drd_clientreq.h
===================================================================
--- trunk/drd/drd_clientreq.h 2009-02-14 14:49:23 UTC (rev 9152)
+++ trunk/drd/drd_clientreq.h 2009-02-14 15:13:31 UTC (rev 9153)
@@ -22,14 +22,27 @@
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.
+ */
+
#ifndef __DRD_CLIENTREQ_H
#define __DRD_CLIENTREQ_H
#include "drd.h"
+#include "drd_basics.h" /* DRD_() */
+/*
+ * While the client requests defined in the header file "drd.h" define a
+ * public interface between client programs and the DRD tool, the client
+ * requests defined below are a tool-internal interface. These last client
+ * requests must only be used by the source code in the various *_intercepts.c
+ * source files.
+ */
enum {
/* Ask drd to suppress data race reports on all currently allocated stack */
/* data of the current thread. */
@@ -194,6 +207,11 @@
};
+/*
+ * Error checking on POSIX recursive mutexes, POSIX error checking mutexes,
+ * POSIX default mutexes and POSIX spinlocks happens by the same code. The
+ * values defined below specify which of these types a mutex really is.
+ */
typedef enum
{
mutex_type_unknown = -1,
@@ -204,13 +222,19 @@
mutex_type_spinlock = 4
} MutexT;
+/*
+ * Error checking on POSIX barriers and GOMP barriers happens by the same
+ * code. The integer values defined below specify the type of a barrier with
+ * a given client address.
+ */
typedef enum
{
pthread_barrier = 1,
gomp_barrier = 2
} BarrierT;
-void drd_clientreq_init(void);
+void DRD_(clientreq_init)(void);
+
#endif // __DRD_CLIENTREQ_H
Added: trunk/drd/drd_load_store.c
===================================================================
--- trunk/drd/drd_load_store.c (rev 0)
+++ trunk/drd/drd_load_store.c 2009-02-14 15:13:31 UTC (rev 9153)
@@ -0,0 +1,547 @@
+/*
+ This file is part of drd, a data race detector.
+
+ Copyright (C) 2006-2009 Bart Van Assche <bar...@gm...>.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+
+#include "drd_bitmap.h"
+#include "drd_thread_bitmap.h"
+
+/* Include several source files here in order to allow the compiler to */
+/* do more inlining. */
+#include "drd_bitmap.c"
+#include "drd_load_store.h"
+#include "drd_segment.c"
+#include "drd_thread.c"
+#include "drd_vc.c"
+#include "libvex_guest_offsets.h"
+
+
+/* STACK_POINTER_OFFSET: VEX register offset for the stack pointer register. */
+#if defined(VGA_x86)
+#define STACK_POINTER_OFFSET OFFSET_x86_ESP
+#elif defined(VGA_amd64)
+#define STACK_POINTER_OFFSET OFFSET_amd64_RSP
+#elif defined(VGA_ppc32)
+#define STACK_POINTER_OFFSET ((OFFSET_ppc32_GPR0 + OFFSET_ppc32_GPR2) / 2)
+#elif defined(VGA_ppc64)
+#define STACK_POINTER_OFFSET ((OFFSET_ppc64_GPR0 + OFFSET_ppc64_GPR2) / 2)
+#else
+#error Unknown architecture.
+#endif
+
+
+/* Local variables. */
+
+static Bool s_drd_check_stack_accesses = False;
+
+
+/* Function definitions. */
+
+Bool DRD_(get_check_stack_accesses)()
+{
+ return s_drd_check_stack_accesses;
+}
+
+void DRD_(set_check_stack_accesses)(const Bool c)
+{
+ tl_assert(c == False || c == True);
+ s_drd_check_stack_accesses = c;
+}
+
+void drd_trace_mem_access(const Addr addr, const SizeT size,
+ const BmAccessTypeT access_type)
+{
+ if (drd_is_any_traced(addr, addr + size))
+ {
+ char vc[80];
+ 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
+ ? "load "
+ : access_type == eStore
+ ? "store"
+ : access_type == eStart
+ ? "start"
+ : access_type == eEnd
+ ? "end "
+ : "????",
+ addr,
+ size,
+ VG_(get_running_tid)(),
+ thread_get_running_tid(),
+ vc);
+ VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(),
+ VG_(clo_backtrace_size));
+ tl_assert(DrdThreadIdToVgThreadId(thread_get_running_tid())
+ == VG_(get_running_tid)());
+ }
+}
+
+static VG_REGPARM(2) void drd_trace_mem_load(const Addr addr, const SizeT size)
+{
+ 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);
+}
+
+static void drd_report_race(const Addr addr, const SizeT size,
+ const BmAccessTypeT access_type)
+{
+ DataRaceErrInfo drei;
+
+ drei.tid = thread_get_running_tid();
+ drei.addr = addr;
+ drei.size = size;
+ drei.access_type = access_type;
+ VG_(maybe_record_error)(VG_(get_running_tid)(),
+ DataRaceErr,
+ VG_(get_IP)(VG_(get_running_tid)()),
+ "Conflicting accesses",
+ &drei);
+}
+
+VG_REGPARM(2) void drd_trace_load(Addr addr, SizeT size)
+{
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ /* The assert below has been commented out because of performance reasons.*/
+ tl_assert(thread_get_running_tid()
+ == VgThreadIdToDrdThreadId(VG_(get_running_tid())));
+#endif
+
+ 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_report_race(addr, size, eLoad);
+ }
+}
+
+static VG_REGPARM(1) void drd_trace_load_1(Addr addr)
+{
+ 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_report_race(addr, 1, eLoad);
+ }
+}
+
+static VG_REGPARM(1) void drd_trace_load_2(Addr addr)
+{
+ 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_report_race(addr, 2, eLoad);
+ }
+}
+
+static VG_REGPARM(1) void drd_trace_load_4(Addr addr)
+{
+ 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_report_race(addr, 4, eLoad);
+ }
+}
+
+static VG_REGPARM(1) void drd_trace_load_8(Addr addr)
+{
+ 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_report_race(addr, 8, eLoad);
+ }
+}
+
+VG_REGPARM(2) void drd_trace_store(Addr addr, SizeT size)
+{
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ /* The assert below has been commented out because of performance reasons.*/
+ tl_assert(thread_get_running_tid()
+ == VgThreadIdToDrdThreadId(VG_(get_running_tid())));
+#endif
+
+ 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_report_race(addr, size, eStore);
+ }
+}
+
+static VG_REGPARM(1) void drd_trace_store_1(Addr addr)
+{
+ 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_report_race(addr, 1, eStore);
+ }
+}
+
+static VG_REGPARM(1) void drd_trace_store_2(Addr addr)
+{
+ 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_report_race(addr, 2, eStore);
+ }
+}
+
+static VG_REGPARM(1) void drd_trace_store_4(Addr addr)
+{
+ 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_report_race(addr, 4, eStore);
+ }
+}
+
+static VG_REGPARM(1) void drd_trace_store_8(Addr addr)
+{
+ 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_report_race(addr, 8, eStore);
+ }
+}
+
+/**
+ * Return true if and only if addr_expr matches the pattern (SP) or
+ * <offset>(SP).
+ */
+static Bool is_stack_access(IRSB* const bb, IRExpr* const addr_expr)
+{
+ Bool result = False;
+
+ if (addr_expr->tag == Iex_RdTmp)
+ {
+ int i;
+ for (i = 0; i < bb->stmts_size; i++)
+ {
+ if (bb->stmts[i]
+ && bb->stmts[i]->tag == Ist_WrTmp
+ && bb->stmts[i]->Ist.WrTmp.tmp == addr_expr->Iex.RdTmp.tmp)
+ {
+ IRExpr* e = bb->stmts[i]->Ist.WrTmp.data;
+ if (e->tag == Iex_Get && e->Iex.Get.offset == STACK_POINTER_OFFSET)
+ {
+ result = True;
+ }
+
+ //ppIRExpr(e);
+ //VG_(printf)(" (%s)\n", result ? "True" : "False");
+ break;
+ }
+ }
+ }
+ return result;
+}
+
+static void instrument_load(IRSB* const bb,
+ IRExpr* const addr_expr,
+ const HWord size)
+{
+ IRExpr* size_expr;
+ IRExpr** argv;
+ IRDirty* di;
+
+ if (UNLIKELY(drd_any_address_is_traced()))
+ {
+ addStmtToIRSB(bb,
+ IRStmt_Dirty(
+ unsafeIRDirty_0_N(/*regparms*/2,
+ "drd_trace_load",
+ VG_(fnptr_to_fnentry)
+ (drd_trace_mem_load),
+ mkIRExprVec_2(addr_expr,
+ mkIRExpr_HWord(size)))));
+ }
+
+ if (! s_drd_check_stack_accesses && is_stack_access(bb, addr_expr))
+ return;
+
+ switch (size)
+ {
+ case 1:
+ argv = mkIRExprVec_1(addr_expr);
+ di = unsafeIRDirty_0_N(/*regparms*/1,
+ "drd_trace_load_1",
+ VG_(fnptr_to_fnentry)(drd_trace_load_1),
+ argv);
+ break;
+ case 2:
+ argv = mkIRExprVec_1(addr_expr);
+ di = unsafeIRDirty_0_N(/*regparms*/1,
+ "drd_trace_load_2",
+ VG_(fnptr_to_fnentry)(drd_trace_load_2),
+ argv);
+ break;
+ case 4:
+ argv = mkIRExprVec_1(addr_expr);
+ di = unsafeIRDirty_0_N(/*regparms*/1,
+ "drd_trace_load_4",
+ VG_(fnptr_to_fnentry)(drd_trace_load_4),
+ argv);
+ break;
+ case 8:
+ argv = mkIRExprVec_1(addr_expr);
+ di = unsafeIRDirty_0_N(/*regparms*/1,
+ "drd_trace_load_8",
+ VG_(fnptr_to_fnentry)(drd_trace_load_8),
+ argv);
+ break;
+ default:
+ size_expr = mkIRExpr_HWord(size);
+ argv = mkIRExprVec_2(addr_expr, size_expr);
+ di = unsafeIRDirty_0_N(/*regparms*/2,
+ "drd_trace_load",
+ VG_(fnptr_to_fnentry)(drd_trace_load),
+ argv);
+ break;
+ }
+ addStmtToIRSB(bb, IRStmt_Dirty(di));
+}
+
+static void instrument_store(IRSB* const bb,
+ IRExpr* const addr_expr,
+ const HWord size)
+{
+ IRExpr* size_expr;
+ IRExpr** argv;
+ IRDirty* di;
+
+ if (UNLIKELY(drd_any_address_is_traced()))
+ {
+ addStmtToIRSB(bb,
+ IRStmt_Dirty(
+ unsafeIRDirty_0_N(/*regparms*/2,
+ "drd_trace_store",
+ VG_(fnptr_to_fnentry)
+ (drd_trace_mem_store),
+ mkIRExprVec_2(addr_expr,
+ mkIRExpr_HWord(size)))));
+ }
+
+ if (! s_drd_check_stack_accesses && is_stack_access(bb, addr_expr))
+ return;
+
+ switch (size)
+ {
+ case 1:
+ argv = mkIRExprVec_1(addr_expr);
+ di = unsafeIRDirty_0_N(/*regparms*/1,
+ "drd_trace_store_1",
+ VG_(fnptr_to_fnentry)(drd_trace_store_1),
+ argv);
+ break;
+ case 2:
+ argv = mkIRExprVec_1(addr_expr);
+ di = unsafeIRDirty_0_N(/*regparms*/1,
+ "drd_trace_store_2",
+ VG_(fnptr_to_fnentry)(drd_trace_store_2),
+ argv);
+ break;
+ case 4:
+ argv = mkIRExprVec_1(addr_expr);
+ di = unsafeIRDirty_0_N(/*regparms*/1,
+ "drd_trace_store_4",
+ VG_(fnptr_to_fnentry)(drd_trace_store_4),
+ argv);
+ break;
+ case 8:
+ argv = mkIRExprVec_1(addr_expr);
+ di = unsafeIRDirty_0_N(/*regparms*/1,
+ "drd_trace_store_8",
+ VG_(fnptr_to_fnentry)(drd_trace_store_8),
+ argv);
+ break;
+ default:
+ size_expr = mkIRExpr_HWord(size);
+ argv = mkIRExprVec_2(addr_expr, size_expr);
+ di = unsafeIRDirty_0_N(/*regparms*/2,
+ "drd_trace_store",
+ VG_(fnptr_to_fnentry)(drd_trace_store),
+ argv);
+ break;
+ }
+ addStmtToIRSB(bb, IRStmt_Dirty(di));
+}
+
+IRSB* drd_instrument(VgCallbackClosure* const closure,
+ IRSB* const bb_in,
+ VexGuestLayout* const layout,
+ VexGuestExtents* const vge,
+ IRType const gWordTy,
+ IRType const hWordTy)
+{
+ IRDirty* di;
+ Int i;
+ IRSB* bb;
+ IRExpr** argv;
+ Bool instrument = True;
+ Bool bus_locked = False;
+
+ /* Set up BB */
+ bb = emptyIRSB();
+ bb->tyenv = deepCopyIRTypeEnv(bb_in->tyenv);
+ bb->next = deepCopyIRExpr(bb_in->next);
+ bb->jumpkind = bb_in->jumpkind;
+
+ for (i = 0; i < bb_in->stmts_used; i++)
+ {
+ IRStmt* const st = bb_in->stmts[i];
+ tl_assert(st);
+ if (st->tag == Ist_NoOp)
+ continue;
+
+ switch (st->tag)
+ {
+ /* Note: the code for not instrumenting the code in .plt */
+ /* sections is only necessary on CentOS 3.0 x86 (kernel 2.4.21 */
+ /* + glibc 2.3.2 + NPTL 0.60 + binutils 2.14.90.0.4). */
+ /* This is because on this platform dynamic library symbols are */
+ /* relocated in another way than by later binutils versions. The */
+ /* linker e.g. does not generate .got.plt sections on CentOS 3.0. */
+ case Ist_IMark:
+ instrument = VG_(seginfo_sect_kind)(NULL, 0, st->Ist.IMark.addr)
+ != Vg_SectPLT;
+ addStmtToIRSB(bb, st);
+ break;
+
+ case Ist_MBE:
+ switch (st->Ist.MBE.event)
+ {
+ case Imbe_Fence:
+ break; /* not interesting */
+ case Imbe_BusLock:
+ case Imbe_SnoopedStoreBegin:
+ tl_assert(! bus_locked);
+ bus_locked = True;
+ break;
+ case Imbe_BusUnlock:
+ case Imbe_SnoopedStoreEnd:
+ tl_assert(bus_locked);
+ bus_locked = False;
+ break;
+ default:
+ tl_assert(0);
+ }
+ addStmtToIRSB(bb, st);
+ break;
+
+ case Ist_Store:
+ if (instrument && ! bus_locked)
+ {
+ instrument_store(bb,
+ st->Ist.Store.addr,
+ sizeofIRType(typeOfIRExpr(bb->tyenv,
+ st->Ist.Store.data)));
+ }
+ addStmtToIRSB(bb, st);
+ break;
+
+ case Ist_WrTmp:
+ if (instrument)
+ {
+ const IRExpr* const data = st->Ist.WrTmp.data;
+ if (data->tag == Iex_Load)
+ {
+ instrument_load(bb,
+ data->Iex.Load.addr,
+ sizeofIRType(data->Iex.Load.ty));
+ }
+ }
+ addStmtToIRSB(bb, st);
+ break;
+
+ case Ist_Dirty:
+ if (instrument)
+ {
+ IRDirty* d = st->Ist.Dirty.details;
+ IREffect const mFx = d->mFx;
+ switch (mFx) {
+ case Ifx_None:
+ break;
+ case Ifx_Read:
+ case Ifx_Write:
+ case Ifx_Modify:
+ tl_assert(d->mAddr);
+ tl_assert(d->mSize > 0);
+ argv = mkIRExprVec_2(d->mAddr, mkIRExpr_HWord(d->mSize));
+ if (mFx == Ifx_Read || mFx == Ifx_Modify) {
+ di = unsafeIRDirty_0_N(
+ /*regparms*/2,
+ "drd_trace_load",
+ VG_(fnptr_to_fnentry)(drd_trace_load),
+ argv);
+ addStmtToIRSB(bb, IRStmt_Dirty(di));
+ }
+ if ((mFx == Ifx_Write || mFx == Ifx_Modify)
+ && ! bus_locked)
+ {
+ di = unsafeIRDirty_0_N(
+ /*regparms*/2,
+ "drd_trace_store",
+ VG_(fnptr_to_fnentry)(drd_trace_store),
+ argv);
+ addStmtToIRSB(bb, IRStmt_Dirty(di));
+ }
+ break;
+ default:
+ tl_assert(0);
+ }
+ }
+ addStmtToIRSB(bb, st);
+ break;
+
+ default:
+ addStmtToIRSB(bb, st);
+ break;
+ }
+ }
+
+ tl_assert(! bus_locked);
+
+ return bb;
+}
+
Added: trunk/drd/drd_load_store.h
===================================================================
--- trunk/drd/drd_load_store.h (rev 0)
+++ trunk/drd/drd_load_store.h 2009-02-14 15:13:31 UTC (rev 9153)
@@ -0,0 +1,52 @@
+/*
+ This file is part of drd, a data race detector.
+
+ Copyright (C) 2006-2009 Bart Van Assche <bar...@gm...>.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+
+/*
+ * Functions related to instrumentation of loads and stores.
+ */
+
+
+#ifndef __DRD_LOAD_STORE_H
+#define __DRD_LOAD_STORE_H
+
+
+#include <libvex.h> /* IRSB */
+#include <pub_tool_tooliface.h> /* VgCallbackClosure */
+
+
+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);
+VG_REGPARM(2) void drd_trace_load(Addr addr, SizeT size);
+VG_REGPARM(2) void drd_trace_store(Addr addr, SizeT size);
+
+
+#endif // __DRD_LOAD_STORE_H
Modified: trunk/drd/drd_main.c
===================================================================
--- trunk/drd/drd_main.c 2009-02-14 14:49:23 UTC (rev 9152)
+++ trunk/drd/drd_main.c 2009-02-14 15:13:31 UTC (rev 9153)
@@ -1,8 +1,7 @@
/*
This file is part of drd, a data race detector.
- Copyright (C) 2006-2008 Bart Van Assche
- bar...@gm...
+ Copyright (C) 2006-2009 Bart Van Assche <bar...@gm...>.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -24,10 +23,11 @@
#include "drd_barrier.h"
-#include "drd_clientreq.h"
#include "drd_clientobj.h"
+#include "drd_clientreq.h"
#include "drd_cond.h"
#include "drd_error.h"
+#include "drd_load_store.h"
#include "drd_malloc_wrappers.h"
#include "drd_mutex.h"
#include "drd_rwlock.h"
@@ -35,8 +35,6 @@
#include "drd_semaphore.h"
#include "drd_suppression.h"
#include "drd_thread.h"
-#include "drd_thread_bitmap.h"
-#include "drd_track.h"
#include "drd_vc.h"
#include "libvex_guest_offsets.h"
#include "pub_drd_bitmap.h"
@@ -55,15 +53,6 @@
#include "pub_tool_tooliface.h"
-/* Include several source files here in order to allow the compiler to */
-/* do more inlining. */
-#include "drd_bitmap.c"
-#include "drd_segment.c"
-#include "drd_thread.c"
-#include "drd_vc.c"
-
-
-
// Function declarations.
static void drd_start_client_code(const ThreadId tid, const ULong bbs_done);
@@ -71,9 +60,7 @@
// Local variables.
-static Bool s_drd_check_stack_accesses = False;
static Bool s_drd_print_stats = False;
-static Bool s_drd_trace_fork_join = False;
static Bool s_drd_var_info = False;
static Bool s_show_stack_usage = False;
@@ -84,6 +71,7 @@
static Bool drd_process_cmd_line_option(Char* arg)
{
+ int check_stack_accesses = -1;
int exclusive_threshold_ms = -1;
int segment_merging = -1;
int shared_threshold_ms = -1;
@@ -92,6 +80,7 @@
int trace_clientobj = -1;
int trace_cond = -1;
int trace_csw = -1;
+ int trace_fork_join = -1;
int trace_conflict_set = -1;
int trace_mutex = -1;
int trace_rwlock = -1;
@@ -100,7 +89,7 @@
int trace_suppression = -1;
Char* trace_address = 0;
- VG_BOOL_CLO (arg, "--check-stack-var", s_drd_check_stack_accesses)
+ 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,"--report-signal-unlocked",s_drd_report_signal_unlocked)
else VG_BOOL_CLO(arg, "--segment-merging", segment_merging)
@@ -111,7 +100,7 @@
else VG_BOOL_CLO(arg, "--trace-cond", trace_cond)
else VG_BOOL_CLO(arg, "--trace-conflict-set", trace_conflict_set)
else VG_BOOL_CLO(arg, "--trace-csw", trace_csw)
- else VG_BOOL_CLO(arg, "--trace-fork-join", s_drd_trace_fork_join)
+ else VG_BOOL_CLO(arg, "--trace-fork-join", trace_fork_join)
else VG_BOOL_CLO(arg, "--trace-mutex", trace_mutex)
else VG_BOOL_CLO(arg, "--trace-rwlock", trace_rwlock)
else VG_BOOL_CLO(arg, "--trace-segment", trace_segment)
@@ -124,6 +113,8 @@
else
return VG_(replacement_malloc_process_cmd_line_option)(arg);
+ if (check_stack_accesses != -1)
+ DRD_(set_check_stack_accesses)(check_stack_accesses);
if (exclusive_threshold_ms != -1)
{
mutex_set_lock_threshold(exclusive_threshold_ms);
@@ -150,6 +141,8 @@
cond_set_trace(trace_cond);
if (trace_csw != -1)
thread_trace_context_switches(trace_csw);
+ if (trace_fork_join != -1)
+ DRD_(thread_set_trace_fork_join)(trace_fork_join);
if (trace_conflict_set != -1)
thread_trace_conflict_set(trace_conflict_set);
if (trace_mutex != -1)
@@ -223,185 +216,6 @@
// Implements the thread-related core callbacks.
//
-static void drd_trace_mem_access(const Addr addr, const SizeT size,
- const BmAccessTypeT access_type)
-{
- if (drd_is_any_traced(addr, addr + size))
- {
- char vc[80];
- 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
- ? "load "
- : access_type == eStore
- ? "store"
- : access_type == eStart
- ? "start"
- : access_type == eEnd
- ? "end "
- : "????",
- addr,
- size,
- VG_(get_running_tid)(),
- thread_get_running_tid(),
- vc);
- VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(),
- VG_(clo_backtrace_size));
- tl_assert(DrdThreadIdToVgThreadId(thread_get_running_tid())
- == VG_(get_running_tid)());
- }
-}
-
-static VG_REGPARM(2) void drd_trace_mem_load(const Addr addr, const SizeT size)
-{
- 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);
-}
-
-static void drd_report_race(const Addr addr, const SizeT size,
- const BmAccessTypeT access_type)
-{
- DataRaceErrInfo drei;
-
- drei.tid = thread_get_running_tid();
- drei.addr = addr;
- drei.size = size;
- drei.access_type = access_type;
- VG_(maybe_record_error)(VG_(get_running_tid)(),
- DataRaceErr,
- VG_(get_IP)(VG_(get_running_tid)()),
- "Conflicting accesses",
- &drei);
-}
-
-static VG_REGPARM(2) void drd_trace_load(Addr addr, SizeT size)
-{
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- /* The assert below has been commented out because of performance reasons.*/
- tl_assert(thread_get_running_tid()
- == VgThreadIdToDrdThreadId(VG_(get_running_tid())));
-#endif
-
- 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_report_race(addr, size, eLoad);
- }
-}
-
-static VG_REGPARM(1) void drd_trace_load_1(Addr addr)
-{
- 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_report_race(addr, 1, eLoad);
- }
-}
-
-static VG_REGPARM(1) void drd_trace_load_2(Addr addr)
-{
- 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_report_race(addr, 2, eLoad);
- }
-}
-
-static VG_REGPARM(1) void drd_trace_load_4(Addr addr)
-{
- 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_report_race(addr, 4, eLoad);
- }
-}
-
-static VG_REGPARM(1) void drd_trace_load_8(Addr addr)
-{
- 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_report_race(addr, 8, eLoad);
- }
-}
-
-static
-VG_REGPARM(2) void drd_trace_store(Addr addr, SizeT size)
-{
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- /* The assert below has been commented out because of performance reasons.*/
- tl_assert(thread_get_running_tid()
- == VgThreadIdToDrdThreadId(VG_(get_running_tid())));
-#endif
-
- 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_report_race(addr, size, eStore);
- }
-}
-
-static VG_REGPARM(1) void drd_trace_store_1(Addr addr)
-{
- 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_report_race(addr, 1, eStore);
- }
-}
-
-static VG_REGPARM(1) void drd_trace_store_2(Addr addr)
-{
- 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_report_race(addr, 2, eStore);
- }
-}
-
-static VG_REGPARM(1) void drd_trace_store_4(Addr addr)
-{
- 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_report_race(addr, 4, eStore);
- }
-}
-
-static VG_REGPARM(1) void drd_trace_store_8(Addr addr)
-{
- 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_report_race(addr, 8, eStore);
- }
-}
-
static void drd_pre_mem_read(const CorePart part,
const ThreadId tid,
Char* const s,
@@ -486,7 +300,7 @@
{
drd_trace_mem_access(a1, len, eEnd);
}
- if (! is_stack_mem || s_drd_check_stack_accesses)
+ if (! is_stack_mem || DRD_(get_check_stack_accesses)())
{
thread_stop_using_mem(a1, a2);
clientobj_stop_using_mem(a1, a2);
@@ -606,7 +420,7 @@
{
thread_new_segment(drd_creator);
}
- if (s_drd_trace_fork_join)
+ if (DRD_(thread_get_trace_fork_join)())
{
VG_(message)(Vg_DebugMsg,
"drd_pre_thread_create creator = %d/%d, created = %d",
@@ -625,13 +439,13 @@
tl_assert(vg_created != VG_INVALID_THREADID);
drd_created = thread_post_create(vg_created);
- if (s_drd_trace_fork_join)
+ if (DRD_(thread_get_trace_fork_join)())
{
VG_(message)(Vg_DebugMsg,
"drd_post_thread_create created = %d/%d",
vg_created, drd_created);
}
- if (! s_drd_check_stack_accesses)
+ if (! DRD_(get_check_stack_accesses)())
{
drd_start_suppression(thread_get_stack_max(drd_created)
- thread_get_stack_size(drd_created),
@@ -640,60 +454,6 @@
}
}
-/* Process VG_USERREQ__POST_THREAD_JOIN. This client request is invoked just */
-/* after thread drd_joiner joined thread drd_joinee. */
-void drd_post_thread_join(DrdThreadId drd_joiner, DrdThreadId drd_joinee)
-{
- tl_assert(IsValidDrdThreadId(drd_joiner));
- tl_assert(IsValidDrdThreadId(drd_joinee));
- thread_new_segment(drd_joinee);
- thread_combine_vc(drd_joiner, drd_joinee);
- thread_new_segment(drd_joiner);
-
- if (s_drd_trace_fork_join)
- {
- const ThreadId joiner = DrdThreadIdToVgThreadId(drd_joiner);
- const ThreadId joinee = DrdThreadIdToVgThreadId(drd_joinee);
- const unsigned msg_size = 256;
- char* msg;
-
- msg = VG_(malloc)("drd.main.dptj.1", msg_size);
- tl_assert(msg);
- VG_(snprintf)(msg, msg_size,
- "drd_post_thread_join joiner = %d/%d, joinee = %d/%d",
- joiner, drd_joiner, joinee, drd_joinee);
- if (joiner)
- {
- 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));
- }
- VG_(message)(Vg_DebugMsg, "%s", msg);
- VG_(free)(msg);
- }
-
- if (! s_drd_check_stack_accesses)
- {
- 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);
- cond_thread_delete(drd_joinee);
- semaphore_thread_delete(drd_joinee);
- barrier_thread_delete(drd_joinee);
-}
-
-void drd_pre_thread_cancel(DrdThreadId canceling, DrdThreadId canceled)
-{
- thread_pre_cancel(canceled);
-}
-
-void drd_post_thread_cancel(DrdThreadId canceling, DrdThreadId canceled, Bool succeeded)
-{ }
-
/* Called after a thread has performed its last memory access. */
static void drd_thread_finished(ThreadId vg_tid)
{
@@ -702,7 +462,7 @@
tl_assert(VG_(get_running_tid)() == vg_tid);
drd_tid = VgThreadIdToDrdThreadId(vg_tid);
- if (s_drd_trace_fork_join)
+ if (DRD_(thread_get_trace_fork_join)())
{
VG_(message)(Vg_DebugMsg,
"drd_thread_finished tid = %d/%d%s",
@@ -738,101 +498,6 @@
thread_finished(drd_tid);
}
-void drd_pre_mutex_init(const Addr mutex, const MutexT mutex_type)
-{
- mutex_init(mutex, mutex_type);
-}
-
-void drd_post_mutex_destroy(const Addr mutex, const MutexT mutex_type)
-{
- mutex_post_destroy(mutex);
-}
-
-void drd_pre_mutex_lock(const Addr mutex, const MutexT mutex_type,
- const Bool trylock)
-{
- mutex_pre_lock(mutex, mutex_type, trylock);
-}
-
-void drd_post_mutex_lock(const Addr mutex, const Bool took_lock)
-{
- mutex_post_lock(mutex, took_lock, False);
-}
-
-void drd_pre_mutex_unlock(const Addr mutex, const MutexT mutex_type)
-{
- mutex_unlock(mutex, mutex_type);
-}
-
-void drd_pre_cond_init(Addr cond)
-{
- cond_pre_init(cond);
-}
-
-void drd_post_cond_destroy(Addr cond)
-{
- cond_post_destroy(cond);
-}
-
-void drd_semaphore_init(const Addr semaphore,
- const Word pshared, const Word value)
-{
- semaphore_init(semaphore, pshared, value);
-}
-
-void drd_semaphore_destroy(const Addr semaphore)
-{
- semaphore_destroy(semaphore);
-}
-
-void drd_semaphore_pre_wait(const DrdThreadId tid, const Addr semaphore)
-{
- semaphore_pre_wait(semaphore);
-}
-
-void drd_semaphore_post_wait(const DrdThreadId tid, const Addr semaphore,
- const Bool waited)
-{
- semaphore_post_wait(tid, semaphore, waited);
-}
-
-void drd_semaphore_pre_post(const DrdThreadId tid, const Addr semaphore)
-{
- semaphore_pre_post(tid, semaphore);
-}
-
-void drd_semaphore_post_post(const DrdThreadId tid, const Addr semaphore,
- const Bool waited)
-{
- semaphore_post_post(tid, semaphore, waited);
-}
-
-
-void drd_barrier_init(const Addr barrier,
- const BarrierT barrier_type, const Word count,
- const Bool reinitialization)
-{
- barrier_init(barrier, barrier_type, count, reinitialization);
-}
-
-void drd_barrier_destroy(const Addr barrier, const BarrierT barrier_type)
-{
- barrier_destroy(barrier, barrier_type);
-}
-
-void drd_barrier_pre_wait(const DrdThreadId tid, const Addr barrier,
- const BarrierT barrier_type)
-{
- barrier_pre_wait(tid, barrier, barrier_type);
-}
-
-void drd_barrier_post_wait(const DrdThreadId tid, const Addr barrier,
- const BarrierT barrier_type, const Bool waited)
-{
- barrier_post_wait(tid, barrier, barrier_type, waited);
-}
-
-
//
// Implementation of the tool interface.
//
@@ -853,319 +518,6 @@
}
}
-#if defined(VGA_x86)
-#define STACK_POINTER_OFFSET OFFSET_x86_ESP
-#elif defined(VGA_amd64)
-#define STACK_POINTER_OFFSET OFFSET_amd64_RSP
-#elif defined(VGA_ppc32)
-#define STACK_POINTER_OFFSET ((OFFSET_ppc32_GPR0 + OFFSET_ppc32_GPR2) / 2)
-#elif defined(VGA_ppc64)
-#define STACK_POINTER_OFFSET ((OFFSET_ppc64_GPR0 + OFFSET_ppc64_GPR2) / 2)
-#else
-#error Unknown architecture.
-#endif
-
-
-/** Return true if and only if addr_expr matches the pattern (SP) or
- * <offset>(SP).
- */
-static Bool is_stack_access(IRSB* const bb, IRExpr* const addr_expr)
-{
- Bool result = False;
-
- if (addr_expr->tag == Iex_RdTmp)
- {
- int i;
- for (i = 0; i < bb->stmts_size; i++)
- {
- if (bb->stmts[i]
- && bb->stmts[i]->tag == Ist_WrTmp
- && bb->stmts[i]->Ist.WrTmp.tmp == addr_expr->Iex.RdTmp.tmp)
- {
- IRExpr* e = bb->stmts[i]->Ist.WrTmp.data;
- if (e->tag == Iex_Get && e->Iex.Get.offset == STACK_POINTER_OFFSET)
- {
- result = True;
- }
-
- //ppIRExpr(e);
- //VG_(printf)(" (%s)\n", result ? "True" : "False");
- break;
- }
- }
- }
- return result;
-}
-
-static void instrument_load(IRSB* const bb,
- IRExpr* const addr_expr,
- const HWord size)
-{
- IRExpr* size_expr;
- IRExpr** argv;
- IRDirty* di;
-
- if (UNLIKELY(drd_any_address_is_traced()))
- {
- addStmtToIRSB(bb,
- IRStmt_Dirty(
- unsafeIRDirty_0_N(/*regparms*/2,
- "drd_trace_load",
- VG_(fnptr_to_fnentry)
- (drd_trace_mem_load),
- mkIRExprVec_2(addr_expr,
- mkIRExpr_HWord(size)))));
- }
-
- if (! s_drd_check_stack_accesses && is_stack_access(bb, addr_expr))
- return;
-
- switch (size)
- {
- case 1:
- argv = mkIRExprVec_1(addr_expr);
- di = unsafeIRDirty_0_N(/*regparms*/1,
- "drd_trace_load_1",
- VG_(fnptr_to_fnentry)(drd_trace_load_1),
- argv);
- break;
- case 2:
- argv = mkIRExprVec_1(addr_expr);
- di = unsafeIRDirty_0_N(/*regparms*/1,
- "drd_trace_load_2",
- VG_(fnptr_to_fnentry)(drd_trace_load_2),
- argv);
- break;
- case 4:
- argv = mkIRExprVec_1(addr_expr);
- di = unsafeIRDirty_0_N(/*regparms*/1,
- "drd_trace_load_4",
- VG_(fnptr_to_fnentry)(drd_trace_load_4),
- argv);
- break;
- case 8:
- argv = mkIRExprVec_1(addr_expr);
- di = unsafeIRDirty_0_N(/*regparms*/1,
- "drd_trace_load_8",
- VG_(fnptr_to_fnentry)(drd_trace_load_8),
- argv);
- break;
- default:
- size_expr = mkIRExpr_HWord(size);
- argv = mkIRExprVec_2(addr_expr, size_expr);
- di = unsafeIRDirty_0_N(/*regparms*/2,
- "drd_trace_load",
- VG_(fnptr_to_fnentry)(drd_trace_load),
- argv);
- break;
- }
- addStmtToIRSB(bb, IRStmt_Dirty(di));
-}
-
-static void instrument_store(IRSB* const bb,
- IRExpr* const addr_expr,
- const HWord size)
-{
- IRExpr* size_expr;
- IRExpr** argv;
- IRDirty* di;
-
- if (UNLIKELY(drd_any_address_is_traced()))
- {
- addStmtToIRSB(bb,
- IRStmt_Dirty(
- unsafeIRDirty_0_N(/*regparms*/2,
- "drd_trace_store",
- VG_(fnptr_to_fnentry)
- (drd_trace_mem_store),
- mkIRExprVec_2(addr_expr,
- mkIRExpr_HWord(size)))));
- }
-
- if (! s_drd_check_stack_accesses && is_stack_access(bb, addr_expr))
- return;
-
- switch (size)
- {
- case 1:
- argv = mkIRExprVec_1(addr_expr);
- di = unsafeIRDirty_0_N(/*regparms*/1,
- "drd_trace_store_1",
- VG_(fnptr_to_fnentry)(drd_trace_store_1),
- argv);
- break;
- case 2:
- argv = mkIRExprVec_1(addr_expr);
- di = unsafeIRDirty_0_N(/*regparms*/1,
- "drd_trace_store_2",
- VG_(fnptr_to_fnentry)(drd_trace_store_2),
- argv);
- break;
- case 4:
- argv = mkIRExprVec_1(addr_expr);
- di = unsafeIRDirty_0_N(/*regparms*/1,
- "drd_trace_store_4",
- VG_(fnptr_to_fnentry)(drd_trace_store_4),
- argv);
- break;
- case 8:
- argv = mkIRExprVec_1(addr_expr);
- di = unsafeIRDirty_0_N(/*regparms*/1,
- "drd_trace_store_8",
- VG_(fnptr_to_fnentry)(drd_trace_store_8),
- argv);
- break;
- default:
- size_expr = mkIRExpr_HWord(size);
- argv = mkIRExprVec_2(addr_expr, size_expr);
- di = unsafeIRDirty_0_N(/*regparms*/2,
- "drd_trace_store",
- VG_(fnptr_to_fnentry)(drd_trace_store),
- argv);
- break;
- }
- addStmtToIRSB(bb, IRStmt_Dirty(di));
-}
-
-static
-IRSB* drd_instrument(VgCallbackClosure* const closure,
- IRSB* const bb_in,
- VexGuestLayout* const layout,
- VexGuestExtents* const vge,
- IRType const gWordTy,
- IRType const hWordTy)
-{
- IRDirty* di;
- Int i;
- IRSB* bb;
- IRExpr** argv;
- Bool instrument = True;
- Bool bus_locked = False;
-
- /* Set up BB */
- bb = emptyIRSB();
- bb->tyenv = deepCopyIRTypeEnv(bb_in->tyenv);
- bb->next = deepCopyIRExpr(bb_in->next);
- bb->jumpkind = bb_in->jumpkind;
-
- for (i = 0; i < bb_in->stmts_used; i++)
- {
- IRStmt* const st = bb_in->stmts[i];
- tl_assert(st);
- if (st->tag == Ist_NoOp)
- continue;
-
- switch (st->tag)
- {
- /* Note: the code for not instrumenting the code in .plt */
- /* sections is only necessary on CentOS 3.0 x86 (kernel 2.4.21 */
- /* + glibc 2.3.2 + NPTL 0.60 + binutils 2.14.90.0.4). */
- /* This is because on this platform dynamic library symbols are */
- /* relocated in another way than by later binutils versions. The */
- /* linker e.g. does not generate .got.plt sections on CentOS 3.0. */
- case Ist_IMark:
- instrument = VG_(seginfo_sect_kind)(NULL, 0, st->Ist.IMark.addr)
- != Vg_SectPLT;
- addStmtToIRSB(bb, st);
- break;
-
- case Ist_MBE:
- switch (st->Ist.MBE.event)
- {
- case Imbe_Fence:
- break; /* not interesting */
- case Imbe_BusLock:
- case Imbe_SnoopedStoreBegin:
- tl_assert(! bus_locked);
- bus_locked = True;
- break;
- case Imbe_BusUnlock:
- case Imbe_SnoopedStoreEnd:
- tl_assert(bus_locked);
- bus_locked = False;
- break;
- default:
- tl_assert(0);
- }
- addStmtToIRSB(bb, st);
- break;
-
- case Ist_Store:
- if (instrument && ! bus_locked)
- {
- instrument_store(bb,
- st->Ist.Store.addr,
- sizeofIRType(typeOfIRExpr(bb->tyenv,
- st->Ist.Store.data)));
- }
- addStmtToIRSB(bb, st);
- break;
-
- case Ist_WrTmp:
- if (instrument)
- {
- const IRExpr* const data = st->Ist.WrTmp.data;
- if (data->tag == Iex_Load)
- {
- instrument_load(bb,
- data->Iex.Load.addr,
- sizeofIRType(data->Iex.Load.ty));
- }
- }
- addStmtToIRSB(bb, st);
- break;
-
- case Ist_Dirty:
- if (instrument)
- {
- IRDirty* d = st->Ist.Dirty.details;
- IREffect const mFx = d->mFx;
- switch (mFx) {
- case Ifx_None:
- break;
- case Ifx_Read:
- case Ifx_Write:
- case Ifx_Modify:
- tl_assert(d->mAddr);
- tl_assert(d->mSize > 0);
- argv = mkIRExprVec_2(d->mAddr, mkIRExpr_HWord(d->mSize));
- if (mFx == Ifx_Read || mFx == Ifx_Modify) {
- di = unsafeIRDirty_0_N(
- /*regparms*/2,
- "drd_trace_load",
- VG_(fnptr_to_fnentry)(drd_trace_load),
- argv);
- addStmtToIRSB(bb, IRStmt_Dirty(di));
- }
- if ((mFx == Ifx_Write || mFx == Ifx_Modify)
- && ! bus_locked)
- {
- di = unsafeIRDirty_0_N(
- /*regparms*/2,
- "drd_trace_store",
- VG_(fnptr_to_fnentry)(drd_trace_store),
- argv);
- addStmtToIRSB(bb, IRStmt_Dirty(di));
- }
- break;
- default:
- tl_assert(0);
- }
- }
- addStmtToIRSB(bb, st);
- break;
-
- default:
- addStmtToIRSB(bb, st);
- break;
- }
- }
-
- tl_assert(! bus_locked);
-
- return bb;
-}
-
static void drd_start_client_code(const ThreadId tid, const ULong bbs_done)
{
tl_assert(tid == VG_(get_running_tid)());
@@ -1267,7 +619,7 @@
drd_register_malloc_wrappers(drd_start_using_mem_w_ecu,
drd_stop_using_nonstack_mem);
- drd_clientreq_init();
+ DRD_(clientreq_init)();
drd_suppression_init();
Modified: trunk/drd/drd_thread.c
===================================================================
--- trunk/drd/drd_thread.c 2009-02-14 14:49:23 UTC (rev 9152)
+++ trunk/drd/drd_thread.c 2009-02-14 15:13:31 UTC (rev 9153)
@@ -24,7 +24,11 @@
#include "drd_error.h"
+#include "drd_barrier.h"
+#include "drd_cond.h"
+#include "drd_mutex.h"
#include "drd_segment.h"
+#include "drd_semaphore.h"
#include "drd_suppression.h"
#include "drd_thread.h"
#include "pub_tool_vki.h"
@@ -66,6 +70,7 @@
struct bitmap* s_conflict_set;
static Bool s_trace_context_switches = False;
static Bool s_trace_conflict_set = False;
+static Bool s_trace_fork_join = False;
static Bool s_segment_merging = True;
@@ -73,16 +78,30 @@
void thread_trace_context_switches(const Bool t)
{
+ tl_assert(t == False || t == True);
s_trace_context_switches = t;
}
void thread_trace_conflict_set(const Bool t)
{
+ tl_assert(t == False || t == True);
s_trace_conflict_set = t;
}
+Bool DRD_(thread_get_trace_fork_join)(void)
+{
+ return s_trace_fork_join;
+}
+
+void DRD_(thread_set_trace_fork_join)(const Bool t)
+{
+ tl_assert(t == False || t == True);
+ s_trace_fork_join = t;
+}
+
void thread_set_segment_merging(const Bool m)
{
+ tl_assert(m == False || m == True);
s_segment_merging = m;
}
@@ -211,6 +230,53 @@
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)
+{
+ tl_assert(IsValidDrdThreadId(drd_joiner));
+ tl_assert(IsValidDrdThreadId(drd_joinee));
+ thread_new_segment(drd_joinee);
+ thread_combine_vc(drd_joiner, drd_joinee);
+ thread_new_segment(drd_joiner);
+
+ if (s_trace_fork_join)
+ {
+ const ThreadId joiner = DrdThreadIdToVgThreadId(drd_joiner);
+ const ThreadId joinee = DrdThreadIdToVgThreadId(drd_joinee);
+ const unsigned msg_size = 256;
+ char* msg;
+
+ msg = VG_(malloc)("drd.main.dptj.1", msg_size);
+ tl_assert(msg);
+ VG_(snprintf)(msg, msg_size,
+ "drd_post_thread_join joiner = %d/%d, joinee = %d/%d",
+ joiner, drd_joiner, joinee, drd_joinee);
+ if (joiner)
+ {
+ 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));
+ }
+ VG_(message)(Vg_DebugMsg, "%s", msg);
+ VG_(free)(msg);
+ }
+
+ 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));
+ }
+ thread_delete(drd_joinee);
+ mutex_thread_delete(drd_joinee);
+ cond_thread_delete(drd_joinee);
+ semaphore_thread_delete(drd_joinee);
+ barrier_thread_delete(drd_joinee);
+}
+
/** Allocate the first segment for a thread. Call this just after
* pthread_create().
*/
@@ -272,8 +338,9 @@
return s_threadinfo[tid].stack_size;
}
-/** Clean up thread-specific data structures. Call this just after
- * pth...
[truncated message content] |
|
From: <sv...@va...> - 2009-02-14 14:49:27
|
Author: bart Date: 2009-02-14 14:49:23 +0000 (Sat, 14 Feb 2009) New Revision: 9152 Log: Added a missing #include directive. Modified: trunk/drd/drd_bitmap.h Modified: trunk/drd/drd_bitmap.h =================================================================== --- trunk/drd/drd_bitmap.h 2009-02-14 14:46:16 UTC (rev 9151) +++ trunk/drd/drd_bitmap.h 2009-02-14 14:49:23 UTC (rev 9152) @@ -27,6 +27,7 @@ #define __DRD_BITMAP_H +#include "pub_tool_basics.h" #include "pub_tool_oset.h" #include "pub_tool_libcbase.h" |
|
From: <sv...@va...> - 2009-02-14 14:46:22
|
Author: bart
Date: 2009-02-14 14:46:16 +0000 (Sat, 14 Feb 2009)
New Revision: 9151
Log:
Relaxed an assert statement: a thread canceled by pthread_cancel() can really exit with synchr_nesting > 0.
Modified:
trunk/drd/drd_thread.c
Modified: trunk/drd/drd_thread.c
===================================================================
--- trunk/drd/drd_thread.c 2009-02-14 12:14:50 UTC (rev 9150)
+++ trunk/drd/drd_thread.c 2009-02-14 14:46:16 UTC (rev 9151)
@@ -282,7 +282,7 @@
tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
&& tid != DRD_INVALID_THREADID);
- tl_assert(s_threadinfo[tid].synchr_nesting == 0);
+ tl_assert(s_threadinfo[tid].synchr_nesting >= 0);
for (sg = s_threadinfo[tid].last; sg; sg = sg_prev)
{
sg_prev = sg->prev;
|
|
From: <sv...@va...> - 2009-02-14 13:31:02
|
Author: bart
Date: 2009-02-14 12:12:57 +0000 (Sat, 14 Feb 2009)
New Revision: 9149
Log:
- Performance improvement: eliminated busy waiting from thread creation.
- Applied DRD_() prefix to all names of functions that are not
intercepts of client code.
- Removed superfluous include directive, namely #include <inttypes.h>.
- Removed hack for suppressing false positive reports on stdio / stderr
because recently a suppression pattern was added for these races.
- Removed unused code and declarations.
- Added more comments.
- Updated copyright statement.
Modified:
trunk/drd/drd_pthread_intercepts.c
Modified: trunk/drd/drd_pthread_intercepts.c
===================================================================
--- trunk/drd/drd_pthread_intercepts.c 2009-02-14 11:54:42 UTC (rev 9148)
+++ trunk/drd/drd_pthread_intercepts.c 2009-02-14 12:12:57 UTC (rev 9149)
@@ -1,13 +1,12 @@
/*--------------------------------------------------------------------*/
-/*--- Client-space code for drd. drd_pthread_intercepts.c ---*/
+/*--- Client-space code for DRD. drd_pthread_intercepts.c ---*/
/*--------------------------------------------------------------------*/
/*
- This file is part of drd, a data race detector.
+ This file is part of DRD, a data race detector.
- Copyright (C) 2006-2008 Bart Van Assche
- bar...@gm...
+ Copyright (C) 2006-2009 Bart Van Assche <bar...@gm...>.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -40,26 +39,27 @@
originates from Valgrind.
------------------------------------------------------------------ */
-// Make sure 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
-#include <assert.h>
-#include <inttypes.h> // uintptr_t
-#include <pthread.h>
-#include <semaphore.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h> // confstr()
-#include "config.h"
-#include "drd_basics.h"
+#include <assert.h> /* assert() */
+#include <pthread.h> /* pthread_mutex_t */
+#include <semaphore.h> /* sem_t */
+#include <stdio.h> /* fprintf() */
+#include <stdlib.h> /* malloc(), free() */
+#include <unistd.h> /* confstr() */
+#include "config.h" /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP etc. */
+#include "drd_basics.h" /* DRD_() */
#include "drd_clientreq.h"
-#include "pub_tool_redir.h"
+#include "pub_tool_redir.h" /* VG_WRAP_FUNCTION_ZZ() */
-// Defines.
+/* Defines. */
#define PTH_FUNC(ret_ty, f, args...) \
ret_ty VG_WRAP_FUNCTION_ZZ(libpthreadZdsoZd0,f)(args); \
@@ -73,74 +73,78 @@
void* (*start)(void*);
void* arg;
int detachstate;
-#if 0
- pthread_mutex_t mutex;
- pthread_cond_t cond;
-#else
- int wrapper_started;
-#endif
} VgPosixThreadArgs;
-/* Function declarations. */
+/* Local function declarations. */
-static void init(void) __attribute__((constructor));
-static void check_threading_library(void);
-static void vg_set_main_thread_state(void);
+static void DRD_(init)(void) __attribute__((constructor));
+static void DRD_(check_threading_library)(void);
+static void DRD_(set_main_thread_state)(void);
/* Function definitions. */
-/** Shared library initialization function: the _init() function is called
- * after dlopen() has loaded the shared library. This function must not
- * be declared static.
+/**
+ * Shared library initialization function. The function init() is called after
+ * dlopen() has loaded the shared library with DRD client intercepts because
+ * the constructor attribute was specified in the declaration of this function.
+ * Note: do specify the -nostdlib option to gcc when linking this code into a
+ * shared library because doing so would cancel the effect of the constructor
+ * attribute ! Using the gcc option -nodefaultlibs is fine because this last
+ * option preserves the shared library initialization code that calls
+ * constructor and destructor functions.
*/
-static void init(void)
+static void DRD_(init)(void)
{
- check_threading_library();
- vg_set_main_thread_state();
- /* glibc up to and including version 2.8 triggers conflicting accesses */
- /* on stdout and stderr when sending output to one of these streams from */
- /* more than one thread. Suppress data race reports on these objects. */
- DRD_IGNORE_VAR(*stdout);
- DRD_IGNORE_VAR(*stderr);
-#if defined(HAVE_LIBC_FILE_LOCK)
- DRD_IGNORE_VAR(*(pthread_mutex_t*)(stdout->_lock));
- DRD_IGNORE_VAR(*(pthread_mutex_t*)(stderr->_lock));
-#endif
+ DRD_(check_threading_library)();
+ DRD_(set_main_thread_state)();
}
-static MutexT pthread_to_drd_mutex_type(const int kind)
+/**
+ * POSIX threads and DRD each have their own mutex type identification.
+ * Convert POSIX threads' mutex type to DRD's mutex type. In the code below
+ * if-statements are used to test the value of 'kind' instead of a switch
+ * statement because some of the PTHREAD_MUTEX_ macro's may have the same
+ * value.
+ */
+static MutexT DRD_(pthread_to_drd_mutex_type)(const int kind)
{
- switch (kind)
- {
- /* PTHREAD_MUTEX_RECURSIVE_NP */
- case PTHREAD_MUTEX_RECURSIVE:
+ if (kind == PTHREAD_MUTEX_RECURSIVE)
return mutex_type_recursive_mutex;
- /* PTHREAD_MUTEX_ERRORCHECK_NP */
- case PTHREAD_MUTEX_ERRORCHECK:
+ else if (kind == PTHREAD_MUTEX_ERRORCHECK)
return mutex_type_errorcheck_mutex;
- /* PTHREAD_MUTEX_TIMED_NP */
- /* PTHREAD_MUTEX_NORMAL */
- case PTHREAD_MUTEX_DEFAULT:
+ else if (kind == PTHREAD_MUTEX_NORMAL)
+ return mutex_type_default_mutex;
+ else if (kind == PTHREAD_MUTEX_DEFAULT)
+ return mutex_type_default_mutex;
#if defined(HAVE_PTHREAD_MUTEX_ADAPTIVE_NP)
- case PTHREAD_MUTEX_ADAPTIVE_NP:
-#endif
+ else if (kind == PTHREAD_MUTEX_ADAPTIVE_NP)
return mutex_type_default_mutex;
+#endif
+ else
+ {
+ return mutex_type_invalid_mutex;
}
- return mutex_type_invalid_mutex;
}
-/** @note The function mutex_type() has been declared inline in order
- * to avoid that it shows up in call stacks.
+/**
+ * Read the mutex type stored in the client memory used for the mutex
+ * implementation.
+ *
+ * @note This function depends on the implementation of the POSIX threads
+ * library -- the POSIX standard does not define the name of the member in
+ * which the mutex type is stored.
+ * @note The function mutex_type() has been declared inline in order
+ * to avoid that it shows up in call stacks (drd/tests/...exp* files).
*/
-static __inline__ MutexT mutex_type(pthread_mutex_t* mutex)
+static __inline__ MutexT DRD_(mutex_type)(pthread_mutex_t* mutex)
{
#if defined(HAVE_PTHREAD_MUTEX_T__M_KIND)
- /* LinuxThreads. */
+ /* glibc + LinuxThreads. */
const int kind = mutex->__m_kind;
#elif defined(HAVE_PTHREAD_MUTEX_T__DATA__KIND)
- /* NPTL. */
+ /* glibc + NPTL. */
const int kind = mutex->__data.__kind;
#else
/* Another POSIX threads implementation. Regression tests will fail. */
@@ -149,55 +153,56 @@
"Did not recognize your POSIX threads implementation. Giving up.\n");
assert(0);
#endif
- return pthread_to_drd_mutex_type(kind);
+ return DRD_(pthread_to_drd_mutex_type)(kind);
}
-static void vg_start_suppression(const void* const p, size_t const size)
+/**
+ * Tell DRD whether 'tid' is a joinable thread or a detached thread.
+ */
+static void DRD_(set_joinable)(const pthread_t tid, const int joinable)
{
int res;
- VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_START_SUPPRESSION,
- p, size, 0, 0, 0);
-}
-
-static void vg_set_joinable(const pthread_t tid, const int joinable)
-{
- int res;
assert(joinable == 0 || joinable == 1);
VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__SET_JOINABLE,
tid, joinable, 0, 0, 0);
}
+/**
+ * The function called from the thread created by pthread_create().
+ */
static void* DRD_(thread_wrapper)(void* arg)
{
int res;
+ VgPosixThreadArgs* arg_ptr;
+ VgPosixThreadArgs arg_copy;
VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK,
0, 0, 0, 0, 0);
- {
- VgPosixThreadArgs* const arg_ptr = (VgPosixThreadArgs*)arg;
- VgPosixThreadArgs const arg_copy = *arg_ptr;
- void* result;
+ arg_ptr = (VgPosixThreadArgs*)arg;
+ arg_copy = *arg_ptr;
-#if 0
- pthread_mutex_lock(arg_ptr->mutex);
- pthread_cond_signal(arg_ptr->cond);
- pthread_mutex_unlock(arg_ptr->mutex);
-#else
- arg_ptr->wrapper_started = 1;
-#endif
+ /*
+ * 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);
- vg_set_joinable(pthread_self(),
- arg_copy.detachstate == PTHREAD_CREATE_JOINABLE);
- result = (arg_copy.start)(arg_copy.arg);
- return result;
- }
+ VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SET_PTHREADID,
+ pthread_self(), 0, 0, 0, 0);
+
+ DRD_(set_joinable)(pthread_self(),
+ arg_copy.detachstate == PTHREAD_CREATE_JOINABLE);
+
+ return (arg_copy.start)(arg_copy.arg);
}
-/** Return 1 if LinuxThread has been detected, and 0 otherwise. */
-static int detected_linuxthreads(void)
+/**
+ * Return 1 if the LinuxThread implementation has been detected, and 0
+ * otherwise. For more information about the confstr() function, see also
+ * http://www.opengroup.org/onlinepubs/009695399/functions/confstr.html
+ */
+static int DRD_(detected_linuxthreads)(void)
{
#if defined(linux)
#if defined(_CS_GNU_LIBPTHREAD_VERSION)
@@ -217,35 +222,40 @@
#endif
}
-/** Stop and print an error message in case a non-supported threading
- * library (LinuxThreads) has been detected.
+/**
+ * Stop and print an error message in case a non-supported threading
+ * library implementation (LinuxThreads) has been detected.
*/
-static void check_threading_library(void)
+static void DRD_(check_threading_library)(void)
{
- if (detected_linuxthreads())
+ if (DRD_(detected_linuxthreads)())
{
if (getenv("LD_ASSUME_KERNEL"))
{
fprintf(stderr,
- "Detected the LinuxThreads threading library. Sorry, but DRD only supports\n"
- "the newer NPTL (Native POSIX Threads Library). Please try to rerun DRD\n"
- "after having unset the environment variable LD_ASSUME_KERNEL. Giving up.\n"
+"Detected the LinuxThreads threading library. Sorry, but DRD only supports\n"
+"the newer NPTL (Native POSIX Threads Library). Please try to rerun DRD\n"
+"after having unset the environment variable LD_ASSUME_KERNEL. Giving up.\n"
);
}
else
{
fprintf(stderr,
- "Detected the LinuxThreads threading library. Sorry, but DRD only supports\n"
- "the newer NPTL (Native POSIX Threads Library). Please try to rerun DRD\n"
- "after having upgraded to a newer version of your Linux distribution.\n"
- "Giving up.\n"
+"Detected the LinuxThreads threading library. Sorry, but DRD only supports\n"
+"the newer NPTL (Native POSIX Threads Library). Please try to rerun DRD\n"
+"after having upgraded to a newer version of your Linux distribution.\n"
+"Giving up.\n"
);
}
abort();
}
}
-static void vg_set_main_thread_state(void)
+/**
+ * The main thread is the only thread not created by pthread_create().
+ * Update DRD's state information about the main thread.
+ */
+static void DRD_(set_main_thread_state)(void)
{
int res;
@@ -266,55 +276,43 @@
int res;
int ret;
OrigFn fn;
- VgPosixThreadArgs vgargs;
+ VgPosixThreadArgs* vgargs;
VALGRIND_GET_ORIG_FN(fn);
- vg_start_suppression(&vgargs.wrapper_started,
- sizeof(vgargs.wrapper_started));
- vgargs.start = start;
- vgargs.arg = arg;
- vgargs.wrapper_started = 0;
- vgargs.detachstate = PTHREAD_CREATE_JOINABLE;
+ vgargs = malloc(sizeof *vgargs);
+ assert(vgargs);
+ vgargs->start = start;
+ vgargs->arg = arg;
+ /*
+ * 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;
if (attr)
{
- if (pthread_attr_getdetachstate(attr, &vgargs.detachstate) != 0)
+ if (pthread_attr_getdetachstate(attr, &vgargs->detachstate) != 0)
{
assert(0);
}
}
- assert(vgargs.detachstate == PTHREAD_CREATE_JOINABLE
- || vgargs.detachstate == PTHREAD_CREATE_DETACHED);
-#if 0
- pthread_mutex_init(&vgargs.mutex, 0);
- pthread_cond_init(&vgargs.cond, 0);
- pthread_mutex_lock(&vgargs.mutex);
-#endif
+ assert(vgargs->detachstate == PTHREAD_CREATE_JOINABLE
+ || vgargs->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), vgargs);
+
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__DRD_START_RECORDING,
0, 0, 0, 0, 0);
-#if 0
- pthread_cond_wait(&vgargs.cond, &vgargs.mutex);
- pthread_mutex_unlock(&vgargs.mutex);
- pthread_cond_destroy(&vgargs.cond);
- pthread_mutex_destroy(&vgargs.mutex);
-#else
- // Yes, you see it correctly, busy waiting ... The problem is that
- // POSIX threads functions cannot be called here -- the functions defined
- // in this file (drd_intercepts.c) would be called instead of those in
- // libpthread.so. This loop is necessary because vgargs is allocated on the
- // stack, and the created thread reads it.
- if (ret == 0)
- {
- while (! vgargs.wrapper_started)
- {
- sched_yield();
- }
- }
-#endif
+
+ /* Free the memory 'vgargs' points at if pthread_create() failed. */
+ if (ret != 0)
+ free(vgargs);
+
return ret;
}
@@ -346,7 +344,7 @@
CALL_FN_W_W(ret, fn, pt_thread);
if (ret == 0)
{
- vg_set_joinable(pt_thread, 0);
+ DRD_(set_joinable)(pt_thread, 0);
}
}
return ret;
@@ -381,7 +379,8 @@
if (attr)
pthread_mutexattr_gettype(attr, &mt);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_MUTEX_INIT,
- mutex, pthread_to_drd_mutex_type(mt), 0, 0, 0);
+ mutex, DRD_(pthread_to_drd_mutex_type)(mt),
+ 0, 0, 0);
CALL_FN_W_WW(ret, fn, mutex, attr);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_INIT,
mutex, 0, 0, 0, 0);
@@ -400,7 +399,7 @@
mutex, 0, 0, 0, 0);
CALL_FN_W_W(ret, fn, mutex);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_DESTROY,
- mutex, mutex_type(mutex), 0, 0, 0);
+ mutex, DRD_(mutex_type)(mutex), 0, 0, 0);
return ret;
}
@@ -413,7 +412,7 @@
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__PRE_MUTEX_LOCK,
- mutex, mutex_type(mutex), 0, 0, 0);
+ mutex, DRD_(mutex_type)(mutex), 0, 0, 0);
CALL_FN_W_W(ret, fn, mutex);
VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__POST_MUTEX_LOCK,
mutex, ret == 0, 0, 0, 0);
@@ -429,7 +428,7 @@
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__PRE_MUTEX_LOCK,
- mutex, mutex_type(mutex), 1, 0, 0);
+ mutex, DRD_(mutex_type)(mutex), 1, 0, 0);
CALL_FN_W_W(ret, fn, mutex);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_LOCK,
mutex, ret == 0, 0, 0, 0);
@@ -446,7 +445,7 @@
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__PRE_MUTEX_LOCK,
- mutex, mutex_type(mutex), 0, 0, 0);
+ mutex, DRD_(mutex_type)(mutex), 0, 0, 0);
CALL_FN_W_WW(ret, fn, mutex, abs_timeout);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_LOCK,
mutex, ret == 0, 0, 0, 0);
@@ -463,7 +462,7 @@
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, -1,
VG_USERREQ__PRE_MUTEX_UNLOCK,
- mutex, mutex_type(mutex), 0, 0, 0);
+ mutex, DRD_(mutex_type)(mutex), 0, 0, 0);
CALL_FN_W_W(ret, fn, mutex);
VALGRIND_DO_CLIENT_REQUEST(res, -1,
VG_USERREQ__POST_MUTEX_UNLOCK,
@@ -514,7 +513,7 @@
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_COND_WAIT,
- cond, mutex, mutex_type(mutex), 0, 0);
+ cond, mutex, DRD_(mutex_type)(mutex), 0, 0);
CALL_FN_W_WW(ret, fn, cond, mutex);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_COND_WAIT,
cond, mutex, 1, 0, 0);
@@ -532,7 +531,7 @@
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_COND_WAIT,
- cond, mutex, mutex_type(mutex), 0, 0);
+ cond, mutex, DRD_(mutex_type)(mutex), 0, 0);
CALL_FN_W_WWW(ret, fn, cond, mutex, abstime);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_COND_WAIT,
cond, mutex, 1, 0, 0);
|
|
From: <sv...@va...> - 2009-02-14 13:30:58
|
Author: bart
Date: 2009-02-14 12:14:50 +0000 (Sat, 14 Feb 2009)
New Revision: 9150
Log:
Added DRD_(spinlock_init_or_unlock)().
Modified:
trunk/drd/drd_mutex.c
trunk/drd/drd_mutex.h
Modified: trunk/drd/drd_mutex.c
===================================================================
--- trunk/drd/drd_mutex.c 2009-02-14 12:12:57 UTC (rev 9149)
+++ trunk/drd/drd_mutex.c 2009-02-14 12:14:50 UTC (rev 9150)
@@ -1,8 +1,7 @@
/*
This file is part of drd, a data race detector.
- Copyright (C) 2006-2008 Bart Van Assche
- bar...@gm...
+ Copyright (C) 2006-2009 Bart Van Assche <bar...@gm...>.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -23,6 +22,7 @@
*/
+#include "drd_basics.h"
#include "drd_clientobj.h"
#include "drd_error.h"
#include "drd_mutex.h"
@@ -425,6 +425,19 @@
}
}
+void DRD_(spinlock_init_or_unlock)(const Addr spinlock)
+{
+ struct mutex_info* mutex_p = mutex_get(spinlock);
+ if (mutex_p)
+ {
+ mutex_unlock(spinlock, mutex_type_spinlock);
+ }
+ else
+ {
+ mutex_init(spinlock, mutex_type_spinlock);
+ }
+}
+
const char* mutex_get_typename(struct mutex_info* const p)
{
tl_assert(p);
Modified: trunk/drd/drd_mutex.h
===================================================================
--- trunk/drd/drd_mutex.h 2009-02-14 12:12:57 UTC (rev 9149)
+++ trunk/drd/drd_mutex.h 2009-02-14 12:14:50 UTC (rev 9150)
@@ -48,6 +48,7 @@
void mutex_post_lock(const Addr mutex, const Bool took_lock,
const Bool post_cond_wait);
void mutex_unlock(const Addr mutex, const MutexT mutex_type);
+void DRD_(spinlock_init_or_unlock)(const Addr spinlock);
const char* mutex_get_typename(struct mutex_info* const p);
const char* mutex_type_name(const MutexT mt);
Bool mutex_is_locked_by(const Addr mutex, const DrdThreadId tid);
|
|
From: <sv...@va...> - 2009-02-14 13:10:58
|
Author: bart
Date: 2009-02-14 11:54:42 +0000 (Sat, 14 Feb 2009)
New Revision: 9148
Log:
Renamed vg_thread_wrapper() into DRD_(thread_wrapper)().
Modified:
trunk/drd/drd_pthread_intercepts.c
trunk/drd/tests/atomic_var.stderr.exp-with-atomic-builtins-1
trunk/drd/tests/atomic_var.stderr.exp-with-atomic-builtins-2
trunk/drd/tests/hg03_inherit.stderr.exp
trunk/drd/tests/hg04_race.stderr.exp
trunk/drd/tests/hg05_race2.stderr.exp
trunk/drd/tests/hg05_race2.stderr.exp-powerpc
trunk/drd/tests/pth_cond_race.stderr.exp
trunk/drd/tests/pth_create_chain.stderr.exp-ppc
trunk/drd/tests/pth_inconsistent_cond_wait.stderr.exp1
trunk/drd/tests/pth_inconsistent_cond_wait.stderr.exp2
trunk/drd/tests/rwlock_race.stderr.exp
trunk/drd/tests/rwlock_race.stderr.exp2
trunk/drd/tests/tc09_bad_unlock.stderr.exp
trunk/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8
trunk/drd/tests/tc22_exit_w_lock.stderr.exp-64bit
trunk/drd/tests/tc23_bogus_condwait.stderr.exp
Modified: trunk/drd/drd_pthread_intercepts.c
===================================================================
--- trunk/drd/drd_pthread_intercepts.c 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/drd_pthread_intercepts.c 2009-02-14 11:54:42 UTC (rev 9148)
@@ -54,6 +54,7 @@
#include <stdlib.h>
#include <unistd.h> // confstr()
#include "config.h"
+#include "drd_basics.h"
#include "drd_clientreq.h"
#include "pub_tool_redir.h"
@@ -166,7 +167,7 @@
tid, joinable, 0, 0, 0);
}
-static void* vg_thread_wrapper(void* arg)
+static void* DRD_(thread_wrapper)(void* arg)
{
int res;
@@ -292,7 +293,7 @@
/* 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, vg_thread_wrapper, &vgargs);
+ CALL_FN_W_WWWW(ret, fn, thread, attr, DRD_(thread_wrapper), &vgargs);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__DRD_START_RECORDING,
0, 0, 0, 0, 0);
#if 0
Modified: trunk/drd/tests/atomic_var.stderr.exp-with-atomic-builtins-1
===================================================================
--- trunk/drd/tests/atomic_var.stderr.exp-with-atomic-builtins-1 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/atomic_var.stderr.exp-with-atomic-builtins-1 2009-02-14 11:54:42 UTC (rev 9148)
@@ -3,7 +3,7 @@
Thread 2:
Conflicting load by thread 2/3 at 0x........ size 4
at 0x........: thread_func_2 (atomic_var.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside local var "s_y"
Modified: trunk/drd/tests/atomic_var.stderr.exp-with-atomic-builtins-2
===================================================================
--- trunk/drd/tests/atomic_var.stderr.exp-with-atomic-builtins-2 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/atomic_var.stderr.exp-with-atomic-builtins-2 2009-02-14 11:54:42 UTC (rev 9148)
@@ -3,7 +3,7 @@
Thread 3:
Conflicting load by thread 3/3 at 0x........ size 4
at 0x........: thread_func_2 (atomic_var.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside local var "s_y"
Modified: trunk/drd/tests/hg03_inherit.stderr.exp
===================================================================
--- trunk/drd/tests/hg03_inherit.stderr.exp 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/hg03_inherit.stderr.exp 2009-02-14 11:54:42 UTC (rev 9148)
@@ -2,7 +2,7 @@
Thread 3:
Conflicting store by thread 3/3 at 0x........ size 4
at 0x........: t2 (hg03_inherit.c:28)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside shared[1],
@@ -10,7 +10,7 @@
Conflicting store by thread 3/3 at 0x........ size 4
at 0x........: t2 (hg03_inherit.c:29)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside shared[1],
Modified: trunk/drd/tests/hg04_race.stderr.exp
===================================================================
--- trunk/drd/tests/hg04_race.stderr.exp 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/hg04_race.stderr.exp 2009-02-14 11:54:42 UTC (rev 9148)
@@ -2,7 +2,7 @@
Thread 2:
Conflicting load by thread 2/3 at 0x........ size 4
at 0x........: th (hg04_race.c:10)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside local var "shared"
@@ -14,7 +14,7 @@
Conflicting store by thread 2/3 at 0x........ size 4
at 0x........: th (hg04_race.c:10)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside local var "shared"
Modified: trunk/drd/tests/hg05_race2.stderr.exp
===================================================================
--- trunk/drd/tests/hg05_race2.stderr.exp 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/hg05_race2.stderr.exp 2009-02-14 11:54:42 UTC (rev 9148)
@@ -2,7 +2,7 @@
Thread 2:
Conflicting load by thread 2/3 at 0x........ size 4
at 0x........: th (hg05_race2.c:17)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside foo.poot[5].plop[11],
@@ -14,7 +14,7 @@
Conflicting store by thread 2/3 at 0x........ size 4
at 0x........: th (hg05_race2.c:17)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside foo.poot[5].plop[11],
Modified: trunk/drd/tests/hg05_race2.stderr.exp-powerpc
===================================================================
--- trunk/drd/tests/hg05_race2.stderr.exp-powerpc 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/hg05_race2.stderr.exp-powerpc 2009-02-14 11:54:42 UTC (rev 9148)
@@ -2,7 +2,7 @@
Thread 2:
Conflicting load by thread 2/3 at 0x........ size 4
at 0x........: th (hg05_race2.c:17)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Allocation context: unknown.
@@ -13,7 +13,7 @@
Conflicting store by thread 2/3 at 0x........ size 4
at 0x........: th (hg05_race2.c:17)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Allocation context: unknown.
Modified: trunk/drd/tests/pth_cond_race.stderr.exp
===================================================================
--- trunk/drd/tests/pth_cond_race.stderr.exp 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/pth_cond_race.stderr.exp 2009-02-14 11:54:42 UTC (rev 9148)
@@ -3,7 +3,7 @@
Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread.
at 0x........: pthread_cond_signal* (drd_pthread_intercepts.c:?)
by 0x........: thread_func (pth_cond_race.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
cond 0x........ was first observed at:
Modified: trunk/drd/tests/pth_create_chain.stderr.exp-ppc
===================================================================
--- trunk/drd/tests/pth_create_chain.stderr.exp-ppc 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/pth_create_chain.stderr.exp-ppc 2009-02-14 11:54:42 UTC (rev 9148)
@@ -2,7 +2,7 @@
Emulation fatal error -- Valgrind cannot continue:
PPC64 function redirection stack overflow
at 0x........: ???
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Modified: trunk/drd/tests/pth_inconsistent_cond_wait.stderr.exp1
===================================================================
--- trunk/drd/tests/pth_inconsistent_cond_wait.stderr.exp1 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/pth_inconsistent_cond_wait.stderr.exp1 2009-02-14 11:54:42 UTC (rev 9148)
@@ -3,7 +3,7 @@
Inconsistent association of condition variable and mutex: condition variable 0x........, mutexes 0x........ and 0x........
at 0x........: pthread_cond_wait* (drd_pthread_intercepts.c:?)
by 0x........: thread2 (pth_inconsistent_cond_wait.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
cond 0x........ was first observed at:
Modified: trunk/drd/tests/pth_inconsistent_cond_wait.stderr.exp2
===================================================================
--- trunk/drd/tests/pth_inconsistent_cond_wait.stderr.exp2 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/pth_inconsistent_cond_wait.stderr.exp2 2009-02-14 11:54:42 UTC (rev 9148)
@@ -3,7 +3,7 @@
Inconsistent association of condition variable and mutex: condition variable 0x........, mutexes 0x........ and 0x........
at 0x........: pthread_cond_wait* (drd_pthread_intercepts.c:?)
by 0x........: thread1 (pth_inconsistent_cond_wait.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
cond 0x........ was first observed at:
Modified: trunk/drd/tests/rwlock_race.stderr.exp
===================================================================
--- trunk/drd/tests/rwlock_race.stderr.exp 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/rwlock_race.stderr.exp 2009-02-14 11:54:42 UTC (rev 9148)
@@ -2,7 +2,7 @@
Thread 3:
Conflicting load by thread 3/3 at 0x........ size 4
at 0x........: thread_func (rwlock_race.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside local var "s_racy"
@@ -10,19 +10,19 @@
Other segment start (thread 2/2)
at 0x........: pthread_rwlock_rdlock* (drd_pthread_intercepts.c:?)
by 0x........: thread_func (rwlock_race.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Other segment end (thread 2/2)
at 0x........: pthread_rwlock_unlock* (drd_pthread_intercepts.c:?)
by 0x........: thread_func (rwlock_race.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Conflicting store by thread 3/3 at 0x........ size 4
at 0x........: thread_func (rwlock_race.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside local var "s_racy"
@@ -30,13 +30,13 @@
Other segment start (thread 2/2)
at 0x........: pthread_rwlock_rdlock* (drd_pthread_intercepts.c:?)
by 0x........: thread_func (rwlock_race.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Other segment end (thread 2/2)
at 0x........: pthread_rwlock_unlock* (drd_pthread_intercepts.c:?)
by 0x........: thread_func (rwlock_race.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Result: 2
Modified: trunk/drd/tests/rwlock_race.stderr.exp2
===================================================================
--- trunk/drd/tests/rwlock_race.stderr.exp2 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/rwlock_race.stderr.exp2 2009-02-14 11:54:42 UTC (rev 9148)
@@ -2,7 +2,7 @@
Thread 3:
Conflicting load by thread 3/3 at 0x........ size 4
at 0x........: thread (rwlock_race.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside local var "s_racy"
@@ -14,7 +14,7 @@
Conflicting store by thread 3/3 at 0x........ size 4
at 0x........: thread (rwlock_race.c:?)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Location 0x........ is 0 bytes inside local var "s_racy"
Modified: trunk/drd/tests/tc09_bad_unlock.stderr.exp
===================================================================
--- trunk/drd/tests/tc09_bad_unlock.stderr.exp 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/tc09_bad_unlock.stderr.exp 2009-02-14 11:54:42 UTC (rev 9148)
@@ -12,7 +12,7 @@
Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1.
at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
by 0x........: child_fn (tc09_bad_unlock.c:11)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
mutex 0x........ was first observed at:
@@ -44,7 +44,7 @@
Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1.
at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
by 0x........: child_fn (tc09_bad_unlock.c:11)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
mutex 0x........ was first observed at:
Modified: trunk/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8
===================================================================
--- trunk/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/tc09_bad_unlock.stderr.exp-glibc2.8 2009-02-14 11:54:42 UTC (rev 9148)
@@ -12,7 +12,7 @@
Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1.
at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
by 0x........: child_fn (tc09_bad_unlock.c:11)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
mutex 0x........ was first observed at:
@@ -44,7 +44,7 @@
Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1.
at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
by 0x........: child_fn (tc09_bad_unlock.c:11)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
mutex 0x........ was first observed at:
Modified: trunk/drd/tests/tc22_exit_w_lock.stderr.exp-64bit
===================================================================
--- trunk/drd/tests/tc22_exit_w_lock.stderr.exp-64bit 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/tc22_exit_w_lock.stderr.exp-64bit 2009-02-14 11:54:42 UTC (rev 9148)
@@ -5,7 +5,7 @@
mutex 0x........ was first observed at:
at 0x........: pthread_mutex_lock (drd_pthread_intercepts.c:?)
by 0x........: child_fn1 (tc22_exit_w_lock.c:18)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
Modified: trunk/drd/tests/tc23_bogus_condwait.stderr.exp
===================================================================
--- trunk/drd/tests/tc23_bogus_condwait.stderr.exp 2009-02-14 10:58:45 UTC (rev 9147)
+++ trunk/drd/tests/tc23_bogus_condwait.stderr.exp 2009-02-14 11:54:42 UTC (rev 9148)
@@ -11,7 +11,7 @@
Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread.
at 0x........: pthread_cond_signal* (drd_pthread_intercepts.c:?)
by 0x........: rescue_me (tc23_bogus_condwait.c:20)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
cond 0x........ was first observed at:
@@ -30,7 +30,7 @@
Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread.
at 0x........: pthread_cond_signal* (drd_pthread_intercepts.c:?)
by 0x........: rescue_me (tc23_bogus_condwait.c:24)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
cond 0x........ was first observed at:
@@ -59,7 +59,7 @@
Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread.
at 0x........: pthread_cond_signal* (drd_pthread_intercepts.c:?)
by 0x........: rescue_me (tc23_bogus_condwait.c:28)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
cond 0x........ was first observed at:
@@ -81,7 +81,7 @@
Probably a race condition: condition variable 0x........ has been signaled but the associated mutex 0x........ is not locked by the signalling thread.
at 0x........: pthread_cond_signal* (drd_pthread_intercepts.c:?)
by 0x........: rescue_me (tc23_bogus_condwait.c:32)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
cond 0x........ was first observed at:
@@ -96,7 +96,7 @@
Mutex not locked by calling thread: mutex 0x........, recursion count 2, owner 1.
at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
by 0x........: grab_the_lock (tc23_bogus_condwait.c:42)
- by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?)
+ by 0x........: vgDrd_thread_wrapper (drd_pthread_intercepts.c:?)
by 0x........: (within libpthread-?.?.so)
by 0x........: clone (in /...libc...)
mutex 0x........ was first observed at:
|
|
From: <sv...@va...> - 2009-02-14 10:58:50
|
Author: bart
Date: 2009-02-14 10:58:45 +0000 (Sat, 14 Feb 2009)
New Revision: 9147
Log:
Updated copyright statement.
Modified:
trunk/drd/drd.h
Modified: trunk/drd/drd.h
===================================================================
--- trunk/drd/drd.h 2009-02-14 10:14:09 UTC (rev 9146)
+++ trunk/drd/drd.h 2009-02-14 10:58:45 UTC (rev 9147)
@@ -13,7 +13,8 @@
This file is part of drd, a Valgrind tool for verification of
multithreaded programs.
- Copyright (C) 2006-2008 Bart Van Assche. All rights reserved.
+ Copyright (C) 2006-2009 Bart Van Assche <bar...@gm...>.
+ All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
|
|
From: <sv...@va...> - 2009-02-14 10:14:15
|
Author: bart Date: 2009-02-14 10:14:09 +0000 (Sat, 14 Feb 2009) New Revision: 9146 Log: Added file to repository. Added: trunk/drd/drd_basics.h Added: trunk/drd/drd_basics.h =================================================================== --- trunk/drd/drd_basics.h (rev 0) +++ trunk/drd/drd_basics.h 2009-02-14 10:14:09 UTC (rev 9146) @@ -0,0 +1,38 @@ +/* + This file is part of DRD, a data race detector. + + Copyright (C) 2009 Bart Van Assche <bar...@gm...>. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307, USA. + + The GNU General Public License is contained in the file COPYING. +*/ + + +/* Basic definitions needed by (almost) all DRD source files. */ + + +#ifndef __DRD_BASICS_H +#define __DRD_BASICS_H + + +#include "pub_tool_basics.h" // Addr + + +#define DRD_(str) VGAPPEND(vgDrd_, str) + + +#endif /* __DRD_BASICS_H */ |
|
From: Tom H. <th...@cy...> - 2009-02-14 03:47:30
|
Nightly build on vauxhall ( x86_64, Fedora 10 ) started at 2009-02-14 03:20:05 GMT Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 486 tests, 1 stderr failure, 0 stdout failures, 0 post failures == memcheck/tests/x86-linux/scalar (stderr) |
|
From: Tom H. <th...@cy...> - 2009-02-14 03:43:55
|
Nightly build on lloyd ( x86_64, Fedora 7 ) started at 2009-02-14 03:05:04 GMT Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 477 tests, 6 stderr failures, 0 stdout failures, 0 post failures == exp-ptrcheck/tests/ccc (stderr) exp-ptrcheck/tests/preen_invars (stderr) exp-ptrcheck/tests/pth_create (stderr) exp-ptrcheck/tests/pth_specific (stderr) helgrind/tests/tc20_verifywrap (stderr) memcheck/tests/x86-linux/scalar (stderr) |
|
From: Tom H. <th...@cy...> - 2009-02-14 03:32:00
|
Nightly build on mg ( x86_64, Fedora 9 ) started at 2009-02-14 03:10:05 GMT Results differ from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 483 tests, 5 stderr failures, 2 stdout failures, 0 post failures == exp-ptrcheck/tests/ccc (stderr) exp-ptrcheck/tests/preen_invars (stderr) exp-ptrcheck/tests/pth_create (stderr) exp-ptrcheck/tests/pth_specific (stderr) memcheck/tests/linux/timerfd-syscall (stdout) memcheck/tests/x86-linux/scalar (stderr) none/tests/linux/mremap2 (stdout) ================================================= == Results from 24 hours ago == ================================================= Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 483 tests, 5 stderr failures, 2 stdout failures, 0 post failures == exp-ptrcheck/tests/ccc (stderr) exp-ptrcheck/tests/preen_invars (stderr) exp-ptrcheck/tests/pth_create (stderr) exp-ptrcheck/tests/pth_specific (stderr) memcheck/tests/linux/timerfd-syscall (stdout) memcheck/tests/x86-linux/scalar (stderr) none/tests/mremap2 (stdout) ================================================= == Difference between 24 hours ago and now == ================================================= *** old.short Sat Feb 14 03:21:01 2009 --- new.short Sat Feb 14 03:31:52 2009 *************** *** 15,17 **** memcheck/tests/x86-linux/scalar (stderr) ! none/tests/mremap2 (stdout) --- 15,17 ---- memcheck/tests/x86-linux/scalar (stderr) ! none/tests/linux/mremap2 (stdout) |