When reporting an error about an attempt to re-lock an already-locked
lock, also report the stack where the lock was previously locked.
This makes it easier to diagnose deadlocks.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11234 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/helgrind/hg_errors.c b/helgrind/hg_errors.c
index a1ece96..497fe58 100644
--- a/helgrind/hg_errors.c
+++ b/helgrind/hg_errors.c
@@ -222,8 +222,10 @@
ExeContext* after_ec;
} LockOrder;
struct {
- Thread* thr;
- HChar* errstr; /* persistent, in tool-arena */
+ Thread* thr;
+ HChar* errstr; /* persistent, in tool-arena */
+ HChar* auxstr; /* optional, persistent, in tool-arena */
+ ExeContext* auxctx; /* optional */
} Misc;
} XE;
}
@@ -507,7 +509,8 @@
XE_PthAPIerror, 0, NULL, &xe );
}
-void HG_(record_error_Misc) ( Thread* thr, HChar* errstr )
+void HG_(record_error_Misc_w_aux) ( Thread* thr, HChar* errstr,
+ HChar* auxstr, ExeContext* auxctx )
{
XError xe;
tl_assert( HG_(is_sane_Thread)(thr) );
@@ -516,6 +519,8 @@
xe.tag = XE_Misc;
xe.XE.Misc.thr = thr;
xe.XE.Misc.errstr = string_table_strdup(errstr);
+ xe.XE.Misc.auxstr = auxstr ? string_table_strdup(auxstr) : NULL;
+ xe.XE.Misc.auxctx = auxctx;
// FIXME: tid vs thr
tl_assert( HG_(is_sane_ThreadId)(thr->coretid) );
tl_assert( thr->coretid != VG_INVALID_THREADID );
@@ -523,6 +528,11 @@
XE_Misc, 0, NULL, &xe );
}
+void HG_(record_error_Misc) ( Thread* thr, HChar* errstr )
+{
+ HG_(record_error_Misc_w_aux)(thr, errstr, NULL, NULL);
+}
+
Bool HG_(eq_Error) ( VgRes not_used, Error* e1, Error* e2 )
{
XError *xe1, *xe2;
@@ -716,6 +726,11 @@
(Int)xe->XE.Misc.thr->errmsg_index );
emit( " </xwhat>\n" );
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
+ if (xe->XE.Misc.auxstr) {
+ emit(" <auxwhat>%s</auxwhat>\n", xe->XE.Misc.auxstr);
+ if (xe->XE.Misc.auxctx)
+ VG_(pp_ExeContext)( xe->XE.Misc.auxctx );
+ }
} else {
@@ -723,6 +738,11 @@
(Int)xe->XE.Misc.thr->errmsg_index,
xe->XE.Misc.errstr );
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
+ if (xe->XE.Misc.auxstr) {
+ emit(" %s\n", xe->XE.Misc.auxstr);
+ if (xe->XE.Misc.auxctx)
+ VG_(pp_ExeContext)( xe->XE.Misc.auxctx );
+ }
}
break;