Minor cleanup (no functional change): rename 'struct _Thr :: opaque'
to 'hgthread', since that's what it is really.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11619 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/helgrind/hg_errors.c b/helgrind/hg_errors.c
index 6bc9482..6076f47 100644
--- a/helgrind/hg_errors.c
+++ b/helgrind/hg_errors.c
@@ -341,7 +341,7 @@
Thread* threadp;
tl_assert(wherep);
tl_assert(thrp);
- threadp = libhb_get_Thr_opaque( thrp );
+ threadp = libhb_get_Thr_hgthread( thrp );
tl_assert(threadp);
xe->XE.Race.h2_ct_accEC = wherep;
xe->XE.Race.h2_ct = threadp;
diff --git a/helgrind/hg_lock_n_thread.h b/helgrind/hg_lock_n_thread.h
index 78948fe..e109b55 100644
--- a/helgrind/hg_lock_n_thread.h
+++ b/helgrind/hg_lock_n_thread.h
@@ -83,8 +83,8 @@
/* ADMIN */
struct _Thread* admin;
UInt magic;
- Thr* hbthr;
- ThreadId coretid;
+ Thr* hbthr; /* which in turn points back here .. */
+ ThreadId coretid; /* .. via its hgthread field */
/* USEFUL */
WordSetID locksetA; /* WordSet of Lock* currently held by thread */
WordSetID locksetW; /* subset of locksetA held in w-mode */
diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c
index e2e4a98..1b17f6f 100644
--- a/helgrind/hg_main.c
+++ b/helgrind/hg_main.c
@@ -590,8 +590,8 @@
thr = mk_Thread(hbthr_root);
thr->coretid = 1; /* FIXME: hardwires an assumption about the
identity of the root thread. */
- tl_assert( libhb_get_Thr_opaque(hbthr_root) == NULL );
- libhb_set_Thr_opaque(hbthr_root, thr);
+ tl_assert( libhb_get_Thr_hgthread(hbthr_root) == NULL );
+ libhb_set_Thr_hgthread(hbthr_root, thr);
/* and bind it in the thread-map table. */
tl_assert(HG_(is_sane_ThreadId)(thr->coretid));
@@ -1620,15 +1620,15 @@
hbthr_p = thr_p->hbthr;
tl_assert(hbthr_p != NULL);
- tl_assert( libhb_get_Thr_opaque(hbthr_p) == thr_p );
+ tl_assert( libhb_get_Thr_hgthread(hbthr_p) == thr_p );
hbthr_c = libhb_create ( hbthr_p );
/* Create a new thread record for the child. */
/* a Thread for the new thread ... */
thr_c = mk_Thread( hbthr_c );
- tl_assert( libhb_get_Thr_opaque(hbthr_c) == NULL );
- libhb_set_Thr_opaque(hbthr_c, thr_c);
+ tl_assert( libhb_get_Thr_hgthread(hbthr_c) == NULL );
+ libhb_set_Thr_hgthread(hbthr_c, thr_c);
/* and bind it in the thread-map table */
map_threads[child] = thr_c;
@@ -1765,8 +1765,8 @@
hbthr_s = thr_s->hbthr;
hbthr_q = thr_q->hbthr;
tl_assert(hbthr_s != hbthr_q);
- tl_assert( libhb_get_Thr_opaque(hbthr_s) == thr_s );
- tl_assert( libhb_get_Thr_opaque(hbthr_q) == thr_q );
+ tl_assert( libhb_get_Thr_hgthread(hbthr_s) == thr_s );
+ tl_assert( libhb_get_Thr_hgthread(hbthr_q) == thr_q );
/* Allocate a temporary synchronisation object and use it to send
an imaginary message from the quitter to the stayer, the purpose
@@ -4838,7 +4838,7 @@
ThreadId tid;
UWord nActual;
tl_assert(hbt);
- thr = libhb_get_Thr_opaque( hbt );
+ thr = libhb_get_Thr_hgthread( hbt );
tl_assert(thr);
tid = map_threads_maybe_reverse_lookup_SLOW(thr);
nActual = (UWord)VG_(get_StackTrace)( tid, frames, (UInt)nRequest,
@@ -4855,7 +4855,7 @@
ThreadId tid;
ExeContext* ec;
tl_assert(hbt);
- thr = libhb_get_Thr_opaque( hbt );
+ thr = libhb_get_Thr_hgthread( hbt );
tl_assert(thr);
tid = map_threads_maybe_reverse_lookup_SLOW(thr);
/* this will assert if tid is invalid */
diff --git a/helgrind/libhb.h b/helgrind/libhb.h
index 8d88de6..39711b5 100644
--- a/helgrind/libhb.h
+++ b/helgrind/libhb.h
@@ -129,10 +129,10 @@
void libhb_srange_noaccess ( Thr*, Addr, SizeT ); /* IS IGNORED */
void libhb_srange_untrack ( Thr*, Addr, SizeT );
-/* For the convenience of callers, we offer to store one void* item in
- a Thr, which we ignore, but the caller can get or set any time. */
-void* libhb_get_Thr_opaque ( Thr* );
-void libhb_set_Thr_opaque ( Thr*, void* );
+/* Get and set the hgthread (pointer to corresponding Thread
+ structure). */
+void* libhb_get_Thr_hgthread ( Thr* );
+void libhb_set_Thr_hgthread ( Thr*, void* );
/* Low level copy of shadow state from [src,src+len) to [dst,dst+len).
Overlapping moves are checked for and asserted against. */
diff --git a/helgrind/libhb_core.c b/helgrind/libhb_core.c
index 2e878eb..05fda56 100644
--- a/helgrind/libhb_core.c
+++ b/helgrind/libhb_core.c
@@ -3060,8 +3060,11 @@
race. */
Filter* filter;
- /* opaque (to us) data we hold on behalf of the library's user. */
- void* opaque;
+ /* A pointer back to the top level Thread structure. There is a
+ 1-1 mapping between Thread and Thr structures -- each Thr points
+ at its corresponding Thread, and vice versa. Really, Thr and
+ Thread should be merged into a single structure. */
+ Thread* hgthread;
/* The ULongs (scalar Kws) in this accumulate in strictly
increasing order, without duplicates. This is important because
@@ -4359,7 +4362,8 @@
Thread* hist1_conf_thr = NULL;
tl_assert(acc_thr);
- tl_assert(acc_thr->opaque);
+ tl_assert(acc_thr->hgthread);
+ tl_assert(acc_thr->hgthread->hbthr == acc_thr);
tl_assert(HG_(clo_history_level) >= 0 && HG_(clo_history_level) <= 2);
if (HG_(clo_history_level) == 1) {
@@ -4443,11 +4447,11 @@
// seg_start could be NULL iff this is the first stack in the thread
//if (seg_start) VG_(pp_ExeContext)(seg_start);
//if (seg_end) VG_(pp_ExeContext)(seg_end);
- hist1_conf_thr = confThr->opaque;
+ hist1_conf_thr = confThr->hgthread;
}
}
- HG_(record_error_Race)( acc_thr->opaque, acc_addr,
+ HG_(record_error_Race)( acc_thr->hgthread, acc_addr,
szB, isWrite,
hist1_conf_thr, hist1_seg_start, hist1_seg_end );
}
@@ -5976,14 +5980,14 @@
if (0 && TRACEME(a,szB)) trace(thr,a,szB,"untrack-after ");
}
-void* libhb_get_Thr_opaque ( Thr* thr ) {
+void* libhb_get_Thr_hgthread ( Thr* thr ) {
tl_assert(thr);
- return thr->opaque;
+ return thr->hgthread;
}
-void libhb_set_Thr_opaque ( Thr* thr, void* v ) {
+void libhb_set_Thr_hgthread ( Thr* thr, void* v ) {
tl_assert(thr);
- thr->opaque = v;
+ thr->hgthread = v;
}
void libhb_copy_shadow_state ( Thr* thr, Addr src, Addr dst, SizeT len )