diff -u -r ./ORIGINAL/drd/drd_bitmap3.c drd/drd_bitmap3.c --- ./ORIGINAL/drd/drd_bitmap3.c 2006-08-14 15:45:00.000000000 +0100 +++ drd/drd_bitmap3.c 2006-08-26 08:29:19.000000000 +0100 @@ -88,28 +88,9 @@ } /** - * Record an access of type access_type at addresses a .. a + size - 1 in - * bitmap bm. - */ -void bm_access_range(struct bitmap* const bm, - Addr const a, - SizeT const size, - enum bm_access_type access_type) -{ - Addr b; - - tl_assert(bm); - tl_assert(0 < size && size < 4096); - - for (b = a; b != a + size; b++) - { - bm_access_1(bm, b, access_type); - } -} - -/** * Record an access of type access_type at addresses a in bitmap bm. */ +inline void bm_access_1(struct bitmap* bm, Addr a, enum bm_access_type access_type) { @@ -118,8 +99,6 @@ unsigned* p0; SPLIT_ADDRESS(a); - tl_assert(bm); - p2 = &bm->bm2[a2]; if (*p2 == 0) *p2 = bm2_new(); @@ -136,7 +115,32 @@ void bm_access_4(struct bitmap* bm, Addr a, enum bm_access_type access_type) { - bm_access_range(bm, a, 4, access_type); + // bm_access_range(bm, a, 4, access_type); + tl_assert(bm); + bm_access_1(bm, a+0, access_type); + bm_access_1(bm, a+1, access_type); + bm_access_1(bm, a+2, access_type); + bm_access_1(bm, a+3, access_type); +} + +/** + * Record an access of type access_type at addresses a .. a + size - 1 in + * bitmap bm. + */ +void bm_access_range(struct bitmap* const bm, + Addr const a, + SizeT const size, + enum bm_access_type access_type) +{ + Addr b; + + tl_assert(bm); + tl_assert(0 < size && size < 4096); + + for (b = a; b != a + size; b++) + { + bm_access_1(bm, b, access_type); + } } /** Only in drd: drd_bitmap3.c~ diff -u -r ./ORIGINAL/drd/drd_main.c drd/drd_main.c --- ./ORIGINAL/drd/drd_main.c 2006-08-14 16:43:23.000000000 +0100 +++ drd/drd_main.c 2006-08-22 03:08:58.000000000 +0100 @@ -327,20 +327,35 @@ { IRDirty* d = st->Ist.Dirty.details; IREffect const mFx = d->mFx; - if (mFx != Ifx_None) - { - VG_(message)(Vg_UserMsg, - "Encountered Ist_Dirty with effect %s addr %p size %d", - mFx == Ifx_None ? "-" - : mFx == Ifx_Read ? "R" - : mFx == Ifx_Write ? "W" - : mFx == Ifx_Modify ? "RW" - : "?", - d->mAddr, - d->mSize); + 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); + addStmtToIRBB(bb, IRStmt_Dirty(di)); + } + if (mFx == Ifx_Write || mFx == Ifx_Modify) { + di = unsafeIRDirty_0_N( + /*regparms*/2, + "drd_trace_store", + VG_(fnptr_to_fnentry)(drd_trace_store), + argv); + addStmtToIRBB(bb, IRStmt_Dirty(di)); + } + break; + default: + tl_assert(0); } - // To do: implement handling of Ist_Dirty. - tl_assert(mFx == Ifx_None); } addStmtToIRBB(bb, st); break; Only in drd: drd_main.c~ diff -u -r ./ORIGINAL/drd/drd_malloc_wrappers.c drd/drd_malloc_wrappers.c --- ./ORIGINAL/drd/drd_malloc_wrappers.c 2006-08-14 08:07:00.000000000 +0100 +++ drd/drd_malloc_wrappers.c 2006-08-26 08:24:09.000000000 +0100 @@ -68,6 +68,8 @@ /* Allocate its shadow chunk, put it on the appropriate list. */ +/* This allocates in VG_AR_TOOL, since that's what VG_(malloc) + does. Hence the DRD_Chunks live in VG_AR_TOOL. */ static DRD_Chunk* create_DRD_Chunk(ThreadId tid, Addr p, SizeT size) { @@ -95,6 +97,7 @@ cmalloc_n_mallocs ++; // Allocate and zero + // Payload is in VG_AR_CLIENT p = (Addr)VG_(cli_malloc)( align, size ); if (!p) { return NULL; @@ -151,8 +154,13 @@ mc = VG_(HT_remove)(drd_malloc_list, (UWord)p ); if (mc == NULL) { tl_assert(0); + // we get here if the program is freeing stuff it didn't alloc; + // rm this assertion for robustness // drd_record_free_error(tid, p ); } else { + // free the payload, in VG_AR_CLIENT + VG_(cli_free)( (void*)mc->data ); + // mc is in VG_AR_TOOL VG_(free)(mc); } } @@ -190,6 +198,8 @@ mc = VG_(HT_remove)(drd_malloc_list, (UWord)p_old ); if (mc == NULL) { tl_assert(0); + // we get here if the program is freeing stuff it didn't alloc; + // rm this assertion for robustness // drd_record_free_error(tid, (Addr)p_old ); /* We return to the program regardless. */ return NULL; @@ -221,6 +231,7 @@ /* Nb: we have to allocate a new DRD_Chunk for the new memory rather than recycling the old one, so that any erroneous accesses to the old memory are reported. */ + VG_(cli_free)( (void*)mc->data ); VG_(free)(mc); // Allocate a new chunk. Only in drd: drd_malloc_wrappers.c~ diff -u -r ./ORIGINAL/drd/drd_thread.c drd/drd_thread.c --- ./ORIGINAL/drd/drd_thread.c 2006-08-14 15:46:26.000000000 +0100 +++ drd/drd_thread.c 2006-08-25 22:51:53.000000000 +0100 @@ -48,6 +48,25 @@ struct segment* last; } ThreadInfo; +static Bool sane_ThreadInfo ( ThreadInfo* ti ) +{ + Int n_fwd = 0, n_bwd = 0; + struct segment* p; + for (p = ti->first; p; p = p->next) { + if (p->next && p->next->prev != p) + return False; + n_fwd ++; + } + for (p = ti->last; p; p = p->prev) { + if (p->prev && p->prev->next != p) + return False; + n_bwd ++; + } + if (n_fwd != n_bwd) + return False; + return True; +} + // Local variables. @@ -108,11 +127,15 @@ static void thread_append_segment(ThreadId const threadid, struct segment* const sg) { + tl_assert(sane_ThreadInfo( &s_threadinfo[threadid] )); sg->prev = s_threadinfo[threadid].last; sg->next = 0; s_threadinfo[threadid].last = sg; if (s_threadinfo[threadid].first == 0) s_threadinfo[threadid].first = sg; + if (sg->prev != 0) + sg->prev->next = sg; + tl_assert(sane_ThreadInfo( &s_threadinfo[threadid] )); } /** @@ -122,6 +145,7 @@ static void thread_discard_segment(ThreadId const threadid, struct segment* const sg) { + tl_assert(sane_ThreadInfo( &s_threadinfo[threadid] )); if (sg->prev) sg->prev->next = sg->next; if (sg->next) @@ -131,6 +155,7 @@ if (sg == s_threadinfo[threadid].last) s_threadinfo[threadid].last = sg->prev; sg_delete(sg); + tl_assert(sane_ThreadInfo( &s_threadinfo[threadid] )); } struct vectorclock* thread_get_vc(ThreadId const threadid) @@ -232,7 +257,7 @@ sg && (sg_next = sg->next) && vc_lte(&sg->vc, &thread_vc_min); sg = sg_next) { -#if 1 +#if 0 VG_(printf)("Discarding a segment of thread %d: ", i); vc_print(&sg->vc); VG_(printf)("\n");