Exemplo n.º 1
0
        protected override void OnProcessOutputSchema(MutableObject newSchema)
        {
            var ids = new List <MutableObject>();

            var id1 = new MutableObject();

            id1.Add("TraceRequestID", Trace1RequestIdField.GetFirstValue(newSchema));
            id1.Add("TraceBinaryID", Trace1BinaryIdField.GetFirstValue(newSchema));
            ids.Add(id1);

            var id2 = new MutableObject();

            id2.Add("TraceRequestID", Trace2RequestIdField.GetFirstValue(newSchema));
            id2.Add("TraceBinaryID", Trace2BinaryIdField.GetFirstValue(newSchema));
            ids.Add(id2);

            var id3 = new MutableObject();

            id3.Add("TraceRequestID", Trace3RequestIdField.GetFirstValue(newSchema));
            id3.Add("TraceBinaryID", Trace3BinaryIdField.GetFirstValue(newSchema));
            ids.Add(id3);

            newSchema.Add("Trace IDs", ids);

            Router.TransmitAllSchema(newSchema);
        }
Exemplo n.º 2
0
        public IEnumerator RunVolumeTest()
        {
            MutableObject testObj = new MutableObject();

            testObj.Add("height", 3f);
            testObj.Add("heightMax", 5f);

            VisualPayload payload = new VisualPayload(
                testObj,
                new VisualDescription(BoundingBox.ConstructBoundingBox(GetType().Name)));


            // create a volume controller
            RectangularVolumeController volumeController = new RectangularVolumeController();

            volumeController.YAxis.AbsoluteKey = "height";
            volumeController.YMax.AbsoluteKey  = "heightMax";

            // send the test mutable
            var iterator = volumeController.StartReceivePayload(payload);

            while (iterator.MoveNext( ))
            {
                yield return(null);
            }
        }
Exemplo n.º 3
0
        private MutableObject ConstructRcsMutable(RcsToCsInfo rcsInfo)
        {
            var mutable = new MutableObject();

            mutable.Add("Team", (int)rcsInfo.Team);
            mutable.Add("Cs ID", (int)rcsInfo.CsId);
            mutable.Add("Round", (int)rcsInfo.Round);
            mutable.Add("Bs Id", (int)rcsInfo.BsId);

            return(mutable);
        }
Exemplo n.º 4
0
        private static void ProcessTraceHeader(TraceHeader traceHeader, MutableObject traceMutable)
        {
            MutableObject header = new MutableObject();

            header.Add("Binary ID", (int)traceHeader.BinaryId);
            header.Add("Magic", (int)traceHeader.Magic);
            header.Add("Version", (int)traceHeader.Version);
            header.Add("Flags", (int)traceHeader.Flags);

            traceMutable.Add("Header", header);
        }
        private List <MutableObject> DiscriminatedList(List <MutableObject> mutable)
        {
            var topLevelEntryListing = new List <MutableObject>();

            var entryLists = new Dictionary <int, List <MutableObject> >();

            foreach (var entry in Scope.GetEntries(mutable))
            {
                var discriminant = Discriminant.GetFirstValueBelowArrity(entry);

                if (!entryLists.ContainsKey(discriminant))
                {
                    var newMutable = new MutableObject();

                    var newList = new List <MutableObject>();

                    newMutable.Add("Entries", newList);

                    topLevelEntryListing.Add(newMutable);

                    entryLists[discriminant] = newList;
                }

                var foundList = entryLists[discriminant];

                foundList.Add(entry.Last());
            }

            return(topLevelEntryListing);
        }
Exemplo n.º 6
0
        public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            var ids = new List <MutableObject>();

            var id1    = new MutableObject();
            var ignore = Trace1RequestIdField.GetFirstValue(payload.Data) == -1 ||
                         Trace1BinaryIdField.GetFirstValue(payload.Data) == -1;

            if (!ignore)
            {
                id1.Add("TraceRequestID", Trace1RequestIdField.GetFirstValue(payload.Data));
                id1.Add("TraceBinaryID", Trace1BinaryIdField.GetFirstValue(payload.Data));
                ids.Add(id1);
            }

            var id2 = new MutableObject();

            ignore = Trace2RequestIdField.GetFirstValue(payload.Data) == -1 ||
                     Trace2BinaryIdField.GetFirstValue(payload.Data) == -1;
            if (!ignore)
            {
                id2.Add("TraceRequestID", Trace2RequestIdField.GetFirstValue(payload.Data));
                id2.Add("TraceBinaryID", Trace2BinaryIdField.GetFirstValue(payload.Data));
                ids.Add(id2);
            }

            var id3 = new MutableObject();

            ignore = Trace3RequestIdField.GetFirstValue(payload.Data) == -1 ||
                     Trace3BinaryIdField.GetFirstValue(payload.Data) == -1;
            if (!ignore)
            {
                id3.Add("TraceRequestID", Trace3RequestIdField.GetFirstValue(payload.Data));
                id3.Add("TraceBinaryID", Trace3BinaryIdField.GetFirstValue(payload.Data));
                ids.Add(id3);
            }

            payload.Data.Add("Trace IDs", ids);

            var iterator = Router.TransmitAll(payload);

            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }
Exemplo n.º 7
0
        private MutableObject ConstructStatsMutable(ulong instructionCount)
        {
            var statsMutable = new MutableObject();

            statsMutable.Add("Instruction Count",
                             instructionCount);

            return(statsMutable);
        }
Exemplo n.º 8
0
        protected override MutableObject Mutate(MutableObject mutable)
        {
            if (!Schema.ContainsKey(Key))
            {
                Schema.Add(Key, "Pi");
            }

            if (!mutable.ContainsKey(Key))
            {
                mutable.Add(Key, Schema[Key]);
            }

            return(mutable);
        }
Exemplo n.º 9
0
        protected override void OnProcessOutputSchema(MutableObject newSchema)
        {
            var elementList = EntryField.GetLastKeyValue(newSchema) as IEnumerable <MutableObject>;

            if (elementList == null)
            {
                Debug.LogError("This isn't a valid schema!  The entries field is empty!");
            }

            //var singleSchema = elementList.First();
            var multiSchema = new MutableObject();

            multiSchema.Add("Entries", elementList);
        }
Exemplo n.º 10
0
        private static MutableObject CreateInstructionMutable(InstructionElement element, int instructionCount)
        {
            var newInstruction = new MutableObject();

            newInstruction.Add("Eip", element.Eip);

            newInstruction.Add("Wall Time", (float)element.Header.WallTime);
            newInstruction.Add("Raw Type Index", (int)element.Header.RawTypeIndex);
            newInstruction.Add("Length", (int)element.Header.Length);
            newInstruction.Add("Original Index", (int)element.Header.InstructionCount);
            newInstruction.Add("Processed Index", instructionCount);

            newInstruction.Add("Annotated", false);

            newInstruction.Add("Trace Instruction", element);

            return(newInstruction);
        }
Exemplo n.º 11
0
        public static MutableObject ExecutionToMutable(Execution execution, bool isMemoryTrace, int povType)
        {
            MutableObject mutable = new MutableObject();

            ProcessHeader(execution, mutable, povType);

            List <MutableObject> traceMutables = new List <MutableObject>();

            foreach (var trace in execution.Traces)
            {
                MutableObject traceMutable = new MutableObject();

                ProcessAllTraceElements(trace, traceMutable, isMemoryTrace);

                traceMutables.Add(traceMutable);
            }

            mutable.Add("Traces", traceMutables);

            return(mutable);
        }
Exemplo n.º 12
0
        // construct the execution header as a mutable object, and write it into this mutable
        private static void ProcessHeader(Execution execution, MutableObject mutable, int povType)
        {
            var header = new MutableObject();

            header.Add("Author", execution.CbAuthor);
            header.Add("CB ID", (int)execution.CbId);
            header.Add("Execution ID", (int)execution.ExecutionId);
            header.Add("Request ID", (int)execution.RequestId);
            header.Add("Request Nature", execution.RequestNature);

            // Taking this out as it seems not to be populated...
            //MutableObject service = new MutableObject();
            //service.Add("Service Name", execution.ServiceId.Name ?? "Unnamed");
            //service.Add("Service ID", (int)execution.ServiceId.Id);
            //header.Add("Service", service);

            header.Add("Success", execution.Success);

            header.Add("PovType", povType);

            mutable.Add("Header", header);
        }
Exemplo n.º 13
0
        protected override void OnProcessOutputSchema(MutableObject newSchema)
        {
            var elementList = EntryField.GetFirstValue(newSchema) as IEnumerable <MutableObject>;

            if (elementList == null)
            {
                Debug.LogError("This isn't a valid schema!  The entries field is empty!");
            }

            var singleSchema = elementList.First();
            var multiSchema  = new MutableObject();

            multiSchema.Add("Entries", elementList);

            NormalState.TransmitSchema(singleSchema);
            SelectedState.TransmitSchema(singleSchema);
            NoneSelectedState.TransmitSchema(singleSchema);

            NormalStateMulti.TransmitSchema(multiSchema);
            SelectedStateMulti.TransmitSchema(multiSchema);
            NoneSelectedStateMulti.TransmitSchema(multiSchema);
        }
        protected override MutableObject Mutate(MutableObject mutable)
        {
            if (!IncludeRandomFloat)
            {
                if (mutable.ContainsKey("RandomFloat"))
                {
                    mutable.Remove("RandomFloat");
                }
            }
            else
            {
                if (!mutable.ContainsKey("RandomFloat"))
                {
                    mutable.Add("RandomFloat", Random.Range(0.0f, 1.0f));
                }
                else
                {
                    mutable["RandomFloat"] = Random.Range(0.0f, 1.0f);
                }
            }

            return(mutable);
        }
Exemplo n.º 15
0
        private MutableObject SpoofTrace(int instructionCount, int binaryCount)
        {
            MutableObject executionMutable = new MutableObject();

            var execHeader = new MutableObject();

            execHeader.Add("Author", "Author");
            execHeader.Add("CB ID", 1);
            execHeader.Add("Execution ID", 1);
            execHeader.Add("Request ID", 1);
            execHeader.Add("Request Nature", TraceAdapters.Traces.RequestNature.ServicePoll);

            MutableObject service = new MutableObject();

            service.Add("Service Name", "service name");
            service.Add("Service ID", 1);
            execHeader.Add("Service", service);

            execHeader.Add("Success", true);
            execHeader.Add("PovType", 0);

            executionMutable.Add("Header", execHeader);

            List <MutableObject> traceMutables = new List <MutableObject>();

            MutableObject traceMutable = new MutableObject();

            ///

            MutableObject header = new MutableObject();

            header.Add("Binary ID", 1);
            header.Add("Magic", 1);
            header.Add("Version", 1);
            header.Add("Flags", 1);

            traceMutable.Add("Header", header);

            ////
            var instructionsList = new List <MutableObject>();

            //var usedEips = new List<uint>();
            var uniqueInstructions = Mathf.FloorToInt(Mathf.Log(instructionCount, 1.1f));

            var annotationTypes = new[] { "transmit", "receive", "start1", "allocate", "end1", "free", "fdwait", "random", "end1" };


            for (int i = 0; i < instructionCount; i++)
            {
                var newInstruction = new MutableObject();

                var newEip = (uint)Mathf.FloorToInt(UnityEngine.Random.value * uniqueInstructions);
                newInstruction.Add("Eip", newEip);

                newInstruction.Add("Wall Time", .01f * instructionCount);
                newInstruction.Add("Raw Type Index", 1);
                newInstruction.Add("Length", 1);
                newInstruction.Add("Original Index", i);
                newInstruction.Add("Processed Index", i);

                var disasmInstruction = new InstructionDisasmElement(new TraceElementHeader());
                disasmInstruction.Disassembly = "Disasm " +
                                                (uint)Mathf.FloorToInt(UnityEngine.Random.value * uniqueInstructions);
                newInstruction.Add("Trace Instruction", disasmInstruction);

                if (UnityEngine.Random.value > .975f)
                {
                    newInstruction.Add("Annotated", true);
                    string annotationType =
                        annotationTypes[Mathf.FloorToInt(UnityEngine.Random.value * annotationTypes.Length)];
                    string annotationString = annotationType;
                    if (string.Compare(annotationType, "allocate", StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        annotationString += " " + Mathf.FloorToInt(UnityEngine.Random.value * 10000)
                                            + " bytes at 0x"
                                            + Mathf.FloorToInt(UnityEngine.Random.value * 10000000).ToString("x8");
                    }
                    if (string.Compare(annotationType, "transmit", StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        annotationString += " \"A transmit number " + UnityEngine.Random.value + " \"";
                    }
                    if (string.Compare(annotationType, "receive", StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        annotationString += " \"A receive number " + UnityEngine.Random.value + " \"";
                    }

                    newInstruction.Add("Annotation Event Type", annotationType);
                    newInstruction.Add("Annotation Text", annotationString);
                }
                else
                {
                    newInstruction.Add("Annotated", false);
                }

                instructionsList.Add(newInstruction);
            }

            traceMutable.Add("Instructions", instructionsList);
            traceMutable.Add("InstructionCount", instructionsList.Count);
            ////


            // set up memory reads and writes
            var memReads = new List <MutableObject>()
            {
                new MutableObject()
                {
                    { "Read Address", (uint)1500 },
                    { "Read Hex", "data" },
                    { "Read Size", (int)4 },
                    { "Original Index", (int)5 },
                    { "Processed Index", (int)5 }
                }
            };

            traceMutable.Add("Memory Reads", memReads);

            var memWrites = new List <MutableObject>()
            {
                new MutableObject()
                {
                    { "Write Address", (uint)1500 },
                    { "Write Hex", "data" },
                    { "Write Size", (int)4 },
                    { "Original Index", (int)5 },
                    { "Processed Index", (int)5 }
                }
            };

            traceMutable.Add("Memory Writes", memWrites);

            traceMutables.Add(traceMutable);

            executionMutable.Add("Traces", traceMutables);

            return(executionMutable);
        }
Exemplo n.º 16
0
        private MutableObject EventContainerToMutableObject(List <Round> eventRounds)
        {
            var eventContainerMutableObject = new MutableObject();
            var rounds = new List <MutableObject>();

            eventContainerMutableObject.Add("Rounds", rounds);

            foreach (var round in eventRounds)
            {
                var roundMutable = new MutableObject();
                roundMutable.Add("RoundIndex", round.RoundIndex);

                var events = new List <MutableObject>();
                roundMutable.Add("Events", events);

                // DEBUG

                if (round.GameEvents.Polls == null)
                {
                    round.GameEvents.Polls = new List <PollEvent>();
                }

                // END DEBUG


                foreach (var povSubmissionEvent in round.GameEvents.PovSubmission)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Timestamp", povSubmissionEvent.Timestamp },
                        { "Pov ID", povSubmissionEvent.Povid },
                        { "Source Team", povSubmissionEvent.SourceTeam },
                        { "Target Team", povSubmissionEvent.TargetTeam },
                        { "Target Cs ID", povSubmissionEvent.TargetCsid },
                        { "Target Rcs ID", povSubmissionEvent.TargetBsid },
                        { "Result", EventResult.Succeed },
                        { "TypeString", "PovSubmission" },
                    };

                    events.Add(eventMutable);
                }

                foreach (var pollEvent in round.GameEvents.Polls)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Timestamp", pollEvent.Timestamp },
                        { "Poll ID", pollEvent.Pollid },
                        { "Target Team", pollEvent.TargetTeam },
                        { "Target Cs ID", pollEvent.TargetCsid },
                        { "Target Bs ID", pollEvent.TargetBsid },
                        { "Result", pollEvent.Result },
                        { "Ids", pollEvent.Nds },
                        { "Duration", pollEvent.Duration },
                        { "TypeString", "Poll" },
                    };

                    events.Add(eventMutable);
                }

                foreach (var gameEvent in round.GameEvents.PovThrow)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Timestamp", gameEvent.Timestamp },
                        { "Duration", gameEvent.Duration },
                        { "Pov ID", gameEvent.Povid },
                        { "Source Team", gameEvent.SourceTeam },
                        { "Target Team", gameEvent.TargetTeam },
                        { "Target Cs ID", gameEvent.TargetCsid },
                        { "Target Bs ID", gameEvent.TargetBsid },
                        { "Result", gameEvent.Result },
                        { "Ids Result", gameEvent.Nds },
                        { "Negotiate", gameEvent.Negotiate },
                        { "TypeString", "PovThrow" },
                    };

                    events.Add(eventMutable);
                }


                foreach (var gameEvent in round.GameEvents.PovNotthrown)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Timestamp", gameEvent.Timestamp },
                        { "Pov ID", gameEvent.Povid },
                        { "Source Team", gameEvent.SourceTeam },
                        { "Target Team", gameEvent.TargetTeam },
                        { "Target Cs ID", gameEvent.TargetCsid },
                        { "TypeString", "PovNotThrown" },
                    };

                    events.Add(eventMutable);
                }

                foreach (var gameEvent in round.GameEvents.RcsSubmission)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Timestamp", gameEvent.Timestamp },
                        { "Cs ID", gameEvent.Csid },
                        { "Bs ID", gameEvent.Bsid },
                        { "Rcs ID", gameEvent.Rcsid },
                        { "Team", gameEvent.Team },
                        { "TypeString", "RcsSubmission" },
                    };

                    events.Add(eventMutable);
                }

                foreach (var gameEvent in round.GameEvents.RcsDeployed)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Timestamp", gameEvent.Timestamp },
                        { "Cs ID", gameEvent.Csid },
                        { "Team", gameEvent.Team },
                        { "Bs ID", gameEvent.Bsid },
                        { "TypeString", "RcsDeployed" },
                    };

                    events.Add(eventMutable);
                }

                foreach (var gameEvent in round.GameEvents.NetworkRuleSubmission)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Timestamp", gameEvent.Timestamp },
                        { "Cs ID", gameEvent.Csid },
                        { "Team", gameEvent.Team },
                        { "Rule ID", gameEvent.Ruleid },
                        { "TypeString", "NetworkRuleSubmission" },
                    };

                    events.Add(eventMutable);
                }

                foreach (var gameEvent in round.GameEvents.NetworkRuleDeployed)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Timestamp", gameEvent.Timestamp },
                        { "Cs ID", gameEvent.Csid },
                        { "Team", gameEvent.Team },
                        { "Rule ID", gameEvent.Ruleid },
                        { "TypeString", "NetworkRuleDeployed" },
                    };

                    events.Add(eventMutable);
                }

                foreach (var gameEvent in round.GameEvents.CsOffline)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Timestamp", gameEvent.Timestamp },
                        { "Cs ID", gameEvent.Csid },
                        { "Team", gameEvent.Team },
                        { "Offline Reason", gameEvent.Reason },
                        { "TypeString", "CsOffline" },
                    };

                    events.Add(eventMutable);
                }


                double lowestTimestamp = double.MaxValue;
                foreach (var roundEvent in events.Where(roundEvent => (double)roundEvent["Timestamp"] < lowestTimestamp &&
                                                        (double)roundEvent["Timestamp"] > .000001))
                {
                    lowestTimestamp = (double)roundEvent["Timestamp"];
                }


                foreach (var roundEvent in events)
                {
                    if ((double)roundEvent["Timestamp"] > .00001)
                    {
                        roundEvent["Timestamp"] = (double)roundEvent["Timestamp"] - lowestTimestamp;
                    }
                }

                var csAdded = new List <MutableObject>();
                foreach (var csAdd in round.PreRoundEvents.CsAdded)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Cs ID", csAdd.Csid }
                    };
                    csAdded.Add(eventMutable);
                }
                roundMutable["Cs Added"] = csAdded;

                var csRemoved = new List <MutableObject>();
                foreach (var csRemove in round.PreRoundEvents.CsRemoved)
                {
                    var eventMutable = new MutableObject
                    {
                        { "Cs ID", csRemove.Csid }
                    };
                    csRemoved.Add(eventMutable);
                }
                roundMutable["Cs Removed"] = csRemoved;


                rounds.Add(roundMutable);
            }
            return(eventContainerMutableObject);
        }
Exemplo n.º 17
0
        private static void ProcessTrace(Trace trace, MutableObject traceMutable, bool memTrace = false)
        {
            //trace.GenerateCallGraph();


            //Dictionary< int, FlaggedAnnotation > foundAnnotations = new Dictionary< int, FlaggedAnnotation >();

            //   foreach ( var annotationElement in trace.Annotations )
            //   {
            //       foundAnnotations.Add( (int)annotationElement.Header.InstructionCount, new FlaggedAnnotation { Flagged = false, Annotation = annotationElement } );
            //   }

            Dictionary <int, MutableObject> instructionMutables = new Dictionary <int, MutableObject>();

            Dictionary <int, string> comms = new Dictionary <int, string>();

            int instructionCount = 0;

            foreach (var element in trace.Elements)
            {
                if (instructionMutables.ContainsKey(element.Header.InstructionCount))
                {
                    continue;
                }

                var newInstruction = CreateInstructionMutable(element, instructionCount);

                instructionMutables.Add(element.Header.InstructionCount, newInstruction);

                instructionCount++;
            }

            int lateAddedAnnotationCount = 0;

            // Add any annotations that were not interleaved in the trace (announcer additions; crashes...)
            foreach (var annotation in trace.Annotations)
            //foundAnnotations.Where( p => p.Value.Flagged == false ) )
            {
                //instructionMutables.FirstOrDefault( i => (int)i["Original Index"] == (int)pair.Key );

                MutableObject foundInstructionMutable;

                if (!instructionMutables.ContainsKey(annotation.Header.InstructionCount))
                {
                    var lastElement = trace.Elements.Last();

                    var newHeader = new TraceElementHeader(
                        lastElement.Header.RawTypeIndex,
                        lastElement.Header.Length,
                        lastElement.Header.WallTime,
                        lastElement.Header.InstructionCount + 1 + lateAddedAnnotationCount++);

                    var newElement = new InstructionOnlyElement(newHeader)
                    {
                        Eip = lastElement.Eip
                    };


                    foundInstructionMutable = CreateInstructionMutable(newElement, instructionCount++);
                    //foundInstructionMutable[ "Annotated" ] = true;

                    instructionMutables.Add(newHeader.InstructionCount, foundInstructionMutable);
                }
                else
                {
                    foundInstructionMutable = instructionMutables[annotation.Header.InstructionCount];
                }

                SetAnnotationOnInstructionMutable(foundInstructionMutable, annotation, comms);
            }

            traceMutable.Add("Instructions", instructionMutables.Values);

            traceMutable.Add("InstructionCount", instructionMutables.Count);

            if (memTrace)
            {
                var memReads = new List <MutableObject>();

                foreach (var memRead in trace.MemoryReads)
                {
                    var newRead = new MutableObject()
                    {
                        { "Read Address", (uint)memRead.Addr },
                        { "Read Hex", StringExtensions.ByteArrayToString(memRead.BytesRead) },
                        { "Read Size", memRead.NumberOfBytesRead },
                        { "Original Index", memRead.Header.InstructionCount }
                    };
                    // match original index to get processed index
                    if (instructionMutables.ContainsKey(memRead.Header.InstructionCount))
                    {
                        newRead["Processed Index"] =
                            instructionMutables[memRead.Header.InstructionCount]["Processed Index"];
                    }
                    else
                    {
                        newRead["Processed Index"] = 0;
                    }

                    memReads.Add(newRead);
                }

                traceMutable.Add("Memory Reads", memReads);

                var memWrites = new List <MutableObject>();

                foreach (var memWrite in trace.MemoryWrites)
                {
                    var newWrite = new MutableObject()
                    {
                        { "Write Address", (uint)memWrite.Addr },
                        { "Write Hex", StringExtensions.ByteArrayToString(memWrite.BytesWritten) },
                        { "Write Size", memWrite.NumberOfBytesWritten },
                        { "Original Index", memWrite.Header.InstructionCount }
                        //memWrite.Header.InstructionCount }
                    };
                    // match original index to get processed index
                    if (instructionMutables.ContainsKey(memWrite.Header.InstructionCount))
                    {
                        newWrite["Processed Index"] =
                            instructionMutables[memWrite.Header.InstructionCount]["Processed Index"];
                    }
                    else
                    {
                        newWrite["Processed Index"] = 0;
                    }

                    memWrites.Add(newWrite);
                }
                ;
                traceMutable.Add("Memory Writes", memWrites);
            }

            var sb = new StringBuilder("Comms:\n");

            foreach (var c in comms)
            {
                sb.AppendLine(string.Format("{0:D5}    {1}", c.Key, c.Value));
            }
            //Debug.Log( sb.ToString() );
        }
Exemplo n.º 18
0
        public static MutableObject GenerateExecutionSchema()
        {
            #region Set up execution schema

            MutableObject executionMutable = new MutableObject();

            var execHeader = new MutableObject();

            execHeader.Add("Author", "Author");
            execHeader.Add("CB ID", 1);
            execHeader.Add("Execution ID", 1);
            execHeader.Add("Request ID", 1);
            execHeader.Add("Request Nature", TraceAdapters.Traces.RequestNature.ServicePoll);

            MutableObject service = new MutableObject();
            service.Add("Service Name", "service name");
            service.Add("Service ID", 1);
            execHeader.Add("Service", service);

            execHeader.Add("Success", true);
            execHeader.Add("PovType", 0);

            executionMutable.Add("Header", execHeader);

            List <MutableObject> traceMutables = new List <MutableObject>();

            MutableObject traceMutable = new MutableObject();

            ///

            MutableObject header = new MutableObject();

            header.Add("Binary ID", 1);
            header.Add("Magic", 1);
            header.Add("Version", 1);
            header.Add("Flags", 1);

            traceMutable.Add("Header", header);

            ////
            var instructionsList = new List <MutableObject>();

            for (int i = 0; i < 2; i++)
            {
                var newInstruction = new MutableObject();

                newInstruction.Add("Eip", (uint)1);

                newInstruction.Add("Wall Time", 1f);
                newInstruction.Add("Raw Type Index", 1);
                newInstruction.Add("Length", 1);
                newInstruction.Add("Original Index", 1);
                newInstruction.Add("Processed Index", 1);

                newInstruction.Add("Trace Instruction", new InstructionOnlyElement(new TraceElementHeader()));

                if (i % 2 == 1)
                {
                    newInstruction.Add("Annotated", true);
                    newInstruction.Add("Annotation Text", "Transmit");
                    newInstruction.Add("Annotation Event Type", "transmit");
                }
                else
                {
                    newInstruction.Add("Annotated", false);
                }

                instructionsList.Add(newInstruction);
            }

            traceMutable.Add("Instructions", instructionsList);
            traceMutable.Add("InstructionCount", instructionsList.Count);
            ////

            traceMutables.Add(traceMutable);

            // set up memory reads and writes
            //if ( IncludeMemtrace.GetFirstValue( newSchema ) )
            //{
            var memReads = new List <MutableObject>()
            {
                new MutableObject()
                {
                    { "Read Address", (uint)1500 },
                    { "Read Hex", "data" },
                    { "Read Size", (int)4 },
                    { "Original Index", (int)5 },
                    { "Processed Index", (int)5 }
                }
            };
            traceMutable.Add("Memory Reads", memReads);

            var memWrites = new List <MutableObject>()
            {
                new MutableObject()
                {
                    { "Write Address", (uint)1500 },
                    { "Write Hex", "data" },
                    { "Write Size", (int)4 },
                    { "Original Index", (int)5 },
                    { "Processed Index", (int)5 }
                }
            };
            traceMutable.Add("Memory Writes", memWrites);
            //}

            executionMutable.Add("Traces", traceMutables);

            #endregion

            return(executionMutable);
        }