Пример #1
0
        private void SimplifyCallsInRegion(InstrumentationRegion region)
        {
            foreach (var call in region.Cmds().OfType <CallCmd>())
            {
                var calleeRegion = base.AC.InstrumentationRegions.Find(val =>
                                                                       val.Implementation().Name.Equals(call.callee));
                if (calleeRegion == null)
                {
                    continue;
                }
                if (calleeRegion.IsEnablingNetwork || calleeRegion.IsChangingNetAvailability)
                {
                    continue;
                }

                call.callee = "_NO_OP_$" + base.EP.Name;
                call.Ins.Clear();
                call.Outs.Clear();

                base.SlicedRegions.Add(calleeRegion);
            }
        }
Пример #2
0
        private void InstrumentImplementation(InstrumentationRegion region)
        {
            foreach (var c in region.Cmds().OfType <CallCmd>())
            {
                if (c.callee.Equals("mutex_lock") ||
                    c.callee.Equals("spin_lock"))
                {
                    c.callee = "_UPDATE_CLS_$" + this.EP.Name;
                    c.Ins.Add(Expr.True);

                    this.EP.IsHoldingLock = true;
                }
                else if (c.callee.Equals("mutex_lock_interruptible"))
                {
                    c.callee = "_UPDATE_CLS_$bool$" + this.EP.Name;
                    c.Ins.Add(Expr.True);

                    this.EP.IsHoldingLock = true;
                }
                else if (c.callee.Equals("mutex_unlock") ||
                         c.callee.Equals("spin_unlock"))
                {
                    c.callee = "_UPDATE_CLS_$" + this.EP.Name;
                    c.Ins.Add(Expr.False);

                    this.EP.IsHoldingLock = true;
                }
                else if (c.callee.Equals("spin_lock_irqsave"))
                {
                    c.callee = "_UPDATE_CLS_$" + this.EP.Name;
                    c.Ins.RemoveAt(1);
                    c.Ins.Add(Expr.True);

                    this.EP.IsHoldingLock = true;
                }
                else if (c.callee.Equals("spin_unlock_irqrestore"))
                {
                    c.callee = "_UPDATE_CLS_$" + this.EP.Name;
                    c.Ins.RemoveAt(1);
                    c.Ins.Add(Expr.False);

                    this.EP.IsHoldingLock = true;
                }
                else if (c.callee.Equals("pm_runtime_get_sync") ||
                         c.callee.Equals("pm_runtime_get_noresume"))
                {
                    c.callee = "_UPDATE_CLS_$" + this.EP.Name;
                    c.Ins.Clear();
                    c.Outs.Clear();

                    var powerLock = this.AC.GetLockVariables().Find(val => val.Name.Equals("lock$power"));
                    c.Ins.Add(new IdentifierExpr(powerLock.tok, powerLock));
                    c.Ins.Add(Expr.True);

                    this.EP.IsHoldingLock = true;
                }
                else if (c.callee.Equals("pm_runtime_put_sync") ||
                         c.callee.Equals("pm_runtime_put_noidle"))
                {
                    c.callee = "_UPDATE_CLS_$" + this.EP.Name;
                    c.Ins.Clear();
                    c.Outs.Clear();

                    var powerLock = this.AC.GetLockVariables().Find(val => val.Name.Equals("lock$power"));
                    c.Ins.Add(new IdentifierExpr(powerLock.tok, powerLock));
                    c.Ins.Add(Expr.False);

                    this.EP.IsHoldingLock = true;
                }
                else if (c.callee.Equals("ASSERT_RTNL"))
                {
                    c.callee = "_UPDATE_CLS_$" + this.EP.Name;
                    c.Ins.Clear();
                    c.Outs.Clear();

                    var rtnl = this.AC.GetLockVariables().Find(val => val.Name.Equals("lock$rtnl"));
                    c.Ins.Add(new IdentifierExpr(rtnl.tok, rtnl));
                    c.Ins.Add(Expr.True);

                    this.EP.IsHoldingLock = true;
                }
                else if (c.callee.Equals("netif_stop_queue"))
                {
                    if (!this.EP.IsTxLocked)
                    {
                        c.callee = "_UPDATE_CLS_$" + this.EP.Name;
                        c.Ins.Clear();
                        c.Outs.Clear();

                        var tx = this.AC.GetLockVariables().Find(val => val.Name.Equals("lock$tx"));
                        c.Ins.Add(new IdentifierExpr(tx.tok, tx));
                        c.Ins.Add(Expr.True);

                        if (this.TransmitLockHolder == null)
                        {
                            this.TransmitLockHolder = region;
                        }

                        this.EP.IsHoldingLock = true;
                    }
                    else
                    {
                        c.callee = "_NO_OP_$" + this.EP.Name;
                        c.Ins.Clear();
                        c.Outs.Clear();
                    }
                }
            }
        }