public override void Activate (Thread target) { Resolve (target, target.CurrentFrame); if (handle == null) throw new TargetException (TargetError.LocationInvalid); handle.Insert (target); }
internal PendingBreakpointQueue GetPendingBreakpoints(SingleSteppingEngine sse, Module module) { var pending_removals = new List <FunctionBreakpointHandle> (); var pending_inserts = new List <FunctionBreakpointHandle> (); lock (this) { if (!reached_main) { foreach (Event e in events.Values) { Breakpoint bpt = e as Breakpoint; if (bpt == null) { continue; } pending_bpts.Add(bpt, BreakpointHandle.Action.Insert); } reached_main = true; } foreach (var entry in pending_bpts.ToArray()) { var breakpoint = entry.Key; var action = entry.Value; if (((action == BreakpointHandle.Action.Remove) && !breakpoint.IsActivated) || ((action == BreakpointHandle.Action.Insert) && breakpoint.IsActivated)) { pending_bpts.Remove(breakpoint); continue; } if ((action == BreakpointHandle.Action.Insert) && breakpoint.IsUserModule && (module != null) && (module.ModuleGroup.Name != "user")) { continue; } } if (pending_bpts.Count == 0) { return(null); } Language language; if (sse.Process.IsManaged) { language = sse.Process.MonoLanguage; } else { language = sse.Process.NativeLanguage; } StackFrame main_frame = new StackFrame( sse.Client, FrameType.Special, TargetAddress.Null, TargetAddress.Null, TargetAddress.Null, null, language, new Symbol("<main>", TargetAddress.Null, 0)); foreach (var entry in pending_bpts.ToArray()) { var breakpoint = entry.Key; var action = entry.Value; try { BreakpointHandle handle = breakpoint.Resolve(sse.Client, main_frame); if (handle == null) { continue; } FunctionBreakpointHandle fh = handle as FunctionBreakpointHandle; if (fh == null) { if (action == BreakpointHandle.Action.Insert) { handle.Insert(sse.Inferior); } else { handle.Remove(sse.Inferior); } pending_bpts.Remove(breakpoint); continue; } pending_bpts.Remove(breakpoint); if (action == BreakpointHandle.Action.Insert) { pending_inserts.Add(fh); } else { pending_removals.Add(fh); } } catch (TargetException ex) { if (ex.Type == TargetError.LocationInvalid) { breakpoint.OnResolveFailed(); } else { Console.WriteLine("EX: {0} {1} {2}", breakpoint, action, ex); breakpoint.OnBreakpointError( "Cannot insert breakpoint {0}: {1}", breakpoint.Index, ex.Message); } } catch (Exception ex) { Console.WriteLine("EX: {0} {1} {2}", breakpoint, action, ex); breakpoint.OnBreakpointError( "Cannot insert breakpoint {0}: {1}", breakpoint.Index, ex.Message); } } } var pending = new PendingBreakpointQueue(); foreach (var pending_removal in pending_inserts) { pending.Add(pending_removal, BreakpointHandle.Action.Insert); } foreach (var pending_removal in pending_removals) { pending.Add(pending_removal, BreakpointHandle.Action.Remove); } return(pending); }