Ejemplo n.º 1
0
    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);
            }
        }
    }
Ejemplo n.º 2
0
    public bool IsValid(SimThread thread, SimLock locked)
    {
        bool   warn;
        string msg;

        return(Compare(thread, locked, out warn, out msg));
    }
Ejemplo n.º 3
0
    /*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);
    }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
    public string GetWarningMessage(SimThread thread, SimLock locked)
    {
        bool   warn;
        string msg;

        Compare(thread, locked, out warn, out msg);
        return(warn ? msg : null);
    }
Ejemplo n.º 6
0
    public bool WarnAbout(SimThread thread, SimLock locked)
    {
        bool   warn;
        string msg;

        Compare(thread, locked, out warn, out msg);
        return(warn);
    }