// This returns null when called before the first AssemblyLoad event
		public AssemblyMirror GetEntryAssembly () {
			if (entry_assembly == null) {
				long ass_id = vm.conn.Domain_GetEntryAssembly (id);

				entry_assembly = vm.GetAssembly (ass_id);
			}
			return entry_assembly;
	    }
		// Not cached
		public AssemblyMirror[] GetAssemblies () {
			long[] ids = vm.conn.Domain_GetAssemblies (id);
			AssemblyMirror[] assemblies = new AssemblyMirror [ids.Length];
			// FIXME: Uniqueness
			for (int i = 0; i < ids.Length; ++i)
				assemblies [i] = vm.GetAssembly (ids [i]);
			return assemblies;
	    }
Example #3
0
        private IAssemblyMirror DebugAssemblyFor(Mono.Debugger.Soft.AssemblyMirror assemblyMirror)
        {
            var debugAssembly = _debugAssemblies.SingleOrDefault(da => da.Mirror == assemblyMirror);

            if (debugAssembly != null)
            {
                return(debugAssembly);
            }

            debugAssembly = new SdbAssemblyMirror(assemblyMirror);
            _debugAssemblies.Add(debugAssembly);
            return(debugAssembly);
        }
Example #4
0
 internal AssemblyMirror GetAssembly(long id)
 {
     lock (assemblies_lock) {
         if (assemblies == null)
         {
             assemblies = new Dictionary <long, AssemblyMirror> ();
         }
         AssemblyMirror obj;
         if (id == 0)
         {
             return(null);
         }
         if (!assemblies.TryGetValue(id, out obj))
         {
             obj             = new AssemblyMirror(this, id);
             assemblies [id] = obj;
         }
         return(obj);
     }
 }
Example #5
0
        void MarkAssembly( AssemblyMirror a )
        {
            var asmname = a.GetName();
            var name = asmname.FullName;
            if ( loadedAssemblies.Contains( name ) ) return;
            bool loadAll = false;
            if ( assemblyMatchers.Contains( asmname.Name ) ) loadAll = true;

            var afile = a.Location;
            Log ("load assembly {0} from {1}", name, afile);

            if ( File.Exists( afile ) ){
                Log ("inspecting {0} for types", afile );
                try {
                    var asm = System.Reflection.Assembly.ReflectionOnlyLoadFrom( afile );
                    loadedAssemblies.Add( name );
                    if ( asm != null ){
                        Log ("loaded {0}", afile);
                        foreach ( var t in asm.GetTypes() )
                        {
                            if ( loadAll || MatchType( t ) ) 
                            {
                                Log ("matched type {0}", t.FullName);
                                MarkLoadedType( a, t );
                            }
                        }
                    }
                } catch ( System.Reflection.ReflectionTypeLoadException ) {
                    Log ("warning: could not load types from {0}", afile );
                    loadedAssemblies.Add( name ); // don't try again
                } finally {

                }

            } else {
                Log ("assembly file {0} missing", afile);
            }

        }
Example #6
0
        private void ProcessLoadedAssembly(Mono.Debugger.Soft.AssemblyMirror assembly)
        {
            var hasDebugSymbols = HasDebugSymbols(assembly);

            Trace("AssemblyLoad: {0}", assembly.GetName().FullName);
            Trace("\tHasDebugSymbols: {0}", hasDebugSymbols);

            if (!hasDebugSymbols || !IsUserCode(assembly))
            {
                return;
            }

            _loadedAssemblies.Add(assembly);

            var wasEnabled = _methodEntryRequest.Enabled;

            _methodEntryRequest.Disable();
            _methodEntryRequest.AssemblyFilter = _loadedAssemblies;
            if (wasEnabled)
            {
                _methodEntryRequest.Enable();
            }
        }
		bool UpdateAssemblyFilters (AssemblyMirror asm)
		{
			var name = asm.GetName ().FullName;
			if (userAssemblyNames != null) {
				//HACK: not sure how else to handle xsp-compiled pages
				if (name.StartsWith ("App_")) {
					assemblyFilters.Add (asm);
					return true;
				}
			
				foreach (var n in userAssemblyNames) {
					if (n == name) {
						assemblyFilters.Add (asm);
						return true;
					}
				}
			}
			return false;
		}
Example #8
0
 private static bool HasDebugSymbols(Mono.Debugger.Soft.AssemblyMirror assembly)
 {
     return(File.Exists(assembly.ManifestModule.FullyQualifiedName + ".mdb"));
 }
Example #9
0
 private static bool IsUserCode(Mono.Debugger.Soft.AssemblyMirror assembly)
 {
     return(assembly.GetName().Name.StartsWith("SdbAssemblyMirror-"));
 }
Example #10
0
 public SdbAssemblyMirror(AssemblyMirror assemblyMirror)
     : base(assemblyMirror)
 {
 }
		bool UpdateAssemblyFilters (AssemblyMirror asm)
		{
			var name = asm.GetName ().FullName;
			bool found = false;
			if (userAssemblyNames != null) {
				//HACK: not sure how else to handle xsp-compiled pages
				if (name.StartsWith ("App_")) {
					found = true;
				} else {
					foreach (var n in userAssemblyNames) {
						if (n == name) {
							found = true;
						}
					}
				}
			}
			if (found) {
				assemblyFilters.Add (asm);
				unhandledExceptionRequest.Disable ();
				unhandledExceptionRequest.AssemblyFilter = assemblyFilters;
				unhandledExceptionRequest.Enable ();
				return true;
			} else {
				return false;
			}
		}
Example #12
0
        private void DoShowInfo(AssemblyMirror assembly, System.Text.StringBuilder builder)
        {
            CodeViewer.CacheAssembly(assembly);

            if (assembly.Metadata != null)
            {
                builder.AppendLine(string.Format("Architecture: {0}", assembly.Metadata.MainModule.Architecture));
                builder.AppendLine(string.Format("Assembly: {0}", assembly.Metadata.Name.Name));
                builder.AppendLine(string.Format("Attributes: {0}", assembly.Metadata.Name.Attributes));
                builder.AppendLine(string.Format("Culture: {0}", !string.IsNullOrEmpty(assembly.Metadata.Name.Culture) ? assembly.Metadata.Name.Culture : "neutral"));
                builder.AppendLine(string.Format("Hash: {0}", assembly.Metadata.Name.Hash != null && assembly.Metadata.Name.Hash.Length > 0 ? BitConverter.ToString(assembly.Metadata.Name.Hash) : "none"));
                builder.AppendLine(string.Format("HashAlgorithm: {0}", assembly.Metadata.Name.HashAlgorithm));
                builder.AppendLine(string.Format("Kind: {0}", assembly.Metadata.MainModule.Kind));
                builder.AppendLine(string.Format("PublicKey: {0}", assembly.Metadata.Name.PublicKey != null && assembly.Metadata.Name.PublicKey.Length > 0 ? BitConverter.ToString(assembly.Metadata.Name.PublicKey) : "none"));
                builder.AppendLine(string.Format("PublicKeyToken: {0}", assembly.Metadata.Name.PublicKeyToken != null ? BitConverter.ToString(assembly.Metadata.Name.PublicKeyToken) : "none"));
                builder.AppendLine(string.Format("Qualified Name: {0}", assembly.Metadata.MainModule.FullyQualifiedName));
                builder.AppendLine(string.Format("Runtime: {0}", assembly.Metadata.MainModule.Runtime));
                builder.AppendLine(string.Format("Version: {0}", assembly.Metadata.Name.Version));
            }

            builder.AppendLine(string.Format("Location: {0}", assembly.Location));
        }
Example #13
0
        void MarkLoadedType( AssemblyMirror a, Type t )
        {
            if ( loadedTypes.Contains( t.FullName ) ) return;

            var tm = a.GetType( t.FullName );

            Log("adding reflected matched type {0}",tm.FullName);

            MarkType( tm );

        }