public PropertyReference(EvaluationContext ctx, PropertyInfo prop, CorValRef thisobj, CorType declaringType, CorValRef[] index) : base(ctx) { this.prop = prop; this.declaringType = declaringType; if (declaringType.Type == CorElementType.ELEMENT_TYPE_ARRAY || declaringType.Type == CorElementType.ELEMENT_TYPE_SZARRAY) { this.module = ((CorType)((CorEvaluationContext)ctx).Adapter.GetType(ctx, "System.Object")).Class.Module; } else { this.module = declaringType.Class.Module; } this.index = index; if (!prop.GetGetMethod(true).IsStatic) { this.thisobj = thisobj; } flags = GetFlags(prop); loader = delegate { return(((CorValRef)Value).Val); }; }
public CorExceptionObjectStackFrame(CorDebugExceptionObjectStackFrame other) { this.Module = other.pModule == null ? null : new CorModule(other.pModule); this.IP = other.ip; this.Token = other.methodDef; this.IsLastForeignExceptionFrame = other.isLastForeignExceptionFrame; }
internal DnModule(DnAssembly ownerAssembly, ICorDebugModule module, int incrementedId, int moduleOrder) { this.ownerAssembly = ownerAssembly; this.module = new CorModule(module); this.incrementedId = incrementedId; this.moduleOrder = moduleOrder; }
//methods /// <summary> /// Loop through all frames in thread getting info on them then building /// a arrayList representation of the stack trace with them /// If called when already attached it will skip attaching and detaching and let the function that called it worry about that /// otherwise this function will deal with attaching and deataching /// </summary> /// <param name="depth">How many frames deep to display, 0 means show all</param> public void UpdateStackTrace(int depth) { frameStack.Clear(); //not needed right now cause this class is remade each update bool enteredAttached = processInfo.Attached; if (!enteredAttached) { processInfo.AttachAndStop(); } try { int frameNum = 0; foreach (CorChain chain in thread.Chains) { foreach (CorFrame frame in chain.Frames) { if ((frameNum >= depth) && (depth != 0)) { break; } if (frame.Function == null) { continue; } CorModule module = frame.Function.Module; string moduleName = module.Name; CorMetadataImport importer = null; if (metaImportHash.ContainsKey(moduleName)) { importer = metaImportHash[moduleName] as CorMetadataImport; } else { //make a new importer then add it to the hash importer = new CorMetadataImport(module); metaImportHash[moduleName] = importer; } //add the next frame to the frame stack frameStack.Add(new FrameInfo(frame, importer)); frameNum++; } if ((frameNum > depth) && (depth != 0)) { break; } } } catch (COMException ex) { Debug.WriteLine(ex.ToString()); } finally { if (!enteredAttached) { processInfo.DetachAndResume(); } } }
public CorMetadataImport(CorModule managedModule) { // GUID Copied from Cor.h Guid IID_IMetadataImport = new Guid("7DAC8207-D3AE-4c75-9B67-92801A497D44"); m_importer = (IMetadataImport)managedModule.GetMetaDataInterface(IID_IMetadataImport); Debug.Assert(m_importer != null); }
internal MDbgModule(MDbgProcess process, CorModule managedModule, int number) { Debug.Assert(process != null && managedModule != null); m_process = process; m_module = managedModule; m_functions = new MDbgFunctionMgr(this); m_number = number; }
internal DbgModule TryGetModule(CorModule corModule) { if (corModule == null) return null; lock (lockObj) { if (toEngineModule.TryGetValue(corModule, out var engineModule)) return engineModule.Module; } return null; }
public static DnModule GetDnModule(CorModule module) { var dbg = DebugManager.Instance.Debugger; if (dbg == null) return null; foreach (var m in dbg.Modules) { if (m.CorModule == module) return m; } return null; }
public DnModule GetDnModule(CorModule module) { var dbg = theDebugger.Value.Debugger; if (dbg == null) return null; foreach (var m in dbg.Modules) { if (m.CorModule == module) return m; } return null; }
public DnSpyFile LoadModule(CorModule module, bool canLoadDynFile) { if (module == null) return null; var dnModule = GetDnModule(module); Debug.Assert(dnModule != null); if (dnModule != null) return LoadModule(dnModule, canLoadDynFile); return LoadModule(module.SerializedDnModule.ToSerializedDnSpyModule(), canLoadDynFile); }
public IDsDocument LoadModule(CorModule module, bool canLoadDynFile, bool isAutoLoaded) { if (module == null) return null; var dnModule = GetDnModule(module); Debug.Assert(dnModule != null); if (dnModule != null) return LoadModule(dnModule, canLoadDynFile, isAutoLoaded); return LoadModule(module.DnModuleId.ToModuleId(), canLoadDynFile, diskFileOk: false, isAutoLoaded: isAutoLoaded); }
// // IEnumerator interface // #region IEnumerator Members public bool MoveNext() { var a = new ICorDebugModule[1]; uint c = 0; int r = m_enum.Next((uint) a.Length, a, out c); if (r == 0 && c == 1) // S_OK && we got 1 new element m_mod = new CorModule(a[0]); else m_mod = null; return m_mod != null; }
internal DbgModule TryGetModule(CorModule corModul) { if (corModul == null) { return(null); } lock (lockObj) { if (toEngineModule.TryGetValue(corModul, out var engineModule)) { return(engineModule.Module); } } return(null); }
internal MDbgModule Register(CorModule managedModule) { MDbgModule mdbgModule; if (m_items.ContainsKey(managedModule)) { mdbgModule = (MDbgModule)m_items[managedModule]; return(mdbgModule); } mdbgModule = new MDbgModule(m_process, managedModule, m_freeModuleNumber++); m_items.Add(managedModule, mdbgModule); return(mdbgModule); }
public PropertyReference(EvaluationContext ctx, PropertyInfo prop, CorValRef thisobj, CorType declaringType, CorValRef[] index) : base(ctx) { this.prop = prop; this.declaringType = declaringType; this.module = declaringType.Class.Module; this.index = index; if (!prop.GetGetMethod(true).IsStatic) { this.thisobj = thisobj; } loader = delegate { return(((CorValRef)Value).Val); }; }
public IDnSpyFile LoadModule(CorModule module, bool canLoadDynFile) { if (module == null) { return(null); } var dnModule = GetDnModule(module); Debug.Assert(dnModule != null); if (dnModule != null) { return(LoadModule(dnModule, canLoadDynFile)); } return(LoadModule(module.SerializedDnModule, canLoadDynFile)); }
public DnModule GetDnModule(CorModule module) { var dbg = theDebugger.Value.Debugger; if (dbg == null) { return(null); } foreach (var m in dbg.Modules) { if (m.CorModule == module) { return(m); } } return(null); }
public IDsDocument LoadModule(CorModule module, bool canLoadDynFile, bool isAutoLoaded) { if (module == null) { return(null); } var dnModule = GetDnModule(module); Debug.Assert(dnModule != null); if (dnModule != null) { return(LoadModule(dnModule, canLoadDynFile, isAutoLoaded)); } return(LoadModule(module.DnModuleId.ToModuleId(), canLoadDynFile, diskFileOk: false, isAutoLoaded: isAutoLoaded)); }
public static DnModule GetDnModule(CorModule module) { var dbg = DebugManager.Instance.Debugger; if (dbg == null) { return(null); } foreach (var m in dbg.Modules) { if (m.CorModule == module) { return(m); } } return(null); }
/// <summary> /// Apply an edit. (Edit and Continue feature) /// </summary> /// <param name="deltaMetadataFile">File containing the Metadata delta.</param> /// <param name="deltaILFile">File containing the IL delta.</param> /// <param name="deltaPdbFile">File containing the PDB delta.</param> /// <param name="editSourceFile">The edited source file. WARNING - this param may be removed in next release.</param> public void ApplyEdit(string deltaMetadataFile, string deltaILFile, string deltaPdbFile, string editSourceFile ) { if (SymReader == null && deltaPdbFile != null) { throw new MDbgException("Cannot update symbols on module without loaded symbols."); } // read arguments from files byte[] deltaMeta; using (FileStream dmetaFile = File.OpenRead(deltaMetadataFile)) { deltaMeta = new byte[dmetaFile.Length]; dmetaFile.Read(deltaMeta, 0, deltaMeta.Length); } byte[] deltaIL; using (FileStream dilFile = File.OpenRead(deltaILFile)) { deltaIL = new byte[dilFile.Length]; dilFile.Read(deltaIL, 0, deltaIL.Length); } CorModule.ApplyChanges(deltaMeta, deltaIL); if (deltaPdbFile != null) { // apply dpdb to the symbol store. ISymbolReader sr = SymReader; (sr as SymbolStore.ISymbolReader2).UpdateSymbolStore(deltaPdbFile, null); } // save file name into of the edit if (m_editsSources == null) { Debug.Assert(EditsCounter == 0); // we don't have any edits m_editsSources = new ArrayList(); } m_editsSources.Add(editSourceFile); m_editsCounter++; }
internal void Unregister(CorModule managedModule) { Debug.Assert(m_items.ContainsKey(managedModule)); m_items.Remove(managedModule); }
internal CorOverride(CorModule module, MethodOverrideInfo info) { this.module = module; this.bodyToken = info.BodyToken; this.declToken = info.DeclToken; }
internal CorOverride(CorModule module, MethodOverrideInfo info) { this.module = module; this.bodyToken = info.BodyToken; this.declToken = info.DeclToken; }
public CorOverride(CorModule module, uint bodyToken, uint declToken) { this.module = module; this.bodyToken = bodyToken; this.declToken = declToken; }
public CorOverride(CorModule module, uint bodyToken, uint declToken) { this.Module = module; this.BodyToken = bodyToken; this.DeclToken = declToken; }
internal CorOverride(CorModule module, MethodOverrideInfo info) { Module = module; BodyToken = info.BodyToken; DeclToken = info.DeclToken; }
/// <summary> /// Looks up a CorModule. /// </summary> /// <param name="managedModule">Which CorModule to lookup.</param> /// <returns>The coresponding MDbgModule.</returns> public MDbgModule Lookup(CorModule managedModule) { return((MDbgModule)m_items[managedModule]); }
public CorMetadataImport(CorModule managedModule) { m_importer = managedModule.GetMetaDataInterface <IMetadataImport>(); Debug.Assert(m_importer != null); }
internal CorOverride(CorModule module, MethodOverrideInfo info) { Module = module; BodyToken = info.BodyToken; DeclToken = info.DeclToken; }
public CorOverride(CorModule module, uint bodyToken, uint declToken) { Module = module; BodyToken = bodyToken; DeclToken = declToken; }
public CorModuleEventArgs(CorAppDomain appDomain, CorModule managedModule) : base(appDomain) { m_managedModule = managedModule; }
static bool IsModule(CorModule module, string filename) { return module != null && !module.IsDynamic && !module.IsInMemory && StringComparer.OrdinalIgnoreCase.Equals(module.Name, filename); }
public CorModuleEventArgs(CorAppDomain appDomain, CorModule managedModule, ManagedCallbackType callbackType) : base(appDomain, callbackType) { m_managedModule = managedModule; }
public CorMetadataImport(CorModule managedModule) { m_importer = managedModule.GetMetaDataInterface<IMetadataImport>(); Debug.Assert(m_importer != null); }
/// <summary> /// Initializes a new instance of the <see cref="CorModuleLoadEventArgs"/> class. /// </summary> /// <param name="controller">The controller.</param> /// <param name="module">The module.</param> public CorModuleLoadEventArgs(CorController controller, CorModule module) : base(controller) { this.module = module; }
public CorUpdateModuleSymbolsEventArgs(CorAppDomain appDomain, CorModule managedModule, IStream stream, ManagedCallbackType callbackType) : base(appDomain, managedModule, callbackType) { m_stream = stream; }
/// <summary> /// Initializes a new instance of the <see cref="CorModuleLoadEventArgs"/> class. /// </summary> /// <param name="controller">The controller.</param> /// <param name="module">The module.</param> public CorModuleLoadEventArgs(CorController controller, CorModule module) : base(controller, "ModuleLoad") { Module = module; }
public CorUpdateModuleSymbolsEventArgs(CorAppDomain appDomain, CorModule managedModule, IStream stream) : base(appDomain, managedModule) { m_stream = stream; }
public CorOverride(CorModule module, uint bodyToken, uint declToken) { Module = module; BodyToken = bodyToken; DeclToken = declToken; }
public void Reset() { m_enum.Reset(); m_mod = null; }
internal CorActiveFunction(int ilOffset, CorFunction managedFunction, CorModule managedModule) { m_ilOffset = ilOffset; m_function = managedFunction; m_module = managedModule; }
public CorMetadataImport(CorModule managedModule) { // With a dump, m_importer may be null; metadata is not assured. m_importer = managedModule.GetMetaDataInterface <IMetadataImport>(); }
static bool IsModule(CorModule module, string filename) { return module != null && module.SerializedDnModule == new SerializedDnModule(filename); }
/// <summary> /// Returns a string that represents current frame /// Currently supported formats: /// null or empty string: returns short frame format (just frame name) /// "v" : returns long frame format (including module & arguments) /// </summary> /// <param name="format">Which format to use.</param> /// <returns>The formatted string that represtents the current frame.</returns> public override string ToString(string format) { string fn; switch (m_frame.FrameType) { case CorFrameType.ILFrame: MDbgSourcePosition sl = SourcePosition; string sp; if (sl != null) { string filePath = sl.Path; if (!Thread.m_threadMgr.m_process.m_engine.Options.ShowFullPaths) { filePath = Path.GetFileName(sl.Path); } sp = " (" + filePath + ":" + sl.Line.ToString(System.Globalization.CultureInfo.CurrentUICulture) + ")"; } else { sp = " (source line information unavailable)"; } StringBuilder sbFuncName = new StringBuilder(); MDbgModule module = this.Function.Module; MDbgProcess proc = Thread.m_threadMgr.m_process; // Get class name w/ generic args. CorType tClass = this.FunctionType; if (tClass != null) { InternalUtil.PrintCorType(sbFuncName, proc, tClass); } sbFuncName.Append('.'); // Get method name w/ generic args. MethodInfo mi = this.Function.MethodInfo; sbFuncName.Append(mi.Name); InternalUtil.AddGenericArgs(sbFuncName, proc, this.FunctionTypeParameters); string stFuncName = sbFuncName.ToString(); if (format == "v") { CorModule m = module.CorModule; // verbose frame output // in verbose output we'll print module name + arguments to the functions StringBuilder sb = new StringBuilder(); bool bFirst = true; foreach (MDbgValue v in this.Function.GetArguments(this)) { if (sb.Length != 0) { sb.Append(", "); } // skip this references if (!(bFirst && v.Name == "this")) { sb.Append(v.Name).Append("=").Append(v.GetStringValue(0)); } bFirst = false; } if (m.IsDynamic || m.IsInMemory) { fn = m.Name; } else { fn = System.IO.Path.GetFileName(m.Name); } MDbgAppDomain ad = this.Thread.m_threadMgr.m_process.AppDomains.Lookup(m.Assembly.AppDomain); fn += "#" + ad.Number + "!" + stFuncName + "(" + sb.ToString() + ") " + sp; } else { fn = stFuncName + sp; } break; case CorFrameType.NativeFrame: fn = "[IL Method without Metadata]"; break; case CorFrameType.InternalFrame: switch (m_frame.InternalFrameType) { case CorDebugInternalFrameType.STUBFRAME_NONE: fn = "None"; break; case CorDebugInternalFrameType.STUBFRAME_M2U: fn = "M-->U"; break; case CorDebugInternalFrameType.STUBFRAME_U2M: fn = "U-->M"; break; case CorDebugInternalFrameType.STUBFRAME_APPDOMAIN_TRANSITION: fn = "AD Switch"; break; case CorDebugInternalFrameType.STUBFRAME_LIGHTWEIGHT_FUNCTION: fn = "LightWeight"; break; case CorDebugInternalFrameType.STUBFRAME_FUNC_EVAL: fn = "FuncEval"; break; case CorDebugInternalFrameType.STUBFRAME_INTERNALCALL: fn = "InternalCall"; break; case CorDebugInternalFrameType.STUBFRAME_CLASS_INIT: fn = "ClassInit"; break; case CorDebugInternalFrameType.STUBFRAME_EXCEPTION: fn = "Exception"; break; case CorDebugInternalFrameType.STUBFRAME_SECURITY: fn = "Security"; break; case CorDebugInternalFrameType.STUBFRAME_JIT_COMPILATION: fn = "JitCompilation"; break; default: fn = "UNKNOWN"; break; } fn = "[Internal Frame, '" + fn + "']"; break; default: fn = "UNKNOWN Frame Type"; break; } return(fn); }
bool IsOurModule(CorModule module) { return IsModule(module, filename); }
bool IsOurModule(CorModule module) => IsModule(module, filename);