This is used to share information about breakpoints and signal handlers between different invocations of the same target.
Inheritance: DebuggerMarshalByRefObject
Ejemplo n.º 1
0
        internal ExpressionBreakpoint(DebuggerSession session, ThreadGroup group,
					       LocationType type, string expression)
            : base(EventType.Breakpoint, expression, group)
        {
            this.Session = session;
            this.LocationType = type;
        }
Ejemplo n.º 2
0
        internal SourceBreakpoint(DebuggerSession session, int index, ThreadGroup group,
					   SourceLocation location)
            : base(EventType.Breakpoint, index, location.Name, group)
        {
            this.session = session;
            this.location = location;
        }
Ejemplo n.º 3
0
        protected Event(EventType type, int index, string name, ThreadGroup group)
        {
            this.type = type;
            this.index = index;
            this.name = name;
            this.group = group;
            this.UniqueID = GetNextEventIndex ();

            if (group == null)
                throw new NullReferenceException ();
        }
Ejemplo n.º 4
0
 protected Event(EventType type, string name, ThreadGroup group)
     : this(type, GetNextEventIndex(), name, group)
 {
 }
Ejemplo n.º 5
0
 internal ExceptionCatchPoint(int index, ThreadGroup group, string name, bool unhandled)
     : base(EventType.CatchException, index, name, group)
 {
     this.Unhandled = unhandled;
 }
Ejemplo n.º 6
0
 internal ExceptionCatchPoint(ThreadGroup group, TargetType exception, bool unhandled)
     : base(EventType.CatchException, exception.Name, group)
 {
     this.exception = exception;
     this.Unhandled = unhandled;
 }
Ejemplo n.º 7
0
 protected Event(EventType type, string name, ThreadGroup group)
     : this(type, GetNextEventIndex (), name, group)
 {
 }
Ejemplo n.º 8
0
 internal AddressBreakpoint(string name, ThreadGroup group, TargetAddress address)
     : base(EventType.Breakpoint, name, group)
 {
     this.address = address;
 }
Ejemplo n.º 9
0
 public Event InsertExceptionCatchPoint(Thread target, ThreadGroup group,
                                        TargetType exception)
 {
     return(InsertExceptionCatchPoint(target, group, exception, false));
 }
Ejemplo n.º 10
0
 internal ExceptionCatchPoint(ThreadGroup group, TargetType exception, bool unhandled)
     : base(EventType.CatchException, exception.Name, group)
 {
     this.exception = exception;
     this.Unhandled = unhandled;
 }
Ejemplo n.º 11
0
        public Event InsertExceptionCatchPoint(Thread target, ThreadGroup group,
							TargetType exception, bool unhandled)
        {
            Event handle = new ExceptionCatchPoint (group, exception, unhandled);
            AddEvent (handle);
            return handle;
        }
Ejemplo n.º 12
0
        public Event InsertExceptionCatchPoint(Thread target, ThreadGroup group,
							TargetType exception)
        {
            return InsertExceptionCatchPoint (target, group, exception, false);
        }
Ejemplo n.º 13
0
        public Event InsertBreakpoint(Thread target, ThreadGroup group,
					       TargetAddress address)
        {
            Event handle = new AddressBreakpoint (address.ToString (), group, address);
            handle.Activate (target);
            AddEvent (handle);
            return handle;
        }
Ejemplo n.º 14
0
 public Event InsertBreakpoint(ThreadGroup group, LocationType type, string name)
 {
     Breakpoint bpt = new ExpressionBreakpoint (this, group, type, name);
     AddEvent (bpt);
     return bpt;
 }
Ejemplo n.º 15
0
 //
 // Breakpoints
 //
 public Event InsertBreakpoint(ThreadGroup group, SourceLocation location)
 {
     Breakpoint bpt = new SourceBreakpoint (this, group, location);
     AddEvent (bpt);
     return bpt;
 }
Ejemplo n.º 16
0
        private DebuggerSession(DebuggerConfiguration config, string name)
        {
            this.Config = config;
            this.Name = name;

            modules = Hashtable.Synchronized (new Hashtable ());
            displays = Hashtable.Synchronized (new Hashtable ());
            thread_groups = Hashtable.Synchronized (new Hashtable ());
            main_thread_group = CreateThreadGroup ("main");
            directory_maps = new Dictionary<string,string> ();
            user_module_paths = new List<string> ();
            user_modules = new List<string> ();
            exception_catchpoints = new Dictionary<int,ExceptionCatchPoint> ();
            events = new Dictionary<int,Event> ();
            pending_bpts = new Dictionary<Breakpoint,BreakpointHandle.Action> ();
        }
Ejemplo n.º 17
0
        protected override bool DoResolve(ScriptingContext context)
        {
            if (global) {
                if (local)
                    throw new ScriptingException (
                        "Cannot use both -local and -global.");

                if (Group != null)
                    throw new ScriptingException (
                        "Cannot use both -group and -global.");

                tgroup = ThreadGroup.Global;
            } else if (local) {
                if (Group != null)
                    throw new ScriptingException (
                        "Cannot use both -group and -local.");

                tgroup = context.Interpreter.GetThreadGroup (Group, false);
            } else if (Group != null) {
                tgroup = context.Interpreter.GetThreadGroup (Group, false);
            } else {
                tgroup = ThreadGroup.Global;
            }

            if (context.Interpreter.HasTarget) {
                context.CurrentProcess = context.Interpreter.GetProcess (p_index);
                context.CurrentThread = context.Interpreter.GetThread (t_index);
            }

            if (!gui && !lazy && context.Interpreter.HasTarget) {
                Thread thread = context.CurrentThread;
                if (!thread.IsStopped)
                    throw new TargetException (TargetError.NotStopped);

                Backtrace backtrace = thread.GetBacktrace ();

                StackFrame frame;
                if (f_index == -1)
                    frame = backtrace.CurrentFrame;
                else {
                    if (f_index >= backtrace.Count)
                        throw new ScriptingException (
                            "No such frame: {0}", f_index);

                    frame = backtrace [f_index];
                }

                context.CurrentFrame = frame;

                if (context.Interpreter.ExpressionParser.ParseLocation (context, Argument, out location))
                    return true;
            }

            uint line;
            int pos = Argument.IndexOf (':');
            if (pos == 0)
                throw new ScriptingException ("Invalid breakpoint expression");
            else if (pos > 0) {
                string tmp = Argument.Substring (pos+1);
                if (!UInt32.TryParse (tmp, out line))
                    throw new ScriptingException ("Invalid breakpoint expression");
                return true;
            }

            if (UInt32.TryParse (Argument, out line)) {
                if (!context.Interpreter.HasTarget)
                    throw new ScriptingException ("Cannot insert breakpoint by line: no current source file.");
                return true;
            }

            Expression expr = context.ParseExpression (Argument);
            if (expr is PointerExpression) {
                address = ((PointerExpression) expr).EvaluateAddress (context);
                return true;
            }

            if (!context.Interpreter.HasTarget)
                return true;

            MethodExpression mexpr;
            try {
                mexpr = expr.ResolveMethod (context, type);
            } catch {
                mexpr = null;
            }

            if (mexpr != null)
                location = mexpr.EvaluateSource (context);
            else {
                location = context.FindMethod (Argument);
                if (location != null)
                    return true;

                address = context.CurrentProcess.LookupSymbol (Argument);
                if (!address.IsNull)
                    return true;
            }

            if (lazy || gui)
                return true;

            if (location == null)
                throw new ScriptingException ("No such method: `{0}'.", Argument);

            return true;
        }
Ejemplo n.º 18
0
 protected Event ParseEvent(XPathNavigator navigator, int index, ThreadGroup group)
 {
     if (navigator.Name == "Location") {
         SourceLocation location = new SourceLocation (this, navigator);
         return new SourceBreakpoint (this, index, group, location);
     } else if (navigator.Name == "Expression") {
         string expression = navigator.GetAttribute ("expression", "");
         LocationType type = (LocationType) Enum.Parse (
             typeof (LocationType), navigator.GetAttribute ("type", ""));
         return new ExpressionBreakpoint (this, index, group, type, expression);
     } else if (navigator.Name == "Exception") {
         string exc = navigator.GetAttribute ("type", "");
         bool unhandled = Boolean.Parse (navigator.GetAttribute ("unhandled", ""));
         return new ExceptionCatchPoint (index, group, exc, unhandled);
     } else if (navigator.Name == "MainMethod") {
         return new MainMethodBreakpoint (this);
     } else
         throw new InternalError ();
 }
Ejemplo n.º 19
0
        protected override bool DoResolve(ScriptingContext context)
        {
            Language language = CurrentFrame.Language;
            if (CurrentFrame.Language == null)
                throw new ScriptingException ("Current frame doesn't have a language.");

            TargetType exception_type = language.ExceptionType;
            if (exception_type == null)
                throw new ScriptingException ("Current language doesn't have any exceptions.");

            Expression expr = ParseExpression (context);
            if (expr == null)
                return false;

            expr = expr.ResolveType (context);
            if (expr == null)
                return false;

            type = expr.EvaluateType (context) as TargetClassType;
            if (!language.IsExceptionType (type))
                throw new ScriptingException ("Type `{0}' is not an exception type.", expr.Name);

            if (tgroup == null)
                tgroup = context.Interpreter.GetThreadGroup (Group, false);

            return true;
        }
Ejemplo n.º 20
0
        void AddThreadGroup(XmlElement root, ThreadGroup group)
        {
            XmlElement element = root.OwnerDocument.CreateElement ("ThreadGroup");
            element.SetAttribute ("name", group.Name);

            root.AppendChild (element);
        }
Ejemplo n.º 21
0
 internal ExceptionCatchPoint(int index, ThreadGroup group, string name, bool unhandled)
     : base(EventType.CatchException, index, name, group)
 {
     this.Unhandled = unhandled;
 }
Ejemplo n.º 22
0
 internal AddressBreakpoint(string name, ThreadGroup group, TargetAddress address)
     : base(EventType.Breakpoint, name, group)
 {
     this.address = address;
 }
Ejemplo n.º 23
0
 protected Breakpoint(EventType type, int index, string name, ThreadGroup group)
     : base(type, index, name, group)
 {
 }
Ejemplo n.º 24
0
 protected Breakpoint(EventType type, int index, string name, ThreadGroup group)
     : base(type, index, name, group)
 {
 }
Ejemplo n.º 25
0
        public int InsertExceptionCatchPoint(Thread target, ThreadGroup group,
						      TargetType exception, bool unhandled)
        {
            Event handle = target.Process.Session.InsertExceptionCatchPoint (
                target, group, exception, unhandled);
            return handle.Index;
        }
Ejemplo n.º 26
0
        protected override bool DoResolve(ScriptingContext context)
        {
            // set whole method in a try-catch block: if anything goes wrong, an invalid breakpoint
            // number is set and the semaphore is released.
            try {
                if (global) {
                    if (local)
                        throw new ScriptingException (
                                                      "Cannot use both -local and -global.");

                    if (Group != null)
                        throw new ScriptingException (
                                                      "Cannot use both -group and -global.");

                    tgroup = ThreadGroup.Global;
                } else if (local) {
                    if (Group != null)
                        throw new ScriptingException (
                                                      "Cannot use both -group and -local.");

                    tgroup = context.Interpreter.GetThreadGroup (Group, false);
                } else if (Group != null) {
                    tgroup = context.Interpreter.GetThreadGroup (Group, false);
                } else {
                    tgroup = ThreadGroup.Global;
                }

                if (context.Interpreter.HasTarget) {
                    context.CurrentProcess = context.Interpreter.GetProcess (p_index);
                    context.CurrentThread = context.Interpreter.GetThread (t_index);

                    Mono.Debugger.Thread thread = context.CurrentThread;
                    if (!thread.IsStopped)
                        throw new Mono.Debugger.TargetException (TargetError.NotStopped);

                    Backtrace backtrace = thread.GetBacktrace ();

                    StackFrame frame;
                    if (f_index == -1)
                        frame = backtrace.CurrentFrame;
                    else {
                        if (f_index >= backtrace.Count)
                            throw new ScriptingException (
                                                          "No such frame: {0}", f_index);

                        frame = backtrace [f_index];
                    }

                    context.CurrentFrame = frame;

                    if (ExpressionParser.ParseLocation (
                                                        thread, thread.CurrentFrame, Argument, out location))
                    return true;
                }

                if (Argument.IndexOf (':') > 0)
                    return true;

                try {
                    UInt32.Parse (Argument);
                    return true;
                } catch {
                }

                Expression expr = context.Interpreter.ExpressionParser.Parse (Argument);
                if (expr == null)
                    throw new ScriptingException ("Cannot resolve expression `{0}'.", Argument);

                if (expr is PointerExpression) {
                    address = ((PointerExpression) expr).EvaluateAddress (context);
                    return true;
                }

                if (!context.Interpreter.HasTarget)
                    return true;

                MethodExpression mexpr;
                try {
                    mexpr = expr.ResolveMethod (context, type);
                } catch {
                    if (lazy)
                        return true;
                    throw new ScriptingException ("No such method: `{0}'.", Argument);
                }

                if (mexpr != null)
                    location = mexpr.EvaluateSource (context);
                else
                    location = context.FindMethod (Argument);

                if (lazy)
                    return true;

                if (location == null)
                    throw new ScriptingException ("No such method: `{0}'.", Argument);

                return true;
            } catch {
                EmonicInterpreter.breakpointNumber = -1;
                EmonicInterpreter.breakpointSem.Release();
                throw;
            }
        }