public void PlayBack(IEnumerable <Trace> traces) { foreach (var t in traces) { SimThread thread = GetThread(t); SimLock lk = GetLock(t); string frame = t.GetUsefullTopTrace(this.syms); switch (t.record) { case Record.MustNotHoldAny: case Record.MustNotHoldOne: case Record.MustHoldOne: throw new Exception("not supported"); case Record.LockAcquired: thread.Lock(lk, frame); break; case Record.LockReleased: thread.Release(lk, frame); break; default: throw new Exception("Invalid trace record: " + t.record); } } }
public bool IsValid(SimThread thread, SimLock locked) { bool warn; string msg; return(Compare(thread, locked, out warn, out msg)); }
/*locked is already owned by the thread, 'this' is the new one*/ bool Compare(SimThread thread, SimLock locked, out bool isWarning, out string msg) { isWarning = false; msg = null; if (locked != this) { if (!IsParent(locked)) { if (IsGlobalLock) /*acquiring a global lock*/ { if (!thread.HoldsLock(this)) /*does the thread alread hold it?*/ { msg = "Acquired a global lock after a regular lock without having it before."; return(false); } } else { msg = "Hierarchy violation."; return(false); } } } else if (IsSimpleLock) { msg = "Avoid taking simple locks recursively"; isWarning = true; return(false); } return(true); }
public string GetErrorMessage(SimThread thread, SimLock locked) { bool warn; string msg; bool res = Compare(thread, locked, out warn, out msg); return(!res && !warn ? msg : null); }
public string GetWarningMessage(SimThread thread, SimLock locked) { bool warn; string msg; Compare(thread, locked, out warn, out msg); return(warn ? msg : null); }
public bool WarnAbout(SimThread thread, SimLock locked) { bool warn; string msg; Compare(thread, locked, out warn, out msg); return(warn); }