Ejemplo n.º 1
0
        //[DebuggerNonUserCodeAttribute]
        public override void Load(UIntPtr location, uint size, int codeLabel, bool is_volatile)
        {
            ulong machineId      = 0;
            var   machineRunning = this.Reporter.TryGetCurrentMachineId(out machineId);

            if (!machineRunning || !Reporter.InAction.ContainsKey(machineId))
            {
                return;
            }
            UIntPtr objH, objO;

            ObjectTracking.GetObjectHandle(location, out objH, out objO);
            if (objH == UIntPtr.Zero)
            {
                return;
            }
            if (Reporter.InAction[machineId])// && !this.CallStack.Peek().FullName.Contains("Microsoft.PSharp") && objH != null)
            {
                if (is_volatile)
                {
                    throw new Exception("Volatile variables not permitted in PSharp state machines");
                }
                var sourceInfo = GetDebugInformation(location, objH);
                Reporter.RegisterRead(machineId, sourceInfo, location, objH, objO, is_volatile);
            }
        }
        public override void Load(UIntPtr location, uint size, int codeLabel, bool is_volatile)
        {
            UIntPtr objH, objO;

            ObjectTracking.GetObjectHandle(location, out objH, out objO);

            if (this.RecordRW && !this.CallStack.Peek().FullName.Contains("Microsoft.PSharp") && objH != null)
            {
                // TODO: Hack
                if (this.CallStack.Peek().ToString().Contains("Monitor"))
                {
                    return;
                }
                // End hack

                ThreadTrace obj = this.ThreadTrace[this.ThreadTrace.Count - 1];
                obj.Accesses.Add(new ActionInstr(false, location, objH, objO, GetSourceLocation(location)));
                this.DebugTrace.Add($"<ThreadMonitorLog> Load '{objH}' '{objO}' " +
                                    $"'{this.CallStack.Peek()}' '{GetSourceLocation(location)}'.");
            }
            else if (!this.CallStack.Peek().FullName.Contains("Microsoft.PSharp") && objH != null)
            {
                foreach (Tuple <Method, int> m in TaskMethods)
                {
                    // TODO: This is fragile (for tasks)
                    if (this.CallStack.Peek().ShortName.Contains(m.Item1.ShortName))
                    {
                        ThreadTrace obj = Monitoring.ThreadTrace.CreateTraceForTask(m.Item2);
                        obj.Accesses.Add(new ActionInstr(false, location, objH, objO, GetSourceLocation(location)));
                        this.ThreadTrace.Add(obj);
                    }
                }
            }
        }