From: Bart Van Assche Date: Tue, 26 Feb 2008 19:13:04 +0000 (+0000) Subject: Cleaned up generation of "Not a mutex" error messages. X-Git-Tag: svn/VALGRIND_3_4_0~1022 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd8ef39ca834992d068b66c400b014682d2b604c;p=thirdparty%2Fvalgrind.git Cleaned up generation of "Not a mutex" error messages. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7483 --- diff --git a/exp-drd/drd_error.c b/exp-drd/drd_error.c index e38e6c4df1..bc76f5a180 100644 --- a/exp-drd/drd_error.c +++ b/exp-drd/drd_error.c @@ -259,12 +259,13 @@ static void drd_tool_error_pp(Error* const e) } case MutexErr: { MutexErrInfo* p = (MutexErrInfo*)(VG_(get_error_extra)(e)); + tl_assert(p); VG_(message)(Vg_UserMsg, "%s / mutex 0x%lx (recursion count %d, owner %d)", VG_(get_error_string)(e), - p ? p->mutex : 0, - p ? p->recursion_count : 0, - p ? p->owner : DRD_INVALID_THREADID); + p->mutex, + p->recursion_count, + p->owner); VG_(pp_ExeContext)(VG_(get_error_where)(e)); break; } @@ -287,6 +288,12 @@ static void drd_tool_error_pp(Error* const e) VG_(pp_ExeContext)(VG_(get_error_where)(e)); break; } + case GenericErr: { + //GenericErrInfo* gei =(GenericErrInfo*)(VG_(get_error_extra)(e)); + VG_(message)(Vg_UserMsg, "%s", VG_(get_error_string)(e)); + VG_(pp_ExeContext)(VG_(get_error_where)(e)); + break; + } default: VG_(message)(Vg_UserMsg, "%s", @@ -308,6 +315,8 @@ static UInt drd_tool_error_update_extra(Error* e) return sizeof(CondRaceErrInfo); case CondErr: return sizeof(CondErrInfo); + case GenericErr: + return sizeof(GenericErrInfo); default: tl_assert(False); break; diff --git a/exp-drd/drd_error.h b/exp-drd/drd_error.h index 81e7932dd4..e9a54c48b3 100644 --- a/exp-drd/drd_error.h +++ b/exp-drd/drd_error.h @@ -40,7 +40,8 @@ typedef enum { DataRaceErr = 1, MutexErr = 2, CondRaceErr = 3, - CondErr = 4, + CondErr = 4, + GenericErr = 5, } DrdErrorKind; /* The classification of a faulting address. */ @@ -94,6 +95,9 @@ typedef struct { Addr cond; } CondErrInfo; +typedef struct { +} GenericErrInfo; + void describe_addr(Addr const a, SizeT const len, AddrInfo* const ai); Char* describe_addr_text(Addr const a, SizeT const len, AddrInfo* const ai, Char* const buf, UInt const n_buf); diff --git a/exp-drd/drd_mutex.c b/exp-drd/drd_mutex.c index 355c66ba6b..4fcf34e984 100644 --- a/exp-drd/drd_mutex.c +++ b/exp-drd/drd_mutex.c @@ -112,12 +112,12 @@ mutex_get_or_allocate(const Addr mutex, { if (drd_is_any_suppressed(mutex, mutex + size)) { - MutexErrInfo MEI = { 0, 0, 0 }; + GenericErrInfo GEI; VG_(maybe_record_error)(VG_(get_running_tid)(), - MutexErr, + GenericErr, VG_(get_IP)(VG_(get_running_tid)()), "Not a mutex", - &MEI); + &GEI); return 0; } mutex_initialize(&s_mutex[i], mutex, size, mutex_type); @@ -246,12 +246,12 @@ int mutex_lock(const Addr mutex, const SizeT size, MutexT mutex_type) if (p == 0) { - MutexErrInfo MEI = { 0, 0, 0 }; + GenericErrInfo GEI; VG_(maybe_record_error)(VG_(get_running_tid)(), - MutexErr, + GenericErr, VG_(get_IP)(VG_(get_running_tid)()), "Not a mutex", - &MEI); + &GEI); return 0; } @@ -323,12 +323,12 @@ int mutex_unlock(const Addr mutex, const MutexT mutex_type) if (p == 0 || p->owner == DRD_INVALID_THREADID) { - MutexErrInfo MEI = { 0, 0, 0 }; + GenericErrInfo GEI; VG_(maybe_record_error)(vg_tid, - MutexErr, + GenericErr, VG_(get_IP)(vg_tid), "Not a mutex", - &MEI); + &GEI); return 0; } diff --git a/exp-drd/tests/tc06_two_races.stderr.exp2 b/exp-drd/tests/tc06_two_races.stderr.exp2 new file mode 100644 index 0000000000..4cbed89c1a --- /dev/null +++ b/exp-drd/tests/tc06_two_races.stderr.exp2 @@ -0,0 +1 @@ +ERROR SUMMARY: 4 errors from 4 contexts diff --git a/exp-drd/tests/tc07_hbl1.vgtest b/exp-drd/tests/tc07_hbl1.vgtest deleted file mode 100644 index 71c463f810..0000000000 --- a/exp-drd/tests/tc07_hbl1.vgtest +++ /dev/null @@ -1 +0,0 @@ -prog: tc07_hbl1 diff --git a/exp-drd/tests/tc08_hbl2.vgtest b/exp-drd/tests/tc08_hbl2.vgtest deleted file mode 100644 index 665fea8668..0000000000 --- a/exp-drd/tests/tc08_hbl2.vgtest +++ /dev/null @@ -1,2 +0,0 @@ -prog: tc08_hbl2 -stderr_filter: filter_error_summary diff --git a/exp-drd/tests/tc09_bad_unlock.stderr.exp b/exp-drd/tests/tc09_bad_unlock.stderr.exp index b3bc83ab8d..a631ae6396 100644 --- a/exp-drd/tests/tc09_bad_unlock.stderr.exp +++ b/exp-drd/tests/tc09_bad_unlock.stderr.exp @@ -13,7 +13,7 @@ Mutex not unlocked by owner thread / mutex 0x........ (recursion count 1, owner by 0x........: clone (in /...libc...) Thread 1: -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_mutex_unlock (drd_intercepts.c:?) by 0x........: nearly_main (tc09_bad_unlock.c:41) by 0x........: main (tc09_bad_unlock.c:49) @@ -32,7 +32,7 @@ Mutex not unlocked by owner thread / mutex 0x........ (recursion count 1, owner by 0x........: clone (in /...libc...) Thread 1: -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_mutex_unlock (drd_intercepts.c:?) by 0x........: nearly_main (tc09_bad_unlock.c:41) by 0x........: main (tc09_bad_unlock.c:50) diff --git a/exp-drd/tests/tc20_verifywrap.stderr.exp b/exp-drd/tests/tc20_verifywrap.stderr.exp index 504ce2648b..10c23dbdfb 100644 --- a/exp-drd/tests/tc20_verifywrap.stderr.exp +++ b/exp-drd/tests/tc20_verifywrap.stderr.exp @@ -20,14 +20,14 @@ Destroying locked mutex / mutex 0x........ (recursion count 1, owner 1) at 0x........: pthread_mutex_destroy (drd_intercepts.c:?) by 0x........: main (tc20_verifywrap.c:102) -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_mutex_unlock (drd_intercepts.c:?) by 0x........: main (tc20_verifywrap.c:125) ---------------- pthread_cond_wait et al ---------------- -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_cond_wait* (drd_intercepts.c:?) by 0x........: main (tc20_verifywrap.c:147) diff --git a/exp-drd/tests/tc20_verifywrap.stderr.exp2 b/exp-drd/tests/tc20_verifywrap.stderr.exp2 index 2ad249863d..73b095eeef 100644 --- a/exp-drd/tests/tc20_verifywrap.stderr.exp2 +++ b/exp-drd/tests/tc20_verifywrap.stderr.exp2 @@ -20,14 +20,14 @@ Destroying locked mutex / mutex 0x........ (recursion count 1, owner 1) at 0x........: pthread_mutex_destroy (drd_intercepts.c:?) by 0x........: main (tc20_verifywrap.c:102) -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_mutex_unlock (drd_intercepts.c:?) by 0x........: main (tc20_verifywrap.c:125) ---------------- pthread_cond_wait et al ---------------- -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_cond_wait* (drd_intercepts.c:?) by 0x........: main (tc20_verifywrap.c:147) diff --git a/exp-drd/tests/tc23_bogus_condwait.stderr.exp b/exp-drd/tests/tc23_bogus_condwait.stderr.exp index 40ee726aab..ede5af6298 100644 --- a/exp-drd/tests/tc23_bogus_condwait.stderr.exp +++ b/exp-drd/tests/tc23_bogus_condwait.stderr.exp @@ -1,5 +1,5 @@ -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_cond_wait* (drd_intercepts.c:?) by 0x........: main (tc23_bogus_condwait.c:69) @@ -12,15 +12,15 @@ Race condition: condition variable 0x........ has been signalled but the associa by 0x........: clone (in /...libc...) Thread 1: -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_cond_wait* (drd_intercepts.c:?) by 0x........: main (tc23_bogus_condwait.c:69) -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_cond_wait* (drd_intercepts.c:?) by 0x........: main (tc23_bogus_condwait.c:69) -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_cond_wait* (drd_intercepts.c:?) by 0x........: main (tc23_bogus_condwait.c:72) @@ -33,7 +33,7 @@ Race condition: condition variable 0x........ has been signalled but the associa by 0x........: clone (in /...libc...) Thread 1: -Not a mutex / mutex 0x........ (recursion count 0, owner 0) +Not a mutex at 0x........: pthread_cond_wait* (drd_intercepts.c:?) by 0x........: main (tc23_bogus_condwait.c:75)