Inheritance: DebuggerMarshalByRefObject
Exemplo n.º 1
0
        public Backtrace(StackFrame first_frame)
        {
            this.last_frame = first_frame;

            frames = new ArrayList ();
            frames.Add (first_frame);
        }
		public override void CopyFrom (Mono.Debugging.Evaluation.EvaluationContext gctx)
		{
			base.CopyFrom (gctx);
			MdbEvaluationContext ctx = (MdbEvaluationContext) gctx;
			thread = ctx.thread;
			frame = ctx.frame;
		}
Exemplo n.º 3
0
		public EnumVariable(string name, StackFrame stackFrame, TargetEnumObject obj)
		{
			this.name = name;
			this.stackFrame = stackFrame;
			this.obj = obj;
			
			this.value = GetValue();
		}
		public MdbEvaluationContext (Thread thread, StackFrame frame, TargetObject exception, Mono.Debugging.Client.EvaluationOptions options): base (options)
		{
			Evaluator = Server.Instance.Evaluator;
			Adapter = Server.Instance.MdbObjectValueAdaptor;
			this.thread = thread;
			this.frame = frame;
			this.Exception = exception;
		}
Exemplo n.º 5
0
		public ArrayVariable(string name, StackFrame stackFrame, TargetArrayObject obj)
		{
			this.name = name;
			this.stackFrame = stackFrame;
			this.obj = obj;
			
			universalSubset = new ArraySubsetVariable(stackFrame, obj, new int[0]);
		}
Exemplo n.º 6
0
        public StepFrame(Language language, StepMode mode, StackFrame stack,
				  TargetAddress start, TargetAddress end)
        {
            this.start = start;
            this.end = end;
            this.stack = stack;
            this.language = language;
            this.mode = mode;
        }
Exemplo n.º 7
0
		public static AbstractVariable Create(TargetVariable variable, StackFrame stackFrame)
		{
			TargetObject obj;
			
			try {
				obj = variable.GetObject(stackFrame);
			} catch {
				return new ErrorVariable(variable.Name, "Can not get object");
			}
			
			return Create(variable.Name, obj, stackFrame);
		}
Exemplo n.º 8
0
        internal override BreakpointHandle Resolve(Thread target, StackFrame frame)
        {
            if (handle != null)
                return handle;

            SourceLocation location = Session.ParseLocation (
                target, frame, LocationType, Name);
            if (location == null)
                throw new TargetException (TargetError.LocationInvalid);

            handle = location.ResolveBreakpoint (Session, this);
            return handle;
        }
Exemplo n.º 9
0
        public override DL.StackFrame[] GetStackFrames(int firstIndex, int lastIndex)
        {
            CheckDisposed();

            //FIXME: validate indices

            List <DL.StackFrame> list = new List <DL.StackFrame> ();

            for (int i = firstIndex; i <= lastIndex && i < frames.Length; i++)
            {
                MD.StackFrame frame    = frames [i];
                string        method   = null;
                string        filename = null;
                int           line     = -1;

                if (frame.Method != null)
                {
                    method = frame.Method.Name;
                    if (!method.StartsWith("<"))
                    {
                        int p = method.IndexOf('(');
                        if (p != -1)
                        {
                            method = method.Substring(0, p).Trim();
                        }
                    }
                }
                else if (frame.Name != null)
                {
                    method = frame.Name.Name;
                }
                else
                {
                    method = "?";
                }

                if (frame.SourceAddress != null)
                {
                    if (frame.SourceAddress.SourceFile != null)
                    {
                        filename = frame.SourceAddress.SourceFile.FileName;
                    }
                    line = frame.SourceAddress.Row;
                }

                string lang = frame.Language != null ? frame.Language.Name : string.Empty;
                list.Add(new DL.StackFrame(frame.TargetAddress.Address, new DL.SourceLocation(method, filename, line), lang));
            }

            return(list.ToArray());
        }
Exemplo n.º 10
0
		public ArraySubsetVariable(StackFrame stackFrame, TargetArrayObject obj, int[] indicesPefix, int startIndex, int endIndex)
		{
			this.stackFrame = stackFrame;
			this.obj = obj;
			this.indicesPefix = indicesPefix;
			this.startIndex = startIndex;
			this.endIndex = endIndex;
			
			dimension = indicesPefix.Length;
			lowerBound = obj.GetLowerBound(stackFrame.Thread, dimension);
			upperBound = obj.GetUpperBound(stackFrame.Thread, dimension) - 1;

			// Uncoment to test that the whole int range can be handled
			//lowerBound = int.MinValue;
			//upperBound = int.MaxValue;
		}
Exemplo n.º 11
0
        public override AssemblyLine[] Disassemble(int frameIndex, int firstLine, int count)
        {
            CheckDisposed();
            if (disBuffers == null)
            {
                disBuffers = new MdbDissassemblyBuffer [frames.Length];
            }

            MD.StackFrame      frame  = frames [frameIndex];
            DissassemblyBuffer buffer = disBuffers [frameIndex];

            if (buffer == null)
            {
                buffer = new MdbDissassemblyBuffer(frame.Thread, frame.TargetAddress);
                disBuffers [frameIndex] = buffer;
            }

            return(buffer.GetLines(firstLine, firstLine + count - 1));
        }
Exemplo n.º 12
0
		public static AbstractVariable Create(string name, TargetObject obj, StackFrame stackFrame)
		{
			if (obj == null) {
				return new ErrorVariable(name, "Object is null");
			}
			
			try {
				switch (obj.Kind) {
					case TargetObjectKind.Array:
						return new ArrayVariable(name, stackFrame, (TargetArrayObject)obj);
					case TargetObjectKind.Pointer:
						TargetPointerObject pobj = (TargetPointerObject)obj;
						if (!pobj.Type.IsTypesafe) {
							return new ErrorVariable(name, "Pointer is not typesafe");
						}
						try {
							TargetObject deref = pobj.GetDereferencedObject(stackFrame.Thread);
							return VariableFactory.Create(name, deref, stackFrame);
						} catch {
							return new ErrorVariable(name, "Can not dereference object");
						}
					case TargetObjectKind.Object:
						try {
							TargetObject deref = ((TargetObjectObject)obj).GetDereferencedObject(stackFrame.Thread);
							return VariableFactory.Create(name, deref, stackFrame);
						} catch {
							return new ErrorVariable(name, "Can not dereference object");
						}
					case TargetObjectKind.Struct:
					case TargetObjectKind.Class:
						return new ClassVariable(name, stackFrame, (TargetClassObject)obj);
					case TargetObjectKind.Fundamental:
						return new FundamentalVariable(name, stackFrame, (TargetFundamentalObject)obj);
					case TargetObjectKind.Enum:
						return new EnumVariable(name, stackFrame, (TargetEnumObject)obj);
					default:
						return new ErrorVariable(name, "Unknown kind of object");
				}
			} catch (Exception e) {
				return new ErrorVariable(name, e.Message);
			}
		}
Exemplo n.º 13
0
        internal override BreakpointHandle Resolve(Thread target, StackFrame frame)
        {
            if (handle != null)
                return handle;

            if (frame.Thread.Process.IsManaged) {
                MonoLanguageBackend mono = frame.Thread.Process.MonoLanguage;
                MonoFunctionType main = mono.MainMethod;
                if (main == null)
                    return null;

                handle = main.GetBreakpointHandle (this, -1, -1);
            } else {
                OperatingSystemBackend os = frame.Thread.Process.OperatingSystem;
                TargetAddress main = os.LookupSymbol ("main");
                if (main.IsNull)
                    return null;

                handle = new AddressBreakpointHandle (this, main);
            }

            return handle;
        }
Exemplo n.º 14
0
        public override void TargetStopped(Interpreter interpreter, StackFrame frame,
						    AssemblerLine current_insn)
        {
            if (frame == null)
                return;

            if (frame != null && frame.SourceAddress != null)
                Console.WriteLine ("\x1A\x1A{0}:{1}:beg:{2}",
                           frame.SourceAddress.Name, "55" /* XXX */,
                           "0x80594d8" /* XXX */);
        }
Exemplo n.º 15
0
        protected void TargetEvent(Thread target, StackFrame frame,
					    TargetEventArgs args)
        {
            switch (args.Type) {
            case TargetEventType.TargetStopped: {
                if ((int) args.Data != 0)
                    interpreter.Print ("{0} received signal {1} at {2}.",
                               target.Name, (int) args.Data, frame);
                else if (!interpreter.IsInteractive)
                    break;
                else
                    interpreter.Print ("{0} stopped at {1}.", target.Name, frame);

                if (interpreter.IsScript)
                    break;

                AssemblerLine insn;
                try {
                    insn = target.DisassembleInstruction (
                        frame.Method, frame.TargetAddress);
                } catch {
                    insn = null;
                }

                interpreter.Style.TargetStopped (interpreter, frame, insn);

                break;
            }

            case TargetEventType.TargetHitBreakpoint: {
                if (!interpreter.IsInteractive)
                    break;

                interpreter.Print ("{0} hit breakpoint {1} at {2}.",
                           target.Name, (int) args.Data, frame);

                if (interpreter.IsScript)
                    break;

                AssemblerLine insn;
                try {
                    insn = target.DisassembleInstruction (
                        frame.Method, frame.TargetAddress);
                } catch {
                    insn = null;
                }

                interpreter.Style.TargetStopped (interpreter, frame, insn);

                break;
            }

            case TargetEventType.Exception:
            case TargetEventType.UnhandledException: {
                interpreter.Print ("{0} caught {2}exception at {1}.", target.Name, frame,
                           args.Type == TargetEventType.Exception ?
                           "" : "unhandled ");

                if (interpreter.IsScript)
                    break;

                AssemblerLine insn;
                try {
                    insn = target.DisassembleInstruction (
                        frame.Method, frame.TargetAddress);
                } catch {
                    insn = null;
                }

                interpreter.Style.UnhandledException (interpreter, frame, insn);

                break;
            }
            }
        }
Exemplo n.º 16
0
        protected bool PrintSource(Interpreter interpreter, StackFrame frame)
        {
            SourceAddress location = frame.SourceAddress;
            if (location == null)
                return false;

            SourceBuffer buffer;
            if (location.SourceFile != null) {
                string filename = location.SourceFile.FileName;
                buffer = interpreter.SourceFileFactory.FindFile (filename);
            } else
                buffer = location.SourceBuffer;

            if ((buffer == null) || (buffer.Contents == null) || (location.Row == 0))
                return false;

            string line = buffer.Contents [location.Row - 1];
            interpreter.Print (String.Format ("{0,4} {1}", location.Row, line));
            return true;
        }
Exemplo n.º 17
0
        public abstract void UnhandledException(Interpreter interpreter, StackFrame frame,
							 AssemblerLine current_insn);
Exemplo n.º 18
0
        public abstract void TargetStopped(Interpreter interpreter, StackFrame frame,
						    AssemblerLine current_insn);
Exemplo n.º 19
0
 public TargetEventArgs(TargetEventType type, StackFrame frame)
     : this(type, (object)null)
 {
     this.Frame = frame;
 }
Exemplo n.º 20
0
		public FundamentalVariable(string name, StackFrame stackFrame, TargetFundamentalObject obj)
		{
			this.name = name;
			this.stackFrame = stackFrame;
			this.obj = obj;
		}
Exemplo n.º 21
0
 protected override EvaluationContext GetEvaluationContext(int frameIndex, EvaluationOptions options)
 {
     CheckDisposed();
     MD.StackFrame frame = frames [frameIndex];
     return(new MdbEvaluationContext(frame.Thread, frame, exception, options));
 }
Exemplo n.º 22
0
        MemberExpression LookupMember(ScriptingContext context, StackFrame frame,
					       string full_name)
        {
            MemberExpression member;

            TargetFunctionType function = frame.Function;
            if (function != null) {
                member = StructAccessExpression.FindMember (
                    frame.Thread, function.DeclaringType, null,
                    full_name, true, true);
                if (member != null)
                    return member;
            }

            Method method = frame.Method;
            if (method == null)
                return null;

            TargetClassType decl_type = method.GetDeclaringType (context.CurrentThread);
            if (decl_type == null)
                return null;

            TargetClassObject instance = null;
            if (method.HasThis) {
                TargetVariable this_var = method.GetThis (context.CurrentThread);
                TargetObject this_obj = this_var.GetObject (frame);

                var pobj = this_obj as TargetPointerObject;
                if (pobj != null)
                    this_obj = pobj.GetDereferencedObject (context.CurrentThread);

                instance = (TargetClassObject) this_obj;
            }

            member = StructAccessExpression.FindMember (
                context.CurrentThread, decl_type, instance, full_name, true, true);
            if (member == null)
                return null;

            return member;
        }
Exemplo n.º 23
0
        TargetVariable GetVariableByName(StackFrame frame, string name)
        {
            TargetVariable[] locals = frame.Method.GetLocalVariables (frame.Thread);
            foreach (TargetVariable var in locals) {
                if ((var.Name == name) && var.IsInScope (frame.TargetAddress))
                    return var;
            }

            TargetVariable[] param_vars = frame.Method.GetParameters (frame.Thread);
            foreach (TargetVariable var in param_vars) {
                if ((var.Name == name) && var.IsInScope (frame.TargetAddress))
                    return var;
            }

            return null;
        }
Exemplo n.º 24
0
 protected void OnPausedEvent(object o, EventArgs args)
 {
     DebuggingService dbgr = (DebuggingService)Runtime.DebuggingService;
     current_frame = dbgr.CurrentFrame;
     UpdateDisplay ();
 }
Exemplo n.º 25
0
 protected void OnStoppedEvent(object o, EventArgs args)
 {
     current_frame = null;
     UpdateDisplay ();
 }
Exemplo n.º 26
0
        bool BreakEventCheck(MD.TargetEventArgs args)
        {
            MD.StackFrame frame = args.Frame;
            if (!(args.Data is int))
            {
                return(true);
            }

            int eventHandle = (int)args.Data;

            DL.BreakEvent be;
            if (!events.TryGetValue(eventHandle, out be))
            {
                return(true);
            }

            // Check hit count
            if (be.HitCount > 0)
            {
                be.HitCount--;
                DispatchEvent(delegate {
                    NotifyBreakEventUpdate(eventHandle, be.HitCount, null);
                });
                return(false);
            }

            MdbEvaluationContext ctx = new MdbEvaluationContext(frame.Thread, frame, null, SessionOptions.EvaluationOptions);

            DL.Breakpoint bp = be as DL.Breakpoint;
            if (bp != null && !string.IsNullOrEmpty(bp.ConditionExpression))
            {
                ML.TargetObject val = EvaluateExp(ctx, bp.ConditionExpression);
                if (val == null)
                {
                    return(false);
                }
                if (bp.BreakIfConditionChanges)
                {
                    string current = evaluator.TargetObjectToExpression(ctx, val).Value;
                    string last;
                    bool   found = lastConditionValue.TryGetValue(eventHandle, out last);
                    lastConditionValue [eventHandle] = current;
                    if (!found || last == current)
                    {
                        return(false);
                    }
                }
                else
                {
                    ML.TargetFundamentalObject fob = val as ML.TargetFundamentalObject;
                    if (fob == null)
                    {
                        return(false);
                    }
                    object ob = fob.GetObject(frame.Thread);
                    if (!(ob is bool) || !(bool)ob)
                    {
                        return(false);
                    }
                }
            }

            switch (be.HitAction)
            {
            case HitAction.Break:
                return(true);

            case HitAction.CustomAction:
                return(controller.OnCustomBreakpointAction(be.CustomActionId, eventHandle));

            case HitAction.PrintExpression:
                if (string.IsNullOrEmpty(be.TraceExpression) || frame == null)
                {
                    return(false);
                }
                ML.TargetObject val = EvaluateExp(ctx, be.TraceExpression);
                if (val != null)
                {
                    string str = evaluator.TargetObjectToString(ctx, val);
                    DispatchEvent(delegate {
                        NotifyBreakEventUpdate(eventHandle, -1, str);
                    });
                }
                return(false);
            }
            return(false);
        }
Exemplo n.º 27
0
        MemberExpression Lookup(ScriptingContext context, StackFrame frame)
        {
            MemberExpression member = LookupMember (context, frame, name);
            if (member != null)
                return member;

            string[] namespaces = context.GetNamespaces ();
            if (namespaces == null)
                return null;

            foreach (string ns in namespaces) {
                string full_name = MakeFQN (ns, name);
                member = LookupMember (context, frame, full_name);
                if (member != null)
                    return member;
            }

            return null;
        }
Exemplo n.º 28
0
        public override void PrintFrame(ScriptingContext context, StackFrame frame)
        {
            context.Print (frame);
            bool native = false;
            if (!PrintSource (context.Interpreter, frame))
                native = true;
            if (native) {
                AssemblerLine insn = frame.Thread.DisassembleInstruction (
                    frame.Method, frame.TargetAddress);

                if (insn != null)
                    context.Interpreter.PrintInstruction (insn);
                else
                    throw new ScriptingException (
                        "Cannot disassemble instruction at address {0}.",
                        frame.TargetAddress);
            }
        }
Exemplo n.º 29
0
        protected override Expression DoResolve(ScriptingContext context)
        {
            frame = context.CurrentFrame;
            Method method = frame.Method;
            if (method == null)
                throw new ScriptingException (
                    "Keyword `this' not allowed: no current method.");

            if (!method.HasThis)
                throw new ScriptingException (
                    "Keyword `this' not allowed: current method is " +
                    "either static or unmanaged.");

            var = method.GetThis (context.CurrentThread);
            resolved = true;
            return this;
        }
Exemplo n.º 30
0
 public override string PrintVariable(TargetVariable variable, StackFrame frame)
 {
     ObjectFormatter formatter = new ObjectFormatter (DisplayFormat.Default);
     formatter.FormatVariable (frame, variable);
     return formatter.ToString ();
 }
Exemplo n.º 31
0
        internal override BreakpointHandle Resolve(Thread target, StackFrame frame)
        {
            if (handle != null)
                return handle;

            switch (Type) {
            case EventType.Breakpoint:
                handle = new AddressBreakpointHandle (this, address);
                break;

            case EventType.WatchRead:
            case EventType.WatchWrite:
                handle = new AddressBreakpointHandle (this, address);
                break;

            default:
                throw new InternalError ();
            }

            return handle;
        }
Exemplo n.º 32
0
        public override void TargetStopped(Interpreter interpreter, StackFrame frame,
						    AssemblerLine current_insn)
        {
            if (frame != null) {
                if (!PrintSource (interpreter, frame))
                    native = true;

                interpreter.ShowDisplays (frame);
            }
            if (native && (current_insn != null))
                interpreter.PrintInstruction (current_insn);
        }
Exemplo n.º 33
0
        public override void UnhandledException(Interpreter interpreter, StackFrame frame,
							 AssemblerLine insn)
        {
            TargetStopped (interpreter, frame, insn);
        }
Exemplo n.º 34
0
 public abstract void PrintFrame(ScriptingContext context, StackFrame frame);
Exemplo n.º 35
0
        public void ShowDisplays(StackFrame frame)
        {
            ScriptingContext context = new ScriptingContext (this);
            context.CurrentFrame = frame;

            foreach (Display d in Session.Displays)
                context.ShowDisplay (d);
        }
Exemplo n.º 36
0
 public TargetEventArgs(TargetEventType type, object data, StackFrame frame)
     : this(type, data)
 {
     this.Frame = frame;
 }