コード例 #1
0
        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);
        }
コード例 #2
0
            public OperationRemoveBreakpoint(SingleSteppingEngine sse,
						  FunctionBreakpointHandle handle)
                : base(sse, null)
            {
                this.Handle = handle;
                this.Index = MonoLanguageBackend.GetUniqueID ();
            }
コード例 #3
0
        internal int RegisterMethodLoadHandler(Thread thread, MonoFunctionType func,
							FunctionBreakpointHandle handle)
        {
            if (method_load_handlers.Contains (handle.Index))
                return handle.Index;

            if (!thread.CurrentFrame.Language.IsManaged)
                throw new TargetException (TargetError.InvalidContext);

            TargetAddress retval = thread.CallMethod (
                info.InsertSourceBreakpoint, func.SymbolFile.MonoImage,
                func.Token, handle.Index, func.DeclaringType.BaseName);

            MethodLoadedHandler handler = handle.MethodLoaded;

            if (!retval.IsNull) {
                thread.ThreadServant.DoTargetAccess (
                    delegate (TargetMemoryAccess target)  {
                        method_from_jit_info ((TargetAccess) target,
                                      retval, handler);
                        return null;
                });
            }

            method_load_handlers.Add (handle.Index, handler);
            return handle.Index;
        }
コード例 #4
0
            public OperationInsertBreakpoint(SingleSteppingEngine sse,
						  FunctionBreakpointHandle handle)
                : base(sse, null)
            {
                this.Handle = handle;
            }