Ejemplo n.º 1
0
        internal void notify_vm_event(EventType evtype, SuspendPolicy spolicy, int req_id, long thread_id, string vm_uri, int exit_code)
        {
            //Console.WriteLine ("Event: " + evtype + "(" + vm_uri + ")");

            switch (evtype)
            {
            case EventType.VMStart:
                /* Notify the main thread that the debuggee started up */
                lock (startup_monitor) {
                    Monitor.Pulse(startup_monitor);
                }
                queue_event_set(new EventSet(this, spolicy, new Event[] { new VMStartEvent(vm, req_id, thread_id) }));
                break;

            case EventType.VMDeath:
                queue_event_set(new EventSet(this, spolicy, new Event[] { new VMDeathEvent(vm, req_id, exit_code) }));
                break;

            case EventType.VMDisconnect:
                queue_event_set(new EventSet(this, spolicy, new Event[] { new VMDisconnectEvent(vm, req_id) }));
                break;

            default:
                throw new Exception();
            }
        }
Ejemplo n.º 2
0
        internal MethodExitEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IValue returnValue)
            : base(virtualMachine, suspendPolicy, request, thread, location)
        {
            Contract.Requires<ArgumentNullException>(returnValue != null, "returnValue");

            _returnValue = returnValue;
        }
        internal MethodExitEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IValue returnValue)
            : base(virtualMachine, suspendPolicy, request, thread, location)
        {
            Contract.Requires <ArgumentNullException>(returnValue != null, "returnValue");

            _returnValue = returnValue;
        }
Ejemplo n.º 4
0
        internal ExceptionEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IObjectReference exception, ILocation catchLocation)
            : base(virtualMachine, suspendPolicy, request, thread, location)
        {
            Contract.Requires<ArgumentNullException>(exception != null, "exception");

            _exception = exception;
            _catchLocation = catchLocation;
        }
Ejemplo n.º 5
0
        internal ClassUnloadEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, string signature)
            : base(virtualMachine, suspendPolicy, request)
        {
            Contract.Requires<ArgumentNullException>(signature != null, "signature");
            Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(signature));

            _signature = signature;
        }
Ejemplo n.º 6
0
        internal FieldAccessEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IField field, IObjectReference instance)
            : base(virtualMachine, suspendPolicy, request, thread, location)
        {
            Contract.Requires <ArgumentNullException>(field != null, "field");
            Contract.Requires(field.GetIsStatic() || instance != null);

            _field    = field;
            _instance = instance;
        }
Ejemplo n.º 7
0
        internal FieldAccessEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IField field, IObjectReference instance)
            : base(virtualMachine, suspendPolicy, request, thread, location)
        {
            Contract.Requires<ArgumentNullException>(field != null, "field");
            Contract.Requires(field.GetIsStatic() || instance != null);

            _field = field;
            _instance = instance;
        }
        internal ClassPrepareEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, string signature, ReferenceType type)
            : base(virtualMachine, suspendPolicy, request, thread)
        {
            Contract.Requires <ArgumentNullException>(signature != null, "signature");
            Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(signature));

            _signature = signature;
            _type      = type;
        }
            public EventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers)
            {
                Contract.Requires<ArgumentNullException>(modifiers != null, "modifiers");

                _internalEventKind = internalEventKind;
                _requestId = requestId;
                _suspendPolicy = suspendPolicy;
                _modifiers = new ImmutableList<EventRequestModifier>(modifiers);
            }
Ejemplo n.º 10
0
        internal ClassPrepareEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, string signature, ReferenceType type)
            : base(virtualMachine, suspendPolicy, request, thread)
        {
            Contract.Requires<ArgumentNullException>(signature != null, "signature");
            Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(signature));

            _signature = signature;
            _type = type;
        }
            public static EventFilter CreateFilter(EventKind internalEventKind, JvmtiEnvironment environment, JniEnvironment nativeEnvironment, RequestId requestId, SuspendPolicy suspendPolicy, ImmutableList<EventRequestModifier> modifiers)
            {
                if (modifiers.Count == 0)
                    return new PassThroughEventFilter(internalEventKind, requestId, suspendPolicy, modifiers);

                EventFilter[] elements = modifiers.Select(modifier => CreateFilter(internalEventKind, environment, nativeEnvironment, requestId, suspendPolicy, modifiers, modifier)).ToArray();
                if (elements.Length == 1)
                    return elements[0];

                return new AggregateEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, elements);
            }
            private static EventFilter CreateFilter(EventKind internalEventKind, JvmtiEnvironment environment, JniEnvironment nativeEnvironment, RequestId requestId, SuspendPolicy suspendPolicy, ImmutableList<EventRequestModifier> modifiers, EventRequestModifier modifier)
            {
                switch (modifier.Kind)
                {
                case ModifierKind.Count:
                    return new CountEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, modifier.Count);

                case ModifierKind.ThreadFilter:
                    return new ThreadEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, modifier.Thread);

                case ModifierKind.ClassTypeFilter:
                    throw new NotImplementedException();

                case ModifierKind.ClassMatchFilter:
                    throw new NotImplementedException();

                case ModifierKind.ClassExcludeFilter:
                    throw new NotImplementedException();

                case ModifierKind.LocationFilter:
                    return new LocationEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, modifier.Location);

                case ModifierKind.ExceptionFilter:
                    return new ExceptionEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, modifier.ExceptionOrNull, modifier.Caught, modifier.Uncaught);

                case ModifierKind.FieldFilter:
                    throw new NotImplementedException();

                case ModifierKind.Step:
                    return new StepEventFilter(internalEventKind, requestId, suspendPolicy, modifiers, modifier.Thread, environment, nativeEnvironment, modifier.StepSize, modifier.StepDepth);

                case ModifierKind.InstanceFilter:
                    throw new NotImplementedException();

                case ModifierKind.SourceNameMatchFilter:
                    throw new NotImplementedException();

                case ModifierKind.Conditional:
                    throw new NotImplementedException();

                case ModifierKind.Invalid:
                default:
                    throw new ArgumentException();
                }
            }
 internal FieldModificationEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IField field, IObjectReference instance, IValue newValue)
     : base(virtualMachine, suspendPolicy, request, thread, location, field, instance)
 {
     _newValue = newValue;
 }
 public AggregateEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers, IEnumerable<EventFilter> filters)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
     Contract.Requires<ArgumentNullException>(filters != null, "filters");
     _filters = filters.ToArray();
 }
Ejemplo n.º 15
0
 public void Events(SuspendPolicy suspend_policy, EventInfo[] events)
 {
     foreach (EventInfo e in events)
     {
         Console.WriteLine("Event Recieved: {0}", e.EventType);
     }
 }
Ejemplo n.º 16
0
		internal EventSet (VirtualMachine vm, SuspendPolicy suspend_policy, Event[] events) {
			this.vm = vm;
			this.suspend_policy = suspend_policy;
			this.events = events;
		}
            private jvmtiError ApplySuspendPolicy(JvmtiEnvironment environment, JniEnvironment nativeEnvironment, SuspendPolicy policy, ThreadId eventThread)
            {
                if (policy == SuspendPolicy.EventThread && eventThread == default(ThreadId))
                {
                    return jvmtiError.InvalidThread;
                }

                switch (policy)
                {
                case SuspendPolicy.None:
                    return jvmtiError.None;

                case SuspendPolicy.EventThread:
                    return environment.SuspendThread(nativeEnvironment, eventThread);

                case SuspendPolicy.All:
                    ThreadId[] requestList;
                    JvmtiErrorHandler.ThrowOnFailure(environment.GetAllThreads(nativeEnvironment, out requestList));
                    jvmtiError[] errors;
                    return environment.SuspendThreads(nativeEnvironment, requestList, out errors);

                default:
                    throw new ArgumentException("Invalid suspend policy.");
                }
            }
 public ThreadEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers, ThreadId thread)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
     _thread = thread;
 }
            public StepEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers, ThreadId thread, JvmtiEnvironment environment, JniEnvironment nativeEnvironment, StepSize size, StepDepth depth)
                : base(internalEventKind, requestId, suspendPolicy, modifiers, thread)
            {
                if (size == StepSize.Statement && JavaVM.DisableStatementStepping)
                    size = StepSize.Line;

                _size = size;
                _depth = depth;

                // gather reference information for the thread
                using (var threadHandle = environment.VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, thread))
                {
                    if (threadHandle.IsAlive)
                    {
                        jvmtiError error = environment.GetFrameLocation(threadHandle.Value, 0, out _lastMethod, out _lastLocation);
                        if (error == jvmtiError.None)
                            error = environment.GetFrameCount(threadHandle.Value, out _stackDepth);

                        if (error == jvmtiError.None)
                            _hasMethodInfo = true;

                        UpdateLastLine(environment);

                        if (error == jvmtiError.None && size == StepSize.Statement && (depth == StepDepth.Over || depth == StepDepth.Into))
                        {
                            byte[] bytecode;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetBytecodes(_lastMethod, out bytecode));
                            _disassembledMethod = BytecodeDisassembler.Disassemble(bytecode);

                            TaggedReferenceTypeId declaringClass;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodDeclaringClass(nativeEnvironment, _lastMethod, out declaringClass));
                            using (var classHandle = environment.VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, declaringClass.TypeId))
                            {
                                int constantPoolCount;
                                byte[] data;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetConstantPool(classHandle.Value, out constantPoolCount, out data));

                                List<ConstantPoolEntry> entryList = new List<ConstantPoolEntry>();
                                int currentPosition = 0;
                                for (int i = 0; i < constantPoolCount - 1; i++)
                                {
                                    entryList.Add(ConstantPoolEntry.FromBytes(data, ref currentPosition));
                                    switch (entryList.Last().Type)
                                    {
                                    case ConstantType.Double:
                                    case ConstantType.Long:
                                        // these entries take 2 slots
                                        entryList.Add(ConstantPoolEntry.Reserved);
                                        i++;
                                        break;

                                    default:
                                        break;
                                    }
                                }

                                _constantPool = entryList.AsReadOnly();

                                string classSignature;
                                string classGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassSignature(classHandle.Value, out classSignature, out classGenericSignature));
                                string methodName;
                                string methodSignature;
                                string methodGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodName(_lastMethod, out methodName, out methodSignature, out methodGenericSignature));

                                jobject classLoader;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassLoader(classHandle.Value, out classLoader));
                                long classLoaderTag;
                                JvmtiErrorHandler.ThrowOnFailure(environment.TagClassLoader(classLoader, out classLoaderTag));

                                ReadOnlyCollection<ExceptionTableEntry> exceptionTable;
                                JvmtiErrorHandler.ThrowOnFailure(environment.VirtualMachine.GetExceptionTable(classLoaderTag, classSignature, methodName, methodSignature, out exceptionTable));

                                _evaluationStackDepths = BytecodeDisassembler.GetEvaluationStackDepths(_disassembledMethod, _constantPool, exceptionTable);
                            }
                        }
                    }
                }
            }
 public ExceptionEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers, ReferenceTypeId exceptionType, bool caught, bool uncaught)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
     _exceptionType = exceptionType;
     _caught = caught;
     _uncaught = uncaught;
 }
Ejemplo n.º 21
0
 internal ThreadLocationEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location)
     : base(virtualMachine, suspendPolicy, request, thread)
 {
     _location = location;
 }
Ejemplo n.º 22
0
        public Error SetEvent(EventKind eventKind, SuspendPolicy suspendPolicy, EventRequestModifier[] modifiers, out RequestId requestId)
        {
            requestId = default(RequestId);

            JniEnvironment nativeEnvironment;
            JvmtiEnvironment environment;
            jvmtiError error = GetEnvironment(out environment, out nativeEnvironment);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            return _eventProcessor.SetEvent(environment, nativeEnvironment, eventKind, suspendPolicy, new ImmutableList<EventRequestModifier>(modifiers), false, out requestId);
        }
 public PassThroughEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
 }
 public CountEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers, int count)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
     _count = count;
 }
            public Error SetEvent(JvmtiEnvironment environment, JniEnvironment nativeEnvironment, EventKind eventKind, SuspendPolicy suspendPolicy, ImmutableList<EventRequestModifier> modifiers, bool internalRequest, out RequestId requestId)
            {
                Contract.Requires<ArgumentNullException>(modifiers != null, "modifiers");

                requestId = default(RequestId);

                EventKind internalEventKind = eventKind;

                EventRequestModifier locationModifier = default(EventRequestModifier);
                EventRequestModifier stepModifier = default(EventRequestModifier);

                switch (eventKind)
                {
                case EventKind.Breakpoint:
                    // we're going to need the location modifier to set the breakpoint
                    if (modifiers.Count == 0 || modifiers[0].Kind != ModifierKind.LocationFilter)
                        return Error.IllegalArgument;

                    locationModifier = modifiers[0];
                    break;

                case EventKind.SingleStep:
                    // the first modifier contains the step properties
                    if (modifiers.Count == 0 || modifiers[0].Kind != ModifierKind.Step)
                        return Error.IllegalArgument;

                    stepModifier = modifiers[0];
                    if (stepModifier.StepDepth == StepDepth.Out)
                    {
                        // we want to attach the filter as a frame pop request instead of a step request
                        eventKind = EventKind.FramePop;
                        internalEventKind = EventKind.SingleStep;
                    }

                    break;

                default:
                    break;
                }

                requestId = new RequestId(Interlocked.Increment(ref _nextRequestId));
                if (internalRequest)
                    requestId = new RequestId(-requestId.Id);

                EventFilter filter = EventFilter.CreateFilter(internalEventKind, environment, nativeEnvironment, requestId, suspendPolicy, modifiers);
                return SetEventInternal(environment, nativeEnvironment, eventKind, filter);
            }
Ejemplo n.º 26
0
 internal ThreadEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread)
     : base(virtualMachine, suspendPolicy, request)
 {
     _thread = thread;
 }
Ejemplo n.º 27
0
		internal EventRequest (VirtualMachine vm, EventType etype) {
			this.vm = vm;
			this.etype = etype;
			this.suspend = SuspendPolicy.All;
		}
Ejemplo n.º 28
0
 internal MonitorWaitEventArgs(VirtualMachine virtualMachine, SuspendPolicy suspendPolicy, EventRequest request, ThreadReference thread, Location location, IObjectReference @object, TimeSpan timeout)
     : base(virtualMachine, suspendPolicy, request, thread, location, @object)
 {
     _timeout = timeout;
 }
Ejemplo n.º 29
0
 /*
  * EVENTS
  */
 internal int EnableEvent(EventType etype, SuspendPolicy suspend_policy, List<Modifier> mods)
 {
     var w = new PacketWriter ().WriteByte ((byte)etype).WriteByte ((byte)suspend_policy);
     if (mods != null) {
         if (mods.Count > 255)
             throw new NotImplementedException ();
         w.WriteByte ((byte)mods.Count);
         foreach (Modifier mod in mods) {
             if (mod is CountModifier) {
                 w.WriteByte ((byte)ModifierKind.COUNT);
                 w.WriteInt ((mod as CountModifier).Count);
             } else if (mod is LocationModifier) {
                 w.WriteByte ((byte)ModifierKind.LOCATION_ONLY);
                 w.WriteId ((mod as LocationModifier).Method);
                 w.WriteLong ((mod as LocationModifier).Location);
             } else if (mod is StepModifier) {
                 w.WriteByte ((byte)ModifierKind.STEP);
                 w.WriteId ((mod as StepModifier).Thread);
                 w.WriteInt ((mod as StepModifier).Size);
                 w.WriteInt ((mod as StepModifier).Depth);
                 if (Version.AtLeast (2, 16))
                     w.WriteInt ((mod as StepModifier).Filter);
             } else if (mod is ThreadModifier) {
                 w.WriteByte ((byte)ModifierKind.THREAD_ONLY);
                 w.WriteId ((mod as ThreadModifier).Thread);
             } else if (mod is ExceptionModifier) {
                 var em = mod as ExceptionModifier;
                 w.WriteByte ((byte)ModifierKind.EXCEPTION_ONLY);
                 w.WriteId (em.Type);
                 if (Version.MajorVersion > 2 || Version.MinorVersion > 0) {
                     /* This is only supported in protocol version 2.1 */
                     w.WriteBool (em.Caught);
                     w.WriteBool (em.Uncaught);
                 } else if (!em.Caught || !em.Uncaught) {
                     throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
                 }
                 if (Version.MajorVersion > 2 || Version.MinorVersion > 24) {
                     w.WriteBool (em.Subclasses);
                 } else if (!em.Subclasses) {
                     throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
                 }
             } else if (mod is AssemblyModifier) {
                 w.WriteByte ((byte)ModifierKind.ASSEMBLY_ONLY);
                 var amod = (mod as AssemblyModifier);
                 w.WriteInt (amod.Assemblies.Length);
                 foreach (var id in amod.Assemblies)
                     w.WriteId (id);
             } else if (mod is SourceFileModifier) {
                 w.WriteByte ((byte)ModifierKind.SOURCE_FILE_ONLY);
                 var smod = (mod as SourceFileModifier);
                 w.WriteInt (smod.SourceFiles.Length);
                 foreach (var s in smod.SourceFiles)
                     w.WriteString (s);
             } else if (mod is TypeNameModifier) {
                 w.WriteByte ((byte)ModifierKind.TYPE_NAME_ONLY);
                 var tmod = (mod as TypeNameModifier);
                 w.WriteInt (tmod.TypeNames.Length);
                 foreach (var s in tmod.TypeNames)
                     w.WriteString (s);
             } else {
                 throw new NotImplementedException ();
             }
         }
     } else {
         w.WriteByte (0);
     }
     return SendReceive (CommandSet.EVENT_REQUEST, (int)CmdEventRequest.SET, w).ReadInt ();
 }
Ejemplo n.º 30
0
        public Error SetEvent(out RequestId requestId, EventKind eventKind, SuspendPolicy suspendPolicy, EventRequestModifier[] modifiers)
        {
            if (eventKind == EventKind.SingleStep && modifiers.Length == 1 && modifiers[0].Thread == default(ThreadId))
            {
                ThreadId[] threads;
                Error threadsErrorCode = GetAllThreads(out threads);
                if (threadsErrorCode != Error.None)
                {
                    requestId = default(RequestId);
                    return threadsErrorCode;
                }

                requestId = default(RequestId);

                threadsErrorCode = Suspend();
                if (threadsErrorCode != Error.None)
                    return threadsErrorCode;

                List<RequestId> requests = new List<RequestId>();
                foreach (var thread in threads)
                {
                    EventRequestModifier modifier = modifiers[0];
                    modifier.Thread = thread;
                    threadsErrorCode = SetEvent(out requestId, eventKind, suspendPolicy, new[] { modifier });
                    if (threadsErrorCode != Error.None)
                        return threadsErrorCode;

                    requests.Add(requestId);
                }

                _linkedRequests[requestId] = requests;
                foreach (var request in requests)
                    _requestRemap[request] = requestId;

                threadsErrorCode = Resume();
                if (threadsErrorCode != Error.None)
                    return threadsErrorCode;

                return Error.None;
            }

            byte[] packet = new byte[HeaderSize + 6];
            packet[HeaderSize] = (byte)eventKind;
            packet[HeaderSize + 1] = (byte)suspendPolicy;
            WriteInt32(packet, HeaderSize + 2, modifiers.Length);

            List<byte> packetData = new List<byte>(packet);
            foreach (EventRequestModifier modifier in modifiers)
            {
                packetData.Add((byte)modifier.Kind);

                switch (modifier.Kind)
                {
                case ModifierKind.Count:
                    {
                        byte[] additionalData = new byte[sizeof(int)];
                        WriteInt32(additionalData, 0, modifier.Count);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.Conditional:
                    {
                        byte[] additionalData = new byte[sizeof(int)];
                        WriteInt32(additionalData, 0, modifier.ExpressionId);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.ThreadFilter:
                    {
                        byte[] additionalData = new byte[ThreadIdSize];
                        WriteObjectId(additionalData, 0, modifier.Thread);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.ClassTypeFilter:
                    {
                        byte[] additionalData = new byte[ReferenceTypeIdSize];
                        WriteReferenceTypeId(additionalData, 0, modifier.Class);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.ClassMatchFilter:
                case ModifierKind.ClassExcludeFilter:
                    {
                        byte[] stringData = Encoding.UTF8.GetBytes(modifier.ClassPattern);
                        byte[] sizeData = new byte[sizeof(int)];
                        WriteInt32(sizeData, 0, stringData.Length);
                        packetData.AddRange(sizeData);
                        packetData.AddRange(stringData);
                    }
                    continue;

                case ModifierKind.LocationFilter:
                    {
                        byte[] additionalData = new byte[LocationSize];
                        WriteLocation(additionalData, 0, modifier.Location);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.ExceptionFilter:
                    {
                        byte[] additionalData = new byte[_referenceTypeIdSize.Value + 2];
                        WriteReferenceTypeId(additionalData, 0, modifier.ExceptionOrNull);
                        additionalData[_referenceTypeIdSize.Value] = (byte)(modifier.Caught ? 1 : 0);
                        additionalData[_referenceTypeIdSize.Value + 1] = (byte)(modifier.Uncaught ? 1 : 0);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.FieldFilter:
                    {
                        byte[] additionalData = new byte[ReferenceTypeIdSize + FieldIdSize];
                        WriteReferenceTypeId(additionalData, 0, modifier.Class);
                        WriteFieldId(additionalData, ReferenceTypeIdSize, modifier.Field);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.Step:
                    {
                        if (modifier.StepSize == StepSize.Statement)
                            throw new NotSupportedException();

                        byte[] additionalData = new byte[ThreadIdSize + (2 * sizeof(int))];
                        WriteObjectId(additionalData, 0, modifier.Thread);
                        WriteInt32(additionalData, ThreadIdSize, (int)modifier.StepSize);
                        WriteInt32(additionalData, ThreadIdSize + sizeof(int), (int)modifier.StepDepth);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.InstanceFilter:
                    {
                        byte[] additionalData = new byte[ObjectIdSize];
                        WriteObjectId(additionalData, 0, modifier.Instance);
                        packetData.AddRange(additionalData);
                    }
                    continue;

                case ModifierKind.SourceNameMatchFilter:
                    {
                        byte[] stringData = Encoding.UTF8.GetBytes(modifier.SourceNamePattern);
                        byte[] sizeData = new byte[sizeof(int)];
                        WriteInt32(sizeData, 0, stringData.Length);
                        packetData.AddRange(sizeData);
                        packetData.AddRange(stringData);
                    }
                    continue;

                case ModifierKind.Invalid:
                default:
                    throw new InvalidOperationException();
                }
            }

            packet = packetData.ToArray();
            int id = GetMessageId();
            SerializeHeader(packet, id, EventRequestCommand.Set);

            byte[] response = SendPacket(id, packet);
            Error errorCode = ReadErrorCode(response);
            if (errorCode != Error.None)
            {
                requestId = default(RequestId);
                return errorCode;
            }

            int offset = HeaderSize;
            requestId = new RequestId(ReadInt32(response, ref offset));
            return Error.None;
        }
Ejemplo n.º 31
0
 private static void SetEventProperties(DebugEvent debugEvent, IEventRequest request, SuspendPolicy suspendPolicy, IVirtualMachine virtualMachine, IThreadReference thread, bool manualResume)
 {
     Contract.Requires<ArgumentNullException>(debugEvent != null, "debugEvent");
     debugEvent.Properties.AddProperty(typeof(IEventRequest), request);
     debugEvent.Properties.AddProperty(typeof(SuspendPolicy), suspendPolicy);
     debugEvent.Properties.AddProperty(typeof(IVirtualMachine), virtualMachine);
     debugEvent.Properties.AddProperty(typeof(IThreadReference), thread);
     debugEvent.Properties.AddProperty("ManualResume", manualResume);
 }
 public LocationEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers, Location location)
     : base(internalEventKind, requestId, suspendPolicy, modifiers)
 {
     _location = location;
 }