ModuleCreator(DbgEngineImpl engine, DbgObjectFactory objectFactory, DbgAppDomain appDomain, ModuleMirror monoModule, int moduleOrder) { this.engine = engine; this.objectFactory = objectFactory; this.appDomain = appDomain; this.monoModule = monoModule; this.moduleOrder = moduleOrder; moduleAddress = 0; moduleSize = 0; isDynamic = false; isInMemory = false; }
// This must match the code in CorDebug public static ModuleId Create(DbgModule module, ModuleMirror monoModule) { // CorDebug also uses AssemblyNameInfo to get the asm full name. It's possible that // AssemblyName (monoModule.Assembly.GetName()) returns a slightly different string // for some input. var asmFullName = new AssemblyNameInfo(monoModule.Assembly.GetName()).FullName; string moduleName; uint id = (uint)module.Order; if (module.IsInMemory || module.IsDynamic) { moduleName = monoModule.ScopeName + " (id=" + id.ToString() + ")"; } else { moduleName = module.Filename; } return(new ModuleId(asmFullName, moduleName, module.IsDynamic, module.IsInMemory, false)); }
public static DbgEngineModule CreateModule <T>(DbgEngineImpl engine, DbgObjectFactory objectFactory, DbgAppDomain appDomain, ModuleMirror monoModule, int moduleOrder, T data) where T : class => new ModuleCreator(engine, objectFactory, appDomain, monoModule, moduleOrder).CreateModuleCore(data);
void EnableBreakpoints(ModuleMirror monoModule, DbgModule module, List <DbgDotNetCodeLocation> moduleLocations) { debuggerThread.VerifyAccess(); if (moduleLocations.Count == 0) { return; } var createdBreakpoints = new DbgBoundCodeBreakpointInfo <BoundBreakpointData> [moduleLocations.Count]; var reflectionModule = module.GetReflectionModule(); var state = module.GetOrCreateData <TypeLoadBreakpointState>(); for (int i = 0; i < createdBreakpoints.Length; i++) { var location = moduleLocations[i]; const ulong address = DbgObjectFactory.BoundBreakpointNoAddress; DbgEngineBoundCodeBreakpointMessage msg; var method = reflectionModule.ResolveMethod((int)location.Token, DmdResolveOptions.None); if ((object)method == null) { msg = DbgEngineBoundCodeBreakpointMessage.CreateFunctionNotFound(GetFunctionName(location.Module, location.Token)); } else { msg = state.IsTypeLoaded(method.DeclaringType.MetadataToken) ? DbgEngineBoundCodeBreakpointMessage.CreateCustomWarning(dnSpy_Debugger_DotNet_Mono_Resources.CanNotSetABreakpointWhenProcessIsPaused) : DbgEngineBoundCodeBreakpointMessage.CreateNoError(); } var bpData = new BoundBreakpointData(this, location.Module); createdBreakpoints[i] = new DbgBoundCodeBreakpointInfo <BoundBreakpointData>(location, module, address, msg, bpData); } var boundBreakpoints = objectFactory.Create(createdBreakpoints.ToArray()); foreach (var ebp in boundBreakpoints) { if (!ebp.BoundCodeBreakpoint.TryGetData(out BoundBreakpointData bpData)) { Debug.Assert(ebp.BoundCodeBreakpoint.IsClosed); continue; } bpData.EngineBoundCodeBreakpoint = ebp; if (bpData.Breakpoint != null) { bpData.Breakpoint.Tag = bpData; } } for (int i = 0; i < boundBreakpoints.Length; i++) { var boundBp = boundBreakpoints[i]; var location = (DbgDotNetCodeLocation)boundBp.BoundCodeBreakpoint.Breakpoint.Location; var method = reflectionModule.ResolveMethod((int)location.Token, DmdResolveOptions.None); if ((object)method == null) { continue; } state.AddBreakpoint(method.DeclaringType.MetadataToken, boundBp, () => EnableBreakpointCore(module, method, boundBp, location)); } }