void CreateDebugeeStream()
        {
            Console.WriteLine ("Creating Debuggee-side memory stream");

            Mono.Debugger.StackFrame frame = thread.CurrentFrame;

            streamType = frame.Language.LookupType (frame, "System.IO.MemoryStream") as ITargetStructType;
            if (streamType == null)
                throw new Exception ("couldn't find type `System.IO.MemoryStream'");

            ITargetMethodInfo method = null;
            foreach (ITargetMethodInfo m in streamType.Constructors) {
                if (m.FullName == ".ctor()") {
                    method = m;
                    break;
                }
            }

            if (method == null)
                throw new Exception ("couldn't find applicable constructor for memory stream");

            ITargetFunctionObject ctor = streamType.GetConstructor (frame, method.Index);
            ITargetObject[] args = new ITargetObject[0];

            debugeeStream = ctor.Type.InvokeStatic (frame, args, false) as ITargetStructObject;
            if (debugeeStream == null)
                throw new Exception ("unable to create instance of memory stream");

            Console.WriteLine ("succeeded in creating debuggee-side memory stream");
        }
Ejemplo n.º 2
0
        public static ITargetMethodInfo OverloadResolve(EvaluationContext context,
								 ILanguage language,
								 ITargetStructType stype,
								 Expression[] types,
								 ArrayList candidates)
        {
            // We do a very simple overload resolution here
            ITargetType[] argtypes = new ITargetType [types.Length];
            for (int i = 0; i < types.Length; i++)
                argtypes [i] = types [i].EvaluateType (context);

            // Ok, no we need to find an exact match.
            ITargetMethodInfo match = null;
            foreach (ITargetMethodInfo method in candidates) {
                bool ok = true;
                for (int i = 0; i < types.Length; i++) {
                    if (method.Type.ParameterTypes [i].TypeHandle != argtypes [i].TypeHandle) {
                        ok = false;
                        break;
                    }
                }

                if (!ok)
                    continue;

                // We need to find exactly one match
                if (match != null)
                    return null;

                match = method;
            }

            return match;
        }
        // Create the debuggee-side object that we'll communicate with
        void CreateVisualizerObjectSource(string sourceType)
        {
            Console.WriteLine ("Creating Debuggee-side object (of type {0})", sourceType);

            Mono.Debugger.StackFrame frame = thread.CurrentFrame;

            // shouldn't be hardcoded - it comes from the attribute
            objectSourceType = frame.Language.LookupType (frame, sourceType) as ITargetStructType;
            if (objectSourceType == null)
                throw new Exception ("couldn't find type for object source");

            ITargetMethodInfo method = null;
            foreach (ITargetMethodInfo m in objectSourceType.Constructors) {
                if (m.FullName == ".ctor()") {
                    method = m;
                    break;
                }
            }

            if (method == null)
                throw new Exception ("couldn't find applicable constructor for object source");

            ITargetFunctionObject ctor = objectSourceType.GetConstructor (frame, method.Index);
            ITargetObject[] args = new ITargetObject[0];

            objectSource = ctor.Type.InvokeStatic (frame, args, false) as ITargetStructObject;
            if (objectSource == null)
                throw new Exception ("unable to create instance of object source");

            Console.WriteLine ("succeeded in creating debuggee-side object source");
        }
Ejemplo n.º 4
0
 protected ITargetObject GetStaticProperty(ITargetStructType stype, StackFrame frame, ITargetPropertyInfo property)
 {
     try {
         return stype.GetStaticProperty (frame, property.Index);
     } catch (Mono.Debugger.TargetInvocationException ex) {
         throw new EvaluationException ("Can't get property {0}: {1}", Name, ex.Message);
     }
 }
Ejemplo n.º 5
0
        public MethodGroupExpression(ITargetStructType stype, string name,
					      ITargetStructObject instance,
					      ILanguage language, ArrayList methods)
        {
            this.stype = stype;
            this.instance = instance;
            this.language = language;
            this.name = name;
            this.methods = methods;
            resolved = true;
        }
Ejemplo n.º 6
0
 protected ITargetObject GetStaticField(ITargetStructType stype, StackFrame frame, ITargetFieldInfo field)
 {
     try {
         return stype.GetStaticField (frame, field.Index);
     } catch (Mono.Debugger.TargetInvocationException ex) {
         throw new EvaluationException ("Can't get field {0}: {1}", Name, ex.Message);
     }
 }
Ejemplo n.º 7
0
 protected ITargetObject GetStaticMember(ITargetStructType stype, StackFrame frame, ITargetMemberInfo member)
 {
     if (member is ITargetPropertyInfo)
         return GetStaticProperty (stype, frame, (ITargetPropertyInfo) member);
     else if (member is ITargetEventInfo)
         return GetStaticEvent (stype, frame, (ITargetEventInfo) member);
     else
         return GetStaticField (stype, frame, (ITargetFieldInfo) member);
 }
Ejemplo n.º 8
0
 protected ITargetObject GetStaticEvent(ITargetStructType stype, StackFrame frame, ITargetEventInfo ev)
 {
     try {
         return stype.GetStaticEvent (frame, ev.Index);
     } catch (Mono.Debugger.TargetInvocationException ex) {
         throw new EvaluationException ("Can't get event {0}: {1}", Name, ex.Message);
     }
 }
Ejemplo n.º 9
0
        public static Expression FindMember(ITargetStructType stype, StackFrame frame,
						     ITargetStructObject instance, bool allow_instance,
						     string name)
        {
            ITargetMemberInfo member = FindMember (stype, (instance == null) && !allow_instance, name);
            if (member != null) {
                if (instance != null)
                    return new StructAccessExpression (frame, instance, name);
                else
                    return new StructAccessExpression (frame, stype, name);
            }

            ArrayList methods = new ArrayList ();

            again:
            if (name == ".ctor") {
                foreach (ITargetMethodInfo method in stype.Constructors) {
                    methods.Add (method);
                }
            }
            else if (name == ".cctor") {
                foreach (ITargetMethodInfo method in stype.StaticConstructors) {
                    methods.Add (method);
                }
            }
            else {
                if ((instance != null) || allow_instance) {
                    foreach (ITargetMethodInfo method in stype.Methods) {
                        if (method.Name != name)
                            continue;

                        methods.Add (method);
                    }
                }

                foreach (ITargetMethodInfo method in stype.StaticMethods) {
                    if (method.Name != name)
                        continue;

                    methods.Add (method);
                }
            }

            if (methods.Count > 0)
                return new MethodGroupExpression (
                    stype, name, instance, frame.Language, methods);

            ITargetClassType ctype = stype as ITargetClassType;
            if ((ctype != null) && ctype.HasParent) {
                stype = ctype.ParentType;
                goto again;
            }

            return null;
        }
Ejemplo n.º 10
0
        public static ITargetMemberInfo FindMember(ITargetStructType stype, bool is_static, string name)
        {
            if (!is_static) {
                foreach (ITargetFieldInfo field in stype.Fields)
                    if (field.Name == name)
                        return field;

                foreach (ITargetPropertyInfo property in stype.Properties)
                    if (property.Name == name)
                        return property;

                foreach (ITargetEventInfo ev in stype.Events)
                    if (ev.Name == name)
                        return ev;
            }

            foreach (ITargetFieldInfo field in stype.StaticFields)
                if (field.Name == name)
                    return field;

            foreach (ITargetPropertyInfo property in stype.StaticProperties)
                if (property.Name == name)
                    return property;

            foreach (ITargetEventInfo ev in stype.StaticEvents)
                if (ev.Name == name)
                    return ev;

            return null;
        }
Ejemplo n.º 11
0
        protected StructAccessExpression(StackFrame frame,
						  ITargetStructObject instance,
						  string identifier)
        {
            this.Frame = frame;
            this.Type = instance.Type;
            this.Instance = instance;
            this.Identifier = identifier;
            this.IsStatic = false;
            resolved = true;
        }
Ejemplo n.º 12
0
        protected StructAccessExpression(StackFrame frame, ITargetStructType type,
						  string identifier)
        {
            this.Frame = frame;
            this.Type = type;
            this.Identifier = identifier;
            this.IsStatic = true;
            resolved = true;
        }