private void HandleThreadDeath(object sender, ThreadEventArgs e)
        {
            if (e.SuspendPolicy == SuspendPolicy.All)
            {
                Interlocked.Increment(ref _suspended);
            }

            JavaDebugThread thread;

            lock (_threads)
            {
                this._threads.TryGetValue(e.Thread.GetUniqueId(), out thread);
            }

            //string name = thread.GetName();
            DebugEvent debugEvent = new DebugThreadDestroyEvent(GetAttributesForEvent(e), 0);

            SetEventProperties(debugEvent, e, false);
            Callback.Event(DebugEngine, Process, this, thread, debugEvent);

            lock (_threads)
            {
                this._threads.Remove(e.Thread.GetUniqueId());
            }
        }
示例#2
0
 public void VirtualMachineStart(Types.SuspendPolicy suspendPolicy, RequestId requestId, ThreadId threadId)
 {
     ThreadReference thread = VirtualMachine.GetMirrorOf(threadId);
     EventRequest request = VirtualMachine.EventRequestManager.GetEventRequest(EventKind.VirtualMachineStart, requestId);
     ThreadEventArgs e = new ThreadEventArgs(VirtualMachine, (SuspendPolicy)suspendPolicy, request, thread);
     VirtualMachine.EventQueue.OnVirtualMachineStart(e);
 }
示例#3
0
        private void OnThreadExited(object sender, ThreadEventArgs e)
        {
            // TODO: Thread exit code
            var oldThread = _threads[e.Thread];

            _threads.Remove(e.Thread);

            Send(new AD7ThreadDestroyEvent(0), AD7ThreadDestroyEvent.IID, oldThread);
        }
示例#4
0
        private void OnAsyncBreakComplete(object sender, ThreadEventArgs e)
        {
            AD7Thread thread;

            if (!_threads.TryGetValue(e.Thread, out thread))
            {
                _threads[e.Thread] = thread = new AD7Thread(this, e.Thread);
            }
            Send(new AD7AsyncBreakCompleteEvent(), AD7AsyncBreakCompleteEvent.IID, thread);
        }
示例#5
0
        private void ThreadStarted(object sender, ThreadEventArgs ev)
        {
            EventRequest eventRequest = threadStartEventRequest;

            if (eventRequest != null)
            {
                Thread th = ev.Thread;
                jdwpEventHandler.Send(SuspendPolicy.EVENT_THREAD, EventKind.THREAD_START, eventRequest.RequestId, (int)th.ID);
                ev.Thread.Exited += new EventHandler <ThreadEventArgs>(ThreadExited);
            }
            Console.Error.WriteLine("ThreadStarted:" + ev.Thread.ID + " " + eventRequest);
        }
示例#6
0
 private void OnProcessLoaded(object sender, ThreadEventArgs e)
 {
     lock (_syncLock) {
         if (_programCreated)
         {
             // we've delviered the program created event, deliver the load complete event
             SendLoadComplete(_threads[e.Thread]);
         }
         else
         {
             Debug.WriteLine("Delaying load complete " + GetHashCode());
             // we haven't delivered the program created event, wait until we do to deliver the process loaded event.
             _processLoadedThread = _threads[e.Thread];
         }
     }
 }
示例#7
0
        private void OnThreadCreated(object sender, ThreadEventArgs e)
        {
            var newThread = new AD7Thread(this, e.Thread);

            _threads.Add(e.Thread, newThread);

            lock (_syncLock) {
                if (_programCreated)
                {
                    SendThreadStart(newThread);
                }
                else
                {
                    _startThread = newThread;
                }
            }
        }
        private void ManualContinueFromEvent(ThreadEventArgs e)
        {
            switch (e.SuspendPolicy)
            {
            case SuspendPolicy.All:
                JavaDebugThread thread;
                _threads.TryGetValue(e.Thread.GetUniqueId(), out thread);
                Continue(thread);
                break;

            case SuspendPolicy.EventThread:
                IThreadReference threadReference = e.Thread;
                Task.Factory.StartNew(threadReference.Resume).HandleNonCriticalExceptions();
                break;

            case SuspendPolicy.None:
                break;
            }
        }
        private void HandleThreadStart(object sender, ThreadEventArgs e)
        {
            if (e.SuspendPolicy == SuspendPolicy.All)
            {
                Interlocked.Increment(ref _suspended);
            }

            // nothing to do if this thread is already started
            JavaDebugThread thread;

            if (_threads.TryGetValue(e.Thread.GetUniqueId(), out thread))
            {
                switch (e.SuspendPolicy)
                {
                case SuspendPolicy.All:
                    Continue(thread);
                    break;

                case SuspendPolicy.EventThread:
                    Task.Factory.StartNew(e.Thread.Resume).HandleNonCriticalExceptions();
                    break;

                case SuspendPolicy.None:
                    break;
                }

                return;
            }

            thread = new JavaDebugThread(this, e.Thread, ThreadCategory.Worker);
            lock (this._threads)
            {
                this._threads.Add(e.Thread.GetUniqueId(), thread);
            }

            DebugEvent debugEvent = new DebugThreadCreateEvent(GetAttributesForEvent(e));

            SetEventProperties(debugEvent, e, true);
            Callback.Event(DebugEngine, Process, this, thread, debugEvent);

            ManualContinueFromEvent(e);
        }
示例#10
0
        private void OnThreadCreated(object sender, ThreadEventArgs e)
        {
            Debug.WriteLine("Thread created:  " + e.Thread.Id);
            var newThread = new AD7Thread(this, e.Thread);
            _threads.Add(e.Thread, newThread);

            lock (_syncLock) {
                if (_programCreated) {
                    SendThreadStart(newThread);
                } else {
                    _startThread = newThread;
                }
            }
        }
示例#11
0
 private void OnStepComplete(object sender, ThreadEventArgs e)
 {
     Send(new AD7SteppingCompleteEvent(), AD7SteppingCompleteEvent.IID, _threads[e.Thread]);
 }
示例#12
0
        private void OnProcessLoaded(object sender, ThreadEventArgs e)
        {
            lock (_syncLock) {
                if (_pseudoAttach) {
                    _process.Unregister();
                }

                if (_programCreated) {
                    // we've delviered the program created event, deliver the load complete event
                    SendLoadComplete(_threads[e.Thread]);
                } else {
                    Debug.WriteLine("Delaying load complete " + GetHashCode() + " on thread " + _threads[e.Thread].GetDebuggedThread().Id);
                    // we haven't delivered the program created event, wait until we do to deliver the process loaded event.
                    _processLoadedThread = _threads[e.Thread];
                }
            }
        }
示例#13
0
 private void OnEntryPointHit(object sender, ThreadEventArgs e)
 {
     Send(new AD7EntryPointEvent(), AD7EntryPointEvent.IID, _threads[e.Thread]);
 }
示例#14
0
 private void OnAsyncBreakComplete(object sender, ThreadEventArgs e)
 {
     AD7Thread thread;
     if (!_threads.TryGetValue(e.Thread, out thread)) {
         _threads[e.Thread] = thread = new AD7Thread(this, e.Thread);
     }
     Send(new AD7AsyncBreakCompleteEvent(), AD7AsyncBreakCompleteEvent.IID, thread);
 }
示例#15
0
        private void Create(object sender, ThreadEventArgs e)
        {
            var thread = new Thread();

            try
            {
                thread.Section = this.forumData.SectionsRepository.GetSectionByName(e.Section);
            }
            catch (Exception)
            {
                throw new HttpException(500, "Internal Server Error");
            }

            var userId = e.UserId;

            if (userId != 0)
            {
                thread.UserId = e.UserId;
            }
            else
            {
                this.View.Model.Error = "Please, log in!";
                return;
            }

            var content = e.Content.Trim();

            if (Validator.IsContentValid(content))
            {
                thread.Contents = content;
            }
            else
            {
                this.View.Model.Error = $"Content must be between {GlobalConstants.ContentMinLength} and {GlobalConstants.ContentMaxLength} characters long!";
                return;
            }

            var title = e.Title.Trim();

            if (Validator.IsTitleValid(title))
            {
                thread.Title = title;
            }
            else
            {
                this.View.Model.Error = $"Title must be between {GlobalConstants.TitleMinLength} and {GlobalConstants.TitleMaxLength} characters long!";
                return;
            }

            thread.Published = DateTime.UtcNow;
            thread.IsVisible = true;

            try
            {
                this.forumData.ThreadsRepository.CreateThread(thread);
                this.forumData.Save();
            }
            catch (Exception)
            {
                throw new HttpException(500, "Internal Server Error");
            }
        }
示例#16
0
 private void OnProcessLoaded(object sender, ThreadEventArgs e) {
     lock (_syncLock) {
         _processLoaded = true;
         HandleLoadComplete();
     }
 }
示例#17
0
        private void OnThreadCreated(object sender, ThreadEventArgs e) {
            LiveLogger.WriteLine("Thread created: " + e.Thread.Id);

            lock (_syncLock) {
                var newThread = new AD7Thread(this, e.Thread);

                // Treat first thread created as main thread
                // Should only be one for Node
                Debug.Assert(_mainThread == null);
                if (_mainThread == null) {
                    _mainThread = newThread;
                }

                _threads.Add(e.Thread, newThread);
                if (_loadComplete) {
                    SendThreadCreate(newThread);
                }
            }
        }
示例#18
0
        private void OnThreadExited(object sender, ThreadEventArgs e) {
            // TODO: Thread exit code
            AD7Thread oldThread;
            _threads.TryGetValue(e.Thread, out oldThread);
            _threads.Remove(e.Thread);

            _threadExitedEvent.Set();

            if (oldThread != null) {
                Send(new AD7ThreadDestroyEvent(0), AD7ThreadDestroyEvent.IID, oldThread);
            }
        }
 public virtual void OnAsyncCallStop(object sender, ThreadEventArgs teargs)
 {
 }
示例#20
0
 private void OnAsyncBreakComplete(object sender, ThreadEventArgs e)
 {
     Send(new AD7AsyncBreakCompleteEvent(), AD7AsyncBreakCompleteEvent.IID, _threads.Item2);
 }
示例#21
0
        private void OnThreadExited(object sender, ThreadEventArgs e)
        {
            // TODO: Thread exit code
            var oldThread = _threads[e.Thread];
            _threads.Remove(e.Thread);
            oldThread.Dispose();

            Send(new AD7ThreadDestroyEvent(0), AD7ThreadDestroyEvent.IID, oldThread);
        }
        private void HandleVirtualMachineStart(object sender, ThreadEventArgs e)
        {
            if (e.SuspendPolicy == SuspendPolicy.All)
            {
                Interlocked.Increment(ref _suspended);
            }

            var requestManager = _virtualMachine.GetEventRequestManager();

            var threadStartRequest = requestManager.CreateThreadStartRequest();

            threadStartRequest.SuspendPolicy = SuspendPolicy.EventThread;
            threadStartRequest.IsEnabled     = true;

            var threadDeathRequest = requestManager.CreateThreadDeathRequest();

            threadDeathRequest.SuspendPolicy = SuspendPolicy.EventThread;
            threadDeathRequest.IsEnabled     = true;

            var classPrepareRequest = requestManager.CreateClassPrepareRequest();

            classPrepareRequest.SuspendPolicy = SuspendPolicy.EventThread;
            classPrepareRequest.IsEnabled     = true;

            var exceptionRequest = requestManager.CreateExceptionRequest(null, true, true);

            exceptionRequest.SuspendPolicy = SuspendPolicy.All;
            exceptionRequest.IsEnabled     = true;

            var virtualMachineDeathRequest = requestManager.CreateVirtualMachineDeathRequest();

            virtualMachineDeathRequest.SuspendPolicy = SuspendPolicy.All;
            virtualMachineDeathRequest.IsEnabled     = true;

            DebugEvent debugEvent = new DebugLoadCompleteEvent(enum_EVENTATTRIBUTES.EVENT_ASYNC_STOP);

            SetEventProperties(debugEvent, e, false);
            Callback.Event(DebugEngine, Process, this, null, debugEvent);

            _isLoaded = true;

            JavaDebugThread mainThread = null;
            ReadOnlyCollection <IThreadReference> threads = VirtualMachine.GetAllThreads();

            for (int i = 0; i < threads.Count; i++)
            {
                bool            isMainThread = threads[i].Equals(e.Thread);
                JavaDebugThread thread       = new JavaDebugThread(this, threads[i], isMainThread ? ThreadCategory.Main : ThreadCategory.Worker);
                if (isMainThread)
                {
                    mainThread = thread;
                }

                lock (this._threads)
                {
                    this._threads.Add(threads[i].GetUniqueId(), thread);
                }

                debugEvent = new DebugThreadCreateEvent(enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS);
                Callback.Event(DebugEngine, Process, this, thread, debugEvent);
            }

            if (DebugEngine.VirtualizedBreakpoints.Count > 0)
            {
                ReadOnlyCollection <IReferenceType> classes = VirtualMachine.GetAllClasses();
                foreach (var type in classes)
                {
                    if (!type.GetIsPrepared())
                    {
                        continue;
                    }

                    ReadOnlyCollection <string> sourceFiles = type.GetSourcePaths(type.GetDefaultStratum());
                    DebugEngine.BindVirtualizedBreakpoints(this, mainThread, type, sourceFiles);
                }
            }

            JavaDebugThread thread2;

            lock (_threads)
            {
                this._threads.TryGetValue(e.Thread.GetUniqueId(), out thread2);
            }

            debugEvent = new DebugEntryPointEvent(GetAttributesForEvent(e));
            SetEventProperties(debugEvent, e, false);
            Callback.Event(DebugEngine, Process, this, thread2, debugEvent);
        }
 private static void SetEventProperties(DebugEvent debugEvent, ThreadEventArgs e, bool manualResume)
 {
     SetEventProperties(debugEvent, e.Request, e.SuspendPolicy, e.VirtualMachine, e.Thread, manualResume);
 }
示例#24
0
 void debuggedProcess_ThreadStarted(object sender, ThreadEventArgs e)
 {
     AddThread(e.Thread);
 }
示例#25
0
 private void OnStepComplete(object sender, ThreadEventArgs e)
 {
     Send(new AD7SteppingCompleteEvent(), AD7SteppingCompleteEvent.IID, _threads[e.Thread]);
 }
示例#26
0
 private void ThreadExited(object sender, ThreadEventArgs ev)
 {
     Console.Error.WriteLine("ThreadExited:" + ev.Thread.ID);
 }
 public void OnTransferCompleted(object sender, ThreadEventArgs e)
 {
     Application.Invoke(sender, e, TransferCompleted);
 }