private void ProcessFormat1Conditions(ETMPcktPHeaderFormat1 aHeader) { string pass = aHeader.ConditionCountPassed > 0 ? string.Format("{0} x PASS", aHeader.ConditionCountPassed) : string.Empty; string fail = aHeader.ConditionCountFailed > 0 ? string.Format(", {0} x FAIL", aHeader.ConditionCountFailed) : string.Empty; base.Trace("{0} - {1} {2}", base.MakeTracePacketPrefix("P-HEADER(1)"), pass, fail); // Get the total number of instructions processed int totalExecutedInstructionCount = aHeader.ConditionCountPassed + aHeader.ConditionCountFailed; // Trace passed instructions for (int i = 0; i < aHeader.ConditionCountPassed; i++) { uint address = base.StateData.CurrentAddress; ETMInstruction instruction = base.StateData.FetchInstruction(address); // TraceAtom(ETMPcktPHeaderBase.TAtomType.EAtomE_Passed, instruction); // We will now check the current instruction to see if it's a branch. // If it is, then we don't need to increment the instruction address, because // the explicit branch will set a new PC location. // // Note that in the case of a thumb BLX, i.e. two 16-bit instructions which // interpreted together form a +/-4mb branch address, we also need // to ensure that the bool branched = CheckForBranch(instruction); if (!branched) { base.StateData.IncrementPC(); } } // Trace and failed instructions if (aHeader.ConditionCountFailed > 0) { uint address = base.StateData.CurrentAddress; ETMInstruction instruction = base.StateData.FetchInstruction(address); // TraceAtom(ETMPcktPHeaderBase.TAtomType.EAtomN_Failed, instruction); base.StateData.IncrementPC(); } // Spacer - to make the verbose output easier to read... base.Trace(string.Empty); }
public override ETMDecodeState HandleByte(SymByte aByte) { ETMDecodeState nextState = new ETMDecodeStateSynchronized(base.StateData); // ETMPcktBase packet = Packets.Factory.ETMPacketFactory.Create(aByte); if (packet is ETMPcktPHeaderFormat1) { ETMPcktPHeaderFormat1 pHeader1 = (ETMPcktPHeaderFormat1)packet; ProcessFormat1Conditions(pHeader1); } else if (packet is ETMPcktPHeaderFormat2) { ETMPcktPHeaderFormat2 pHeader2 = (ETMPcktPHeaderFormat2)packet; ProcessFormat2Conditions(pHeader2); } else { throw new ETMException("ERROR: P-HEADER is not supported"); } // return(nextState); }