internal void HandleBranch(ETMBranch aBranch) { TETBStackEntry last = LastEntry; if (last != null) { TETBStackEntry entry = new TETBStackEntry(aBranch); // if (last.SymbolAddress == entry.SymbolAddress) { if (entry.SymbolOffset > last.SymbolOffset) { // Internal branch? E.g. if statement, or loop? } else { PushBranch(entry); } } else if (aBranch.SymbolAddressOffset == 0 && aBranch.Symbol != null) { // Guess: calling a new function PushBranch(entry); } else { bool save = true; // Check if we have branched back to an earlier function without // popping back through the call stack int count = iEntries.Count; for (int i = count - 2; i >= 0; i--) { last = iEntries[i]; if (last.SymbolAddress == entry.SymbolAddress) { if (entry.SymbolOffset > last.SymbolOffset) { // We appear to have jumped back to a calling function - so // discard later items on stack. int deleteCount = count - i - 1; iEntries.RemoveRange(i + 1, deleteCount); save = false; break; } } } if (save) { PushBranch(entry); } } } else { PushBranch(aBranch); } }
private void PushBranch(TETBStackEntry aEntry) { if (aEntry.IsUnknown == false) { int lastDepth = 0; // TETBStackEntry lastEntry = LastEntry; if (lastEntry != null) { lastDepth = lastEntry.Depth + 1; } // aEntry.Depth = lastDepth; } iEntries.Add(aEntry); aEntry.Print(); }
private void PushBranch(ETMBranch aBranch) { TETBStackEntry entry = new TETBStackEntry(aBranch); PushBranch(entry); }