mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-11 22:08:14 +00:00
- Updated copyright statement: replaced 2006-2007 by 2006-2008. - Added copyright statement in the files where it was missing (drd_track.h and drd_clientreq.c) - Eliminated dependencies on core header files -- there are no more #include "pub_core....h" directives in the exp-drd source code. - Added semaphore support. - Added barrier support. - Added pthread_mutex_timedlock() support. - Stack depth of stack traces printed by exp-drd can now be set via --num-callers=... - Added command-line option --trace-barrier=[yes|no]. - Added regression test for pthread_barrier() (matinv, a program that performs matrix inversion). - Added regression test sem_as_mutex, which tests whether race detection works correctly when a semaphore is used to ensure mutual exclusion of critical sections. - Some of helgrind's regression tests are now used to test both helgrind and exp-drd: tc17_sembar and tc18_semabuse. - Cleaned up bitmap implementation code now that the const keyword has been added to the declarations of the OSet functions. - Cleaned up exp-drd/Makefile.am - Updated exp-drd/TODO.txt git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7346
132 lines
3.5 KiB
C
132 lines
3.5 KiB
C
/*
|
|
This file is part of drd, a data race detector.
|
|
|
|
Copyright (C) 2006-2008 Bart Van Assche
|
|
bart.vanassche@gmail.com
|
|
|
|
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_suppression.h"
|
|
#include "pub_drd_bitmap.h"
|
|
#include "pub_tool_libcassert.h" // tl_assert()
|
|
#include "pub_tool_stacktrace.h" // VG_(get_and_pp_StackTrace)()
|
|
#include "pub_tool_threadstate.h" // VG_(get_running_tid)()
|
|
#include "pub_tool_libcprint.h" // Vg_DebugMsg
|
|
|
|
|
|
// Local variables.
|
|
|
|
static struct bitmap* s_suppressed;
|
|
static Bool s_trace_suppression;
|
|
|
|
|
|
// Function definitions.
|
|
|
|
void suppression_set_trace(const Bool trace_suppression)
|
|
{
|
|
s_trace_suppression = trace_suppression;
|
|
}
|
|
|
|
void drd_suppression_init(void)
|
|
{
|
|
tl_assert(s_suppressed == 0);
|
|
s_suppressed = bm_new();
|
|
tl_assert(s_suppressed);
|
|
}
|
|
|
|
void drd_start_suppression(const Addr a1, const Addr a2,
|
|
const char* const reason)
|
|
{
|
|
if (s_trace_suppression)
|
|
{
|
|
VG_(message)(Vg_DebugMsg, "start suppression of 0x%lx sz %ld (%s)",
|
|
a1, a2 - a1, reason);
|
|
}
|
|
|
|
tl_assert(a1 < a2);
|
|
tl_assert(! drd_is_any_suppressed(a1, a2));
|
|
bm_access_range(s_suppressed, a1, a2 - a1, eStore);
|
|
}
|
|
|
|
void drd_finish_suppression(const Addr a1, const Addr a2)
|
|
{
|
|
if (s_trace_suppression)
|
|
{
|
|
VG_(message)(Vg_DebugMsg, "finish suppression of 0x%lx sz %ld",
|
|
a1, a2 - a1);
|
|
VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(), 12);
|
|
}
|
|
|
|
tl_assert(a1 < a2);
|
|
if (! drd_is_suppressed(a1, a2))
|
|
{
|
|
VG_(message)(Vg_DebugMsg, "?? not suppressed ??");
|
|
VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(), 12);
|
|
tl_assert(False);
|
|
}
|
|
bm_clear(s_suppressed, a1, a2);
|
|
}
|
|
|
|
/**
|
|
* Return true if data race detection suppression has been requested for all
|
|
* 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)
|
|
{
|
|
return bm_has(s_suppressed, a1, a2, eStore);
|
|
}
|
|
|
|
/**
|
|
* Return true if data race detection suppression has been requested for any
|
|
* 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)
|
|
{
|
|
return bm_has_any(s_suppressed, a1, a2, eStore);
|
|
}
|
|
|
|
void drd_suppression_stop_using_mem(const Addr a1, const Addr a2)
|
|
{
|
|
if (s_trace_suppression)
|
|
{
|
|
Addr b;
|
|
for (b = a1; b < a2; b++)
|
|
{
|
|
if (bm_has_1(s_suppressed, b, eStore))
|
|
{
|
|
VG_(message)(Vg_DebugMsg,
|
|
"stop_using_mem(0x%lx, %ld) finish suppression of 0x%lx",
|
|
a1, a2 - a1, b);
|
|
}
|
|
}
|
|
}
|
|
tl_assert(a1);
|
|
tl_assert(a1 < a2);
|
|
bm_clear(s_suppressed, a1, a2);
|
|
}
|
|
|
|
/*
|
|
* Local variables:
|
|
* c-basic-offset: 3
|
|
* End:
|
|
*/
|