public virtual String CreateStackTraceString(IntPtr ip, bool includeFileInfo) { ReflectionExecutionDomainCallbacks reflectionCallbacks = RuntimeAugments.CallbacksIfAvailable; String moduleFullFileName = null; if (reflectionCallbacks != null) { IntPtr methodStart = RuntimeImports.RhFindMethodStartAddress(ip); if (methodStart != IntPtr.Zero) { string methodName = string.Empty; try { methodName = reflectionCallbacks.GetMethodNameFromStartAddressIfAvailable(methodStart); } catch { } if (!string.IsNullOrEmpty(methodName)) { return(methodName); } } // If we don't have precise information, try to map it at least back to the right module. IntPtr moduleBase = RuntimeImports.RhGetModuleFromPointer(ip); moduleFullFileName = RuntimeAugments.TryGetFullPathToApplicationModule(moduleBase); } // Without any callbacks or the ability to map ip correctly we better admit that we don't know if (string.IsNullOrEmpty(moduleFullFileName)) { return("<unknown>"); } StringBuilder sb = new StringBuilder(); String fileNameWithoutExtension = GetFileNameWithoutExtension(moduleFullFileName); int rva = RuntimeAugments.ConvertIpToRva(ip); sb.Append(fileNameWithoutExtension); sb.Append("!<BaseAddress>+0x"); sb.Append(rva.ToString("x")); return(sb.ToString()); }
public virtual string CreateStackTraceString(IntPtr ip, bool includeFileInfo) { if (!IsMetadataStackTraceResolutionDisabled()) { StackTraceMetadataCallbacks stackTraceCallbacks = RuntimeAugments.StackTraceCallbacksIfAvailable; if (stackTraceCallbacks != null) { IntPtr methodStart = RuntimeImports.RhFindMethodStartAddress(ip); if (methodStart != IntPtr.Zero) { string methodName = stackTraceCallbacks.TryGetMethodNameFromStartAddress(methodStart); if (methodName != null) { if (ip != methodStart) { methodName += " + 0x" + (ip.ToInt64() - methodStart.ToInt64()).ToString("x"); } return(methodName); } } } } // If we don't have precise information, try to map it at least back to the right module. IntPtr moduleBase = RuntimeImports.RhGetOSModuleFromPointer(ip); string moduleFullFileName = RuntimeAugments.TryGetFullPathToApplicationModule(moduleBase); // Without any callbacks or the ability to map ip correctly we better admit that we don't know if (string.IsNullOrEmpty(moduleFullFileName)) { return("<unknown>"); } StringBuilder sb = new StringBuilder(); string fileNameWithoutExtension = GetFileNameWithoutExtension(moduleFullFileName); int rva = RuntimeAugments.ConvertIpToRva(ip); sb.Append(fileNameWithoutExtension); sb.Append("!<BaseAddress>+0x"); sb.Append(rva.ToString("x")); return(sb.ToString()); }
public virtual String CreateStackTraceString(IntPtr ip, bool includeFileInfo) { ReflectionExecutionDomainCallbacks reflectionCallbacks = RuntimeAugments.CallbacksIfAvailable; if (reflectionCallbacks != null) { IntPtr methodStart = RuntimeImports.RhFindMethodStartAddress(ip); if (methodStart != IntPtr.Zero) { string methodName = string.Empty; try { methodName = reflectionCallbacks.GetMethodNameFromStartAddressIfAvailable(methodStart); } catch { } if (!string.IsNullOrEmpty(methodName)) { return(methodName); } } } String fullPathToApplication = RuntimeAugments.TryGetFullPathToMainApplication(); if (string.IsNullOrEmpty(fullPathToApplication)) { return("<unknown>"); } StringBuilder sb = new StringBuilder(); String fileNameWithoutExtension = GetFileNameWithoutExtension(fullPathToApplication); int rva = RuntimeAugments.ConvertIpToRva(ip); sb.Append(fileNameWithoutExtension); sb.Append("!<BaseAddress>+0x"); sb.Append(rva.ToString("x")); return(sb.ToString()); }
internal IntPtr GetNativeImageBase() { return(_ip - RuntimeAugments.ConvertIpToRva(_ip)); }