void SetILBreakpoint(SerializedDnModule serMod, uint token) { Debug.Assert(token != 0 && breakpoint == null); DnBreakpoint bp = null; bp = debugger.CreateBreakpoint(serMod, token, 0, ctx2 => { debugger.RemoveBreakpoint(bp); return(true); }); }
void SetILBreakpoint(DnModuleId moduleId, uint token) { Debug.Assert(token != 0 && breakpoint == null); DnBreakpoint bp = null; bp = debugger.CreateBreakpoint(moduleId, token, 0, ctx2 => { debugger.RemoveBreakpoint(bp); ctx2.E.AddPauseState(new EntryPointBreakpointPauseState(ctx2.E.CorAppDomain, ctx2.E.CorThread)); return(false); }); }
bool OnLoadModule(BreakpointConditionContext context) { var ctx = (DebugEventBreakpointConditionContext)context; var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = lmArgs.CorModule; if (!IsOurModule(mod)) { return(false); } debugger.RemoveBreakpoint(breakpoint); breakpoint = null; var serMod = mod.SerializedDnModule; if (type == BreakProcessType.ModuleCctorOrEntryPoint) { uint cctorToken = MetaDataUtils.GetGlobalStaticConstructor(mod.GetMetaDataInterface <IMetaDataImport>()); if (cctorToken != 0) { SetILBreakpoint(serMod, cctorToken); return(false); } } string otherModuleName; uint epToken = GetEntryPointToken(filename, out otherModuleName); if (epToken != 0) { if ((Table)(epToken >> 24) == Table.Method) { SetILBreakpoint(serMod, epToken); return(false); } if (otherModuleName != null) { Debug.Assert((Table)(epToken >> 24) == Table.File); otherModuleFullName = GetOtherModuleFullName(otherModuleName); if (otherModuleFullName != null) { thisAssembly = mod.Assembly; breakpoint = debugger.CreateBreakpoint(DebugEventBreakpointType.LoadModule, OnLoadOtherModule); return(false); } } } // Failed to set BP. Break to debugger. return(true); }
bool OnLoadModule(DebugEventBreakpointConditionContext ctx) { var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = lmArgs.CorModule; if (!IsOurModule(mod)) { return(false); } debugger.RemoveBreakpoint(breakpoint); breakpoint = null; Debug.Assert(!mod.IsDynamic && !mod.IsInMemory); // It's not a dyn/in-mem module so id isn't used var moduleId = mod.GetModuleId(uint.MaxValue); if (type == BreakProcessKind.ModuleCctorOrEntryPoint) { uint cctorToken = MetaDataUtils.GetGlobalStaticConstructor(mod.GetMetaDataInterface <IMetaDataImport>()); if (cctorToken != 0) { SetILBreakpoint(moduleId, cctorToken); return(false); } } uint epToken = GetEntryPointToken(filename, out string otherModuleName); if (epToken != 0) { if ((Table)(epToken >> 24) == Table.Method) { SetILBreakpoint(moduleId, epToken); return(false); } if (otherModuleName != null) { Debug.Assert((Table)(epToken >> 24) == Table.File); otherModuleFullName = GetOtherModuleFullName(otherModuleName); if (otherModuleFullName != null) { thisAssembly = mod.Assembly; breakpoint = debugger.CreateBreakpoint(DebugEventBreakpointKind.LoadModule, OnLoadOtherModule); return(false); } } } // Failed to set BP. Break to debugger. return(true); }
void AddStartupBreakpoint() { switch (type) { case BreakProcessKind.None: break; case BreakProcessKind.EntryPoint: breakpoint = debugger.CreateBreakpoint(DebugEventBreakpointKind.LoadModule, OnLoadModule); break; default: Debug.Fail(string.Format("Unknown BreakProcessKind: {0}", type)); break; } }
bool OnLoadOtherModule(DebugEventBreakpointConditionContext ctx) { var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = lmArgs.CorModule; if (!IsModule(mod, otherModuleFullName) || mod.Assembly != thisAssembly) { return(false); } debugger.RemoveBreakpoint(breakpoint); breakpoint = null; string otherModuleName; uint epToken = GetEntryPointToken(otherModuleFullName, out otherModuleName); if (epToken != 0 && (Table)(epToken >> 24) == Table.Method) { SetILBreakpoint(mod.SerializedDnModule, epToken); return(false); } return(true); }
bool OnLoadOtherModule(DebugEventBreakpointConditionContext ctx) { var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = lmArgs.CorModule; if (!IsModule(mod, otherModuleFullName) || mod.Assembly != thisAssembly) { return(false); } debugger.RemoveBreakpoint(breakpoint); breakpoint = null; uint epToken = GetEntryPointToken(otherModuleFullName, out string otherModuleName); if (epToken != 0 && (Table)(epToken >> 24) == Table.Method) { Debug.Assert(!mod.IsDynamic && !mod.IsInMemory); // It's not a dyn/in-mem module so id isn't used SetILBreakpoint(mod.GetModuleId(uint.MaxValue), epToken); return(false); } return(true); }
public void RemoveBreakpoint(DnBreakpoint bp) { DebugVerifyThread(); var debp = bp as DnDebugEventBreakpoint; if (debp != null) { debugEventBreakpointList.Remove(debp); debp.OnRemoved(); return; } var adebp = bp as DnAnyDebugEventBreakpoint; if (adebp != null) { anyDebugEventBreakpointList.Remove(adebp); adebp.OnRemoved(); return; } var ilbp = bp as DnILCodeBreakpoint; if (ilbp != null) { ilCodeBreakpointList.Remove(ilbp.Module, ilbp); ilbp.OnRemoved(); return; } }
bool OnLoadOtherModule(BreakpointConditionContext context) { var ctx = (DebugEventBreakpointConditionContext)context; var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = lmArgs.CorModule; if (!IsModule(mod, otherModuleFullName) || mod.Assembly != thisAssembly) return false; debugger.RemoveBreakpoint(breakpoint); breakpoint = null; string otherModuleName; uint epToken = GetEntryPointToken(otherModuleFullName, out otherModuleName); if (epToken != 0 && (Table)(epToken >> 24) == Table.Method) { SetILBreakpoint(mod.SerializedDnModule, epToken); return false; } return true; }
bool OnLoadModule(BreakpointConditionContext context) { var ctx = (DebugEventBreakpointConditionContext)context; var lmArgs = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = lmArgs.CorModule; if (!IsOurModule(mod)) return false; debugger.RemoveBreakpoint(breakpoint); breakpoint = null; var serMod = mod.SerializedDnModule; if (type == BreakProcessType.ModuleCctorOrEntryPoint) { uint cctorToken = MetaDataUtils.GetGlobalStaticConstructor(mod.GetMetaDataInterface<IMetaDataImport>()); if (cctorToken != 0) { SetILBreakpoint(serMod, cctorToken); return false; } } string otherModuleName; uint epToken = GetEntryPointToken(filename, out otherModuleName); if (epToken != 0) { if ((Table)(epToken >> 24) == Table.Method) { SetILBreakpoint(serMod, epToken); return false; } if (otherModuleName != null) { Debug.Assert((Table)(epToken >> 24) == Table.File); otherModuleFullName = GetOtherModuleFullName(otherModuleName); if (otherModuleFullName != null) { thisAssembly = mod.Assembly; breakpoint = debugger.CreateBreakpoint(DebugEventBreakpointType.LoadModule, OnLoadOtherModule); return false; } } } // Failed to set BP. Break to debugger. return true; }
void AddStartupBreakpoint() { switch (type) { case BreakProcessType.None: break; case BreakProcessType.CreateProcess: CreateStartupDebugBreakEvent(DebugEventBreakpointType.CreateProcess); break; case BreakProcessType.CreateAppDomain: CreateStartupDebugBreakEvent(DebugEventBreakpointType.CreateAppDomain); break; case BreakProcessType.CreateThread: CreateStartupDebugBreakEvent(DebugEventBreakpointType.CreateThread); break; case BreakProcessType.LoadModule: CreateStartupDebugBreakEvent(DebugEventBreakpointType.LoadModule); break; case BreakProcessType.LoadClass: bool oldLoadClass = debugger.Options.ModuleClassLoadCallbacks; debugger.Options.ModuleClassLoadCallbacks = true; CreateStartupDebugBreakEvent(DebugEventBreakpointType.LoadClass, ctx => { ctx.Debugger.Options.ModuleClassLoadCallbacks = oldLoadClass; return true; }); break; case BreakProcessType.ExeLoadClass: CreateStartupAnyDebugBreakEvent(ctx => { if (ctx.EventArgs.Type == DebugCallbackType.LoadModule) { var lm = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = lm.CorModule; if (IsOurModule(mod)) mod.EnableClassLoadCallbacks(true); } else if (ctx.EventArgs.Type == DebugCallbackType.LoadClass) { var lc = (LoadClassDebugCallbackEventArgs)ctx.EventArgs; var cls = lc.CorClass; var mod = cls == null ? null : cls.Module; return IsOurModule(mod); } return false; }); break; case BreakProcessType.ExeLoadModule: CreateStartupDebugBreakEvent(DebugEventBreakpointType.LoadModule, ctx => { var e = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = e.CorModule; if (mod == null) return false; return IsOurModule(mod); }); break; case BreakProcessType.ModuleCctorOrEntryPoint: case BreakProcessType.EntryPoint: breakpoint = debugger.CreateBreakpoint(DebugEventBreakpointType.LoadModule, OnLoadModule); break; default: Debug.Fail(string.Format("Unknown BreakProcessType: {0}", type)); break; } }
void AddStartupBreakpoint() { switch (type) { case BreakProcessType.None: break; case BreakProcessType.CreateProcess: CreateStartupDebugBreakEvent(DebugEventBreakpointType.CreateProcess); break; case BreakProcessType.CreateAppDomain: CreateStartupDebugBreakEvent(DebugEventBreakpointType.CreateAppDomain); break; case BreakProcessType.CreateThread: CreateStartupDebugBreakEvent(DebugEventBreakpointType.CreateThread); break; case BreakProcessType.LoadModule: CreateStartupDebugBreakEvent(DebugEventBreakpointType.LoadModule); break; case BreakProcessType.LoadClass: bool oldLoadClass = debugger.Options.ModuleClassLoadCallbacks; debugger.Options.ModuleClassLoadCallbacks = true; CreateStartupDebugBreakEvent(DebugEventBreakpointType.LoadClass, ctx => { ctx.Debugger.Options.ModuleClassLoadCallbacks = oldLoadClass; return(true); }); break; case BreakProcessType.ExeLoadClass: CreateStartupAnyDebugBreakEvent(ctx => { if (ctx.EventArgs.Type == DebugCallbackType.LoadModule) { var lm = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = lm.CorModule; if (IsOurModule(mod)) { mod.EnableClassLoadCallbacks(true); } } else if (ctx.EventArgs.Type == DebugCallbackType.LoadClass) { var lc = (LoadClassDebugCallbackEventArgs)ctx.EventArgs; var cls = lc.CorClass; var mod = cls == null ? null : cls.Module; return(IsOurModule(mod)); } return(false); }); break; case BreakProcessType.ExeLoadModule: CreateStartupDebugBreakEvent(DebugEventBreakpointType.LoadModule, ctx => { var e = (LoadModuleDebugCallbackEventArgs)ctx.EventArgs; var mod = e.CorModule; if (mod == null) { return(false); } return(IsOurModule(mod)); }); break; case BreakProcessType.ModuleCctorOrEntryPoint: case BreakProcessType.EntryPoint: breakpoint = debugger.CreateBreakpoint(DebugEventBreakpointType.LoadModule, OnLoadModule); break; default: Debug.Fail(string.Format("Unknown BreakProcessType: {0}", type)); break; } }