// TODO is making this public a hack? public StackSourceFrameIndex GetFrameIndex(CodeAddressIndex codeAddressIndex, out bool isReasonableTopStack) { isReasonableTopStack = false; string moduleName = "?"; ModuleFileIndex moduleIdx = m_log.CodeAddresses.ModuleFileIndex(codeAddressIndex); if (moduleIdx != Diagnostics.Tracing.ModuleFileIndex.Invalid) { moduleName = m_log.ModuleFiles[moduleIdx].FilePath; if (moduleName.EndsWith("ntdll.dll", StringComparison.OrdinalIgnoreCase)) { isReasonableTopStack = true; } } var internedModule = Interner.ModuleIntern(moduleName); string methodName = "?"; var methodIdx = m_log.CodeAddresses.MethodIndex(codeAddressIndex); if (methodIdx != MethodIndex.Invalid) { methodName = m_log.CodeAddresses.Methods.FullMethodName(methodIdx); } else if (ShowUnknownAddressses) { methodName = "0x" + m_log.CallStacks.CodeAddresses.Address(codeAddressIndex).ToString("x"); } var internedFrame = Interner.FrameIntern(methodName, internedModule); return(internedFrame); }
private bool ReasonableTopFrame(StackSourceCallStackIndex callStackIndex) { uint index = (uint)callStackIndex - (uint)StackSourceCallStackIndex.Start; var stack = m_log.CallStacks[(CallStackIndex)callStackIndex]; if (index < (uint)m_log.CallStacks.MaxCallStackIndex) { CodeAddressIndex codeAddressIndex = m_log.CallStacks.CodeAddressIndex((CallStackIndex)index); ModuleFileIndex moduleFileIndex = m_log.CallStacks.CodeAddresses.ModuleFileIndex(codeAddressIndex); if (m_goodTopModuleIndex == moduleFileIndex) // optimization { return(true); } TraceModuleFile moduleFile = m_log.CallStacks.CodeAddresses.ModuleFile(codeAddressIndex); if (moduleFile == null) { return(false); } // We allow things that end in ntdll to be considered unbroken (TODO is this too strong?) if (!moduleFile.FilePath.EndsWith("ntdll.dll", StringComparison.OrdinalIgnoreCase)) { return(false); } m_goodTopModuleIndex = moduleFileIndex; return(true); } return(false); }
private bool ReasonableTopFrame(StackSourceCallStackIndex callStackIndex, ThreadIndex threadIndex) { uint index = (uint)callStackIndex - (uint)StackSourceCallStackIndex.Start; var stack = m_log.CallStacks[(CallStackIndex)callStackIndex]; if (index < (uint)m_log.CallStacks.Count) { CodeAddressIndex codeAddressIndex = m_log.CallStacks.CodeAddressIndex((CallStackIndex)index); ModuleFileIndex moduleFileIndex = m_log.CallStacks.CodeAddresses.ModuleFileIndex(codeAddressIndex); if (m_goodTopModuleIndex == moduleFileIndex) // optimization { return(true); } TraceModuleFile moduleFile = m_log.CallStacks.CodeAddresses.ModuleFile(codeAddressIndex); if (moduleFile == null) { return(false); } // We allow things that end in ntdll to be considered unbroken (TODO is this too strong?) if (moduleFile.FilePath.EndsWith("ntdll.dll", StringComparison.OrdinalIgnoreCase)) { m_goodTopModuleIndex = moduleFileIndex; return(true); } // The special processes 4 (System) and 0 (Kernel) can stay in the kernel without being broken. if (moduleFile.FilePath.EndsWith("ntoskrnl.exe", StringComparison.OrdinalIgnoreCase)) { var processId = m_log.Threads[threadIndex].Process.ProcessID; if (processId == 4 || processId == 0) { m_goodTopModuleIndex = moduleFileIndex; return(true); } } return(false); } return(false); }
public static DiscoveredModule FromIndex(ModuleFileIndex idx) => new DiscoveredModule { Index = idx, };