public static CorDebugFunction CorDebugFunctionFromMethodIndex(uint methodIndex, CorDebugAppDomain appDomain) { CorDebugFunction function = null; CorDebugAssembly assembly = appDomain.AssemblyFromIdx(TinyCLR_TypeSystem.IdxAssemblyFromIndex(methodIndex)); if (assembly != null) { uint tk = TinyCLR_TypeSystem.TinyCLRTokenFromMethodIndex(methodIndex); function = assembly.GetFunctionFromTokenTinyCLR(tk); } return(function); }
public static CorDebugClass CorDebugClassFromTypeIndex(uint typeIndex, CorDebugAppDomain appDomain) { CorDebugClass cls = null; CorDebugAssembly assembly = appDomain.AssemblyFromIdx(TinyCLR_TypeSystem.IdxAssemblyFromIndex(typeIndex)); if (assembly != null) { uint typedef = TinyCLR_TypeSystem.CLR_TkFromType(TinyCLR_TypeSystem.CLR_TABLESENUM.TBL_TypeDef, TinyCLR_TypeSystem.IdxFromIndex(typeIndex)); cls = assembly.GetClassFromTokenTinyCLR(typedef); } return(cls); }
private void AddBuiltInType (object o, CorDebugAssembly assm, string type) { uint tkCLR = assm.MetaData.Types.First (t => t.FullName == type).MetadataToken.ToUInt32 (); CorDebugClass c = assm.GetClassFromTokenCLR (tkCLR); BuiltinType builtInType = new BuiltinType (assm, tkCLR, c); m_tdBuiltin [o] = builtInType; }
public static uint ClassMemberIndexFromCLRToken (uint token, CorDebugAssembly assembly) { Pdbx.ClassMember cm = assembly.GetPdbxClassMemberFromTokenCLR (token); return ClassMemberIndexFromTinyCLRToken (cm.Token.TinyCLR, assembly); }
public ManagedCallbackAssembly(CorDebugAssembly assembly, EventType eventType) { m_assembly = assembly; m_eventType = eventType; }
public static uint ClassMemberIndexFromTinyCLRToken(uint token, CorDebugAssembly assembly) { uint idx = TinyCLR_TypeSystem.CLR_DataFromTk(token); return(TinyCLR_TypeSystem.IndexFromIdxAssemblyIdx(assembly.Idx, idx)); }
public CorDebugClass(CorDebugAssembly assembly, Pdbx.Class cls) { m_assembly = assembly; m_pdbxClass = cls; }
public CorDebugClass (CorDebugAssembly assembly, uint tkSymbolless) : this(assembly, null) { m_tkSymbolless = tkSymbolless; }
int ICorDebugManagedCallback.UnloadModule (CorDebugAppDomain pAppDomain, CorDebugAssembly pModule) { return 0; }
int ICorDebugManagedCallback.LoadModule (CorDebugAppDomain pAppDomain, CorDebugAssembly pModule) { pAppDomain.Process.Continue (); return 0; }
public PropertyValueReference (EvaluationContext ctx, PropertyDefinition prop, CorValRef thisobj, CorDebugType declaringType, CorValRef[] index) : base (ctx) { this.prop = prop; this.declaringType = declaringType; this.module = declaringType.Class.Assembly; this.index = index; if (!prop.GetMethod.IsStatic) this.thisobj = thisobj; flags = GetFlags (prop); loader = delegate { return ((CorValRef)Value).Val; }; }
public bool UpdateAssemblies() { uint[] assemblies = null; List <ManagedCallbacks.ManagedCallback> callbacks = new System.Collections.Generic.List <ManagedCallbacks.ManagedCallback> (); if (this.Process.Engine.Capabilities.AppDomains) { WireProtocol.Commands.Debugging_Resolve_AppDomain.Reply reply = this.Process.Engine.ResolveAppDomain(m_id); if (reply != null) { m_name = reply.Name; assemblies = reply.m_data; } if (assemblies == null) { //assembly is already unloaded assemblies = new uint[0]; } } else { WireProtocol.Commands.Debugging_Resolve_Assembly[] reply = this.Process.Engine.ResolveAllAssemblies(); assemblies = new uint[reply.Length]; for (int iAssembly = 0; iAssembly < assemblies.Length; iAssembly++) { assemblies [iAssembly] = reply [iAssembly].m_idx; } } //Convert Assembly Index to Idx. for (uint iAssembly = 0; iAssembly < assemblies.Length; iAssembly++) { assemblies [iAssembly] = TinyCLR_TypeSystem.IdxAssemblyFromIndex(assemblies [iAssembly]); } //Unload dead assemblies for (int iAssembly = m_assemblies.Count - 1; iAssembly >= 0; iAssembly--) { CorDebugAssembly assembly = (CorDebugAssembly)m_assemblies [iAssembly]; if (Array.IndexOf(assemblies, assembly.Idx) < 0) { callbacks.Add(new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.UnloadModule)); callbacks.Add(new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.UnloadAssembly)); m_assemblies.RemoveAt(iAssembly); } } //Load new assemblies for (int i = 0; i < assemblies.Length; i++) { uint idx = assemblies [i]; CorDebugAssembly assembly = AssemblyFromIdx(idx); if (assembly == null) { //Get the primary assembly from CorDebugProcess assembly = this.Process.AssemblyFromIdx(idx); Debug.Assert(assembly != null); //create a new CorDebugAssemblyInstance assembly = assembly.CreateAssemblyInstance(this); Debug.Assert(assembly != null); m_assemblies.Add(assembly); //cpde expects mscorlib to be the first assembly it hears about int index = (assembly.Name == "mscorlib") ? 0 : callbacks.Count; callbacks.Insert(index, new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.LoadAssembly)); callbacks.Insert(index + 1, new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.LoadModule)); } } this.Process.EnqueueEvents(callbacks); return(callbacks.Count > 0); }
public CorDebugAssembly AssemblyFromIndex(uint index) { return(CorDebugAssembly.AssemblyFromIndex(index, m_assemblies)); }
public CorDebugAssembly AssemblyFromIdx(uint idx) { return(CorDebugAssembly.AssemblyFromIdx(idx, m_assemblies)); }
public CorDebugAssembly( CorDebugProcess process, string name, Pdbx.PdbxFile pdbxFile, uint idx ) { m_process = process; m_appDomain = null; m_name = name; m_pdbxFile = pdbxFile; m_pdbxAssembly = (pdbxFile != null) ? pdbxFile.Assembly : null; m_htTokenCLRToPdbx = new Hashtable(); m_htTokenTinyCLRToPdbx = new Hashtable(); m_idx = idx; m_primaryAssembly = null; m_isFrameworkAssembly = false; if(m_pdbxAssembly != null) { if (!string.IsNullOrEmpty(pdbxFile.PdbxPath)) { string pth = pdbxFile.PdbxPath.ToLower(); if (pth.Contains(@"\buildoutput\")) { #region V4_1_FRAMEWORK_ASSEMBLIES List<string> frameworkAssemblies = new List<string> { "mfdpwsclient", "mfdpwsdevice", "mfdpwsextensions", "mfwsstack", "microsoft.spot.graphics", "microsoft.spot.hardware", "microsoft.spot.hardware.serialport", "microsoft.spot.hardware.usb", "microsoft.spot.ink", "microsoft.spot.io", "microsoft.spot.native", "microsoft.spot.net", "microsoft.spot.net.security", "microsoft.spot.time", "microsoft.spot.tinycore", "microsoft.spot.touch", "mscorlib", "system.http", "system.io", "system.net.security", "system", "system.xml.legacy", "system.xml", }; #endregion // V4_1_FRAMEWORK_ASSEMBLIES m_isFrameworkAssembly = (frameworkAssemblies.Contains(name.ToLower())); } else { m_isFrameworkAssembly = pdbxFile.PdbxPath.ToLower().Contains(@"\microsoft .net micro framework\"); } } m_pdbxAssembly.CorDebugAssembly = this; foreach(Pdbx.Class c in m_pdbxAssembly.Classes) { AddTokenToHashtables( c.Token, c ); foreach(Pdbx.Field field in c.Fields) { AddTokenToHashtables( field.Token, field ); } foreach(Pdbx.Method method in c.Methods) { AddTokenToHashtables( method.Token, method ); } } } }
int ICorDebugManagedCallback.LoadAssembly (CorDebugAppDomain pAppDomain, CorDebugAssembly pAssembly) { assemblies.Add (pAssembly); //CorMetadataImport mi = new CorMetadataImport(pAssembly); //Seems like this is always set on MicroFramework //pAssembly. JITCompilerFlags = CorDebugJITCompilerFlags.CORDEBUG_JIT_DISABLE_OPTIMIZATION; List<string> docPaths = new List<string> (); if (pAssembly.DebugData != null) { var md = pAssembly.MetaData; var reader = pAssembly.DebugData; if (!pAssembly.IsFrameworkAssembly) { foreach (var module in md.Assembly.Modules) { foreach (var t in module.Types) { foreach (var m in t.Methods) { var methodSymbols = new MethodSymbols (m.MetadataToken); //Ugly hack if(reader is Mono.Cecil.Mdb.MdbReader) { foreach(var variable in m.Body.Variables) methodSymbols.Variables.Add(variable); } reader.Read (methodSymbols); if (methodSymbols.Instructions.Count == 0) continue; DocInfo document; if (!documents.TryGetValue (methodSymbols.Instructions [0].SequencePoint.Document.Url, out document)) { document = new DocInfo (methodSymbols.Instructions [0].SequencePoint.Document.Url); document.Assembly = pAssembly; documents.Add (document.Url, document); } document.AddMethod (m, methodSymbols); if (!docPaths.Contains (document.Url)) docPaths.Add (document.Url); } } } } pAssembly.SetJmcStatus (true); } else { // Flag modules without debug info as not JMC. In this way // the debugger won't try to step into them pAssembly.SetJmcStatus (false); } foreach (var docPath in docPaths) BindSourceFileBreakpoints (docPath); pAppDomain.Process.Continue (); return 0; }
public ManagedCallbackAssembly (CorDebugAssembly assembly, EventType eventType) { m_assembly = assembly; m_eventType = eventType; }
int ICorDebugManagedCallback.UnloadAssembly (CorDebugAppDomain pAppDomain, CorDebugAssembly pAssembly) { assemblies.Remove (pAssembly); return 0; }
public CorDebugClass(CorDebugAssembly assembly, uint tkSymbolless) : this(assembly, null) { m_tkSymbolless = tkSymbolless; }
public CorDebugAssembly(CorDebugProcess process, string name, Pdbx.PdbxFile pdbxFile, uint idx) { m_process = process; m_appDomain = null; m_name = name; m_pdbxFile = pdbxFile; m_pdbxAssembly = (pdbxFile != null) ? pdbxFile.Assembly : null; m_htTokenCLRToPdbx = new Hashtable(); m_htTokenTinyCLRToPdbx = new Hashtable(); m_idx = idx; m_primaryAssembly = null; m_isFrameworkAssembly = false; if (m_pdbxAssembly != null) { if (!string.IsNullOrEmpty(pdbxFile.PdbxPath)) { string pth = pdbxFile.PdbxPath.ToLower(); if (pth.Contains(@"\buildoutput\")) { #region V4_1_FRAMEWORK_ASSEMBLIES List <string> frameworkAssemblies = new List <string> { "mfdpwsclient", "mfdpwsdevice", "mfdpwsextensions", "mfwsstack", "microsoft.spot.graphics", "microsoft.spot.hardware", "microsoft.spot.hardware.serialport", "microsoft.spot.hardware.usb", "microsoft.spot.ink", "microsoft.spot.io", "microsoft.spot.native", "microsoft.spot.net", "microsoft.spot.net.security", "microsoft.spot.time", "microsoft.spot.tinycore", "microsoft.spot.touch", "mscorlib", "system.http", "system.io", "system.net.security", "system", "system.xml.legacy", "system.xml", }; #endregion // V4_1_FRAMEWORK_ASSEMBLIES m_isFrameworkAssembly = (frameworkAssemblies.Contains(name.ToLower())); } else { m_isFrameworkAssembly = pdbxFile.PdbxPath.ToLower().Contains(@"\microsoft .net micro framework\"); } } m_pdbxAssembly.CorDebugAssembly = this; foreach (Pdbx.Class c in m_pdbxAssembly.Classes) { AddTokenToHashtables(c.Token, c); foreach (Pdbx.Field field in c.Fields) { AddTokenToHashtables(field.Token, field); } foreach (Pdbx.Method method in c.Methods) { AddTokenToHashtables(method.Token, method); } } } }
public static uint ClassMemberIndexFromCLRToken(uint token, CorDebugAssembly assembly) { Pdbx.ClassMember cm = assembly.GetPdbxClassMemberFromTokenCLR(token); return(ClassMemberIndexFromTinyCLRToken(cm.Token.TinyCLR, assembly)); }
internal ulong FakeLoadAssemblyIntoMemory( CorDebugAssembly assembly ) { ulong address = m_fakeAssemblyAddressNext; uint size; assembly.ICorDebugModule.GetSize(out size); m_fakeAssemblyAddressNext += size; return address; }
private void LoadAssemblies() { VsPackage.MessageCentre.DebugMsg(DiagnosticStrings.LoadAssemblies); WireProtocol.Commands.Debugging_Resolve_Assembly[] assemblies = Engine.ResolveAllAssemblies(); string[] assemblyPathsT = new string[1]; Pdbx.PdbxFile.Resolver resolver = new Pdbx.PdbxFile.Resolver(); if (!m_fLaunched || !this.IsLocalWin32Process) { //Find mscorlib WireProtocol.Commands.Debugging_Resolve_Assembly a = null; WireProtocol.Commands.Debugging_Resolve_Assembly.Reply reply = null; for (int i = 0; i < assemblies.Length; i++) { a = assemblies[i]; reply = a.m_reply; if (reply.Name == "mscorlib") break; } DebugAssert(reply.Name == "mscorlib"); //Add assemblyDirectories string asyVersion = "v4.3"; if(AssemblyPaths != null) { Regex versionExpr = new Regex(@"\\(v[\d]+\.[\d]+)\\"); for(int i=0; i<AssemblyPaths.Length; i++) { Match m = versionExpr.Match(AssemblyPaths[i]); if (m.Success) { asyVersion = m.Groups[1].Value; break; } } } PlatformInfo platformInfo = new PlatformInfo(asyVersion); // by not spcifying any runtime information, we will look for the most suitable version resolver.AssemblyDirectories = platformInfo.AssemblyFolders; } for(int i = 0; i < assemblies.Length; i++) { WireProtocol.Commands.Debugging_Resolve_Assembly a = assemblies[i]; CorDebugAssembly assembly = this.AssemblyFromIdx( a.m_idx ); if(assembly == null) { WireProtocol.Commands.Debugging_Resolve_Assembly.Reply reply = a.m_reply; if (!string.IsNullOrEmpty(reply.Path)) { assemblyPathsT[0] = reply.Path; resolver.AssemblyPaths = assemblyPathsT; } else { resolver.AssemblyPaths = m_assemblyPaths; } Pdbx.PdbxFile pdbxFile = resolver.Resolve(reply.Name, reply.m_version, Engine.IsTargetBigEndian); //Pdbx.PdbxFile.Open(reply.Name, reply.m_version, assemblyPaths); assembly = new CorDebugAssembly(this, reply.Name, pdbxFile, TinyCLR_TypeSystem.IdxAssemblyFromIndex(a.m_idx)); m_assemblies.Add( assembly ); } } }
public BuiltinType( CorDebugAssembly assembly, uint tkCLR, CorDebugClass cls ) { this.m_assembly = assembly; this.m_tkCLR = tkCLR; this.m_class = cls; }
public CorDebugAssembly(CorDebugProcess process, string name, Pdbx.PdbxFile pdbxFile, uint idx) { m_process = process; m_appDomain = null; m_name = name; m_pdbxFile = pdbxFile; m_pdbxAssembly = (pdbxFile != null) ? pdbxFile.Assembly : null; m_htTokenCLRToPdbx = new Hashtable(); m_htTokenTinyCLRToPdbx = new Hashtable(); m_idx = idx; m_primaryAssembly = null; m_isFrameworkAssembly = false; if (m_pdbxAssembly != null) { if (!string.IsNullOrEmpty(pdbxFile.PdbxPath)) { string pth = pdbxFile.PdbxPath.ToLower(); if (pth.Contains(Path.DirectorySeparatorChar + "buildoutput" + Path.DirectorySeparatorChar)) { #region V4_1_FRAMEWORK_ASSEMBLIES List <string> frameworkAssemblies = new List <string> { "mfdpwsclient", "mfdpwsdevice", "mfdpwsextensions", "mfwsstack", "microsoft.spot.graphics", "microsoft.spot.hardware", "microsoft.spot.hardware.serialport", "microsoft.spot.hardware.usb", "microsoft.spot.ink", "microsoft.spot.io", "microsoft.spot.native", "microsoft.spot.net", "microsoft.spot.net.security", "microsoft.spot.time", "microsoft.spot.tinycore", "microsoft.spot.touch", "mscorlib", "system.http", "system.io", "system.net.security", "system", "system.xml.legacy", "system.xml", }; #endregion // V4_1_FRAMEWORK_ASSEMBLIES m_isFrameworkAssembly = (frameworkAssemblies.Contains(name.ToLower())); } else { m_isFrameworkAssembly = pdbxFile.PdbxPath.ToLower().Contains(Path.PathSeparator + ".net micro framework" + Path.PathSeparator); } } m_pdbxAssembly.CorDebugAssembly = this; foreach (Pdbx.Class c in m_pdbxAssembly.Classes) { AddTokenToHashtables(c.Token, c); foreach (Pdbx.Field field in c.Fields) { AddTokenToHashtables(field.Token, field); } foreach (Pdbx.Method method in c.Methods) { AddTokenToHashtables(method.Token, method); } } if (File.Exists(Path.ChangeExtension(m_pdbxFile.PdbxPath, ".dll"))) { MetaData = ModuleDefinition.ReadModule(Path.ChangeExtension(m_pdbxFile.PdbxPath, ".dll")); } else if (File.Exists(Path.ChangeExtension(m_pdbxFile.PdbxPath, ".exe"))) { MetaData = ModuleDefinition.ReadModule(Path.ChangeExtension(m_pdbxFile.PdbxPath, ".exe")); } if (MetaData != null && File.Exists(Path.ChangeExtension(m_pdbxFile.PdbxPath, ".exe.mdb"))) { DebugData = new Mono.Cecil.Mdb.MdbReaderProvider().GetSymbolReader(MetaData, Path.ChangeExtension(m_pdbxFile.PdbxPath, ".exe")); MetaData.ReadSymbols(DebugData); } else if (MetaData != null && File.Exists(Path.ChangeExtension(m_pdbxFile.PdbxPath, ".dll.mdb"))) { DebugData = new Mono.Cecil.Mdb.MdbReaderProvider().GetSymbolReader(MetaData, Path.ChangeExtension(m_pdbxFile.PdbxPath, ".dll")); MetaData.ReadSymbols(DebugData); } } }
private void AddBuiltInType(object o, CorDebugAssembly assm, string type) { uint tkCLR = MetaData.Helper.ClassTokenFromName(assm.MetaDataImport, type); CorDebugClass c = assm.GetClassFromTokenCLR(tkCLR); BuiltinType builtInType = new BuiltinType( assm, tkCLR, c ); m_tdBuiltin[o] = builtInType; }
public static uint ClassMemberIndexFromTinyCLRToken (uint token, CorDebugAssembly assembly) { uint idx = TinyCLR_TypeSystem.CLR_DataFromTk (token); return TinyCLR_TypeSystem.IndexFromIdxAssemblyIdx (assembly.Idx, idx); }
public CorDebugAssembly (CorDebugProcess process, string name, Pdbx.PdbxFile pdbxFile, uint idx) { m_process = process; m_appDomain = null; m_name = name; m_pdbxFile = pdbxFile; m_pdbxAssembly = (pdbxFile != null) ? pdbxFile.Assembly : null; m_htTokenCLRToPdbx = new Hashtable (); m_htTokenTinyCLRToPdbx = new Hashtable (); m_idx = idx; m_primaryAssembly = null; m_isFrameworkAssembly = false; if (m_pdbxAssembly != null) { if (!string.IsNullOrEmpty (pdbxFile.PdbxPath)) { string pth = pdbxFile.PdbxPath.ToLower (); if (pth.Contains (@"\buildoutput\")) { #region V4_1_FRAMEWORK_ASSEMBLIES List<string> frameworkAssemblies = new List<string> { "mfdpwsclient", "mfdpwsdevice", "mfdpwsextensions", "mfwsstack", "microsoft.spot.graphics", "microsoft.spot.hardware", "microsoft.spot.hardware.serialport", "microsoft.spot.hardware.usb", "microsoft.spot.ink", "microsoft.spot.io", "microsoft.spot.native", "microsoft.spot.net", "microsoft.spot.net.security", "microsoft.spot.time", "microsoft.spot.tinycore", "microsoft.spot.touch", "mscorlib", "system.http", "system.io", "system.net.security", "system", "system.xml.legacy", "system.xml", }; #endregion // V4_1_FRAMEWORK_ASSEMBLIES m_isFrameworkAssembly = (frameworkAssemblies.Contains (name.ToLower ())); } else { m_isFrameworkAssembly = pdbxFile.PdbxPath.ToLower().Contains(Path.PathSeparator + ".net micro framework" + Path.PathSeparator); } } m_pdbxAssembly.CorDebugAssembly = this; foreach (Pdbx.Class c in m_pdbxAssembly.Classes) { AddTokenToHashtables (c.Token, c); foreach (Pdbx.Field field in c.Fields) { AddTokenToHashtables (field.Token, field); } foreach (Pdbx.Method method in c.Methods) { AddTokenToHashtables (method.Token, method); } } if (File.Exists (Path.ChangeExtension (m_pdbxFile.PdbxPath, ".dll"))) MetaData = ModuleDefinition.ReadModule (Path.ChangeExtension (m_pdbxFile.PdbxPath, ".dll")); else if (File.Exists (Path.ChangeExtension (m_pdbxFile.PdbxPath, ".exe"))) MetaData = ModuleDefinition.ReadModule (Path.ChangeExtension (m_pdbxFile.PdbxPath, ".exe")); if (MetaData != null && File.Exists (Path.ChangeExtension (m_pdbxFile.PdbxPath, ".pdb"))) { DebugData = new Mono.Cecil.Pdb.PdbReaderProvider ().GetSymbolReader (MetaData, Path.ChangeExtension (m_pdbxFile.PdbxPath, ".pdb")); MetaData.ReadSymbols (DebugData); } else if (MetaData != null && File.Exists (Path.ChangeExtension (m_pdbxFile.PdbxPath, ".exe.mdb"))) { DebugData = new Mono.Cecil.Mdb.MdbReaderProvider ().GetSymbolReader (MetaData, Path.ChangeExtension (m_pdbxFile.PdbxPath, ".exe")); MetaData.ReadSymbols (DebugData); } else if (MetaData != null && File.Exists (Path.ChangeExtension (m_pdbxFile.PdbxPath, ".dll.mdb"))) { DebugData = new Mono.Cecil.Mdb.MdbReaderProvider ().GetSymbolReader (MetaData, Path.ChangeExtension (m_pdbxFile.PdbxPath, ".dll")); MetaData.ReadSymbols (DebugData); } } }