Exemple #1
0
        public void timeCount(PdetailInfo pdetailInfo)
        {
            CheckForIllegalCrossThreadCalls = false;
            UserLogEvent?.Invoke();
            TimeSpan     ds        = pdetailInfo.StartTime - DateTime.Now - (pdetailInfo.Webtime - pdetailInfo.Systime);
            bool         isRelogin = false;
            ListViewItem item      = pid_listView.FindItemWithText(pdetailInfo.ID);

            while (ds.TotalSeconds >= 0)
            {
                ds = pdetailInfo.StartTime - DateTime.Now - (pdetailInfo.Webtime - pdetailInfo.Systime);
                double dH = ds.Hours;
                double dM = ds.Minutes;
                double dS = ds.Seconds;
                item.SubItems[1].Text = dH.ToString() + "时" + dM.ToString() + "分" + dS.ToString() + "秒";

                if (ds.TotalSeconds < 60 && isRelogin == false)
                {
                    UserLogEvent?.Invoke();
                    isRelogin = true;
                }
                Thread.CurrentThread.Join(1000);
            }
            TimeUpEvent?.Invoke(pdetailInfo.ID);// 发布信号
            // CheckForIllegalCrossThreadCalls = true;
        }
Exemple #2
0
        private void HandleEventSet(Event ev)
        {
            var type = ev.EventType;

            Logger.Log(ev.ToString());
            switch (type)
            {
            case EventType.Breakpoint:
                if (!HandleBreakPoint((BreakpointEvent)ev))
                {
                    return;
                }
                break;

            case EventType.Step:
                HandleStep((StepEvent)ev);
                return;

            case EventType.TypeLoad:
                var typeEvent = (TypeLoadEvent)ev;
                RegisterType(typeEvent.Type);
                TryBindBreakpoints();
                break;

            case EventType.UserLog:
                UserLogEvent e = (UserLogEvent)ev;
                HostOutputWindowEx.WriteLaunchError(e.Message);
                break;

            case EventType.VMDeath:
            case EventType.VMDisconnect:
                Disconnect();
                return;

            default:

                break;
            }

            try
            {
                _vm.Resume();
            }
            catch (VMNotSuspendedException)
            {
                if (type != EventType.VMStart && _vm.Version.AtLeast(2, 2))
                {
                    throw;
                }
            }
        }
Exemple #3
0
        private void HandleEventSet(Event ev)
        {
            var type = ev.EventType;

            _engine.IsSuspended = true;

            logger.Trace($"HandleEventSet: {ev}");

            try
            {
                switch (type)
                {
                case EventType.AssemblyLoad:
                    HandleAssemblyLoad((AssemblyLoadEvent)ev);
                    break;

                case EventType.UserBreak:
                    if (!HandleUserBreak((UserBreakEvent)ev))
                    {
                        return;
                    }
                    break;

                case EventType.Breakpoint:
                    if (!HandleBreakPoint((BreakpointEvent)ev))
                    {
                        return;
                    }
                    break;

                case EventType.Step:
                    HandleStep((StepEvent)ev);
                    return;

                case EventType.TypeLoad:
                    var typeEvent = (TypeLoadEvent)ev;
                    RegisterType(typeEvent.Type);
                    TryBindBreakpoints();
                    break;

                case EventType.UserLog:
                    UserLogEvent e = (UserLogEvent)ev;
                    HostOutputWindowEx.WriteLaunchError(e.Message);
                    break;

                case EventType.VMDeath:
                case EventType.VMDisconnect:
                    Disconnect();
                    return;

                case EventType.VMStart:
                case EventType.ThreadStart:
                    var domain    = ev.Thread.Domain.FriendlyName;
                    var threadId  = ev.Thread.ThreadId;
                    var newThread = new AD7Thread(_engine, ev.Thread);
                    if (_threads.TryAdd(threadId, newThread))
                    {
                        _engine.Callback.ThreadStarted(newThread);
                    }
                    else
                    {
                        logger.Error($"Thread {threadId} already added!");
                    }
                    break;

                case EventType.ThreadDeath:
                    var       oldThreadId = ev.Thread.ThreadId;
                    AD7Thread oldThread   = null;
                    if (!_threads.TryRemove(oldThreadId, out oldThread))
                    {
                        _engine.Callback.ThreadDestroyed(oldThread, 0);
                    }
                    else
                    {
                        logger.Error($"Thread {oldThreadId} not found!");
                    }
                    break;

                case EventType.Exception:
                    var exEvent = ev as ExceptionEvent;
                    var exceptionObjectMirror = exEvent.Exception;
                    // TODO Reading properties from complex exceptions throws an exception. Why?
                    var filter = MonoProperty.EnumOnlyFieldsFilter;
                    IEnumDebugPropertyInfo2 propInfo;
                    var monoProperty = new MonoProperty(exEvent.Thread.GetFrames().FirstOrDefault(), exceptionObjectMirror);
                    var propInfo1    = new DEBUG_PROPERTY_INFO[1];
                    monoProperty.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL, 0, 10000, null, 0, propInfo1);
                    monoProperty.EnumChildren(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL, 0, ref filter, enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_ACCESS_ALL, "", 10000, out propInfo);
                    var sbException = new StringBuilder();
                    sbException.AppendLine($"Excption thrown: {exceptionObjectMirror.Type.FullName}");
                    var propInfoCast = propInfo as AD7PropertyEnum;
                    foreach (var prop in propInfoCast.GetData())
                    {
                        if (prop.bstrName.StartsWith("_message") || prop.bstrName.StartsWith("_innerException"))
                        {
                            sbException.AppendLine($"{prop.bstrName} = {prop.bstrValue}");
                        }
                    }
                    logger.Error($"Exception thrown: {sbException.ToString()}");
                    HostOutputWindowEx.WriteLaunchError($"Exception thrown: {sbException.ToString()}");
                    break;

                default:
                    logger.Trace(ev);
                    break;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"Exception thrown in {nameof(HandleEventSet)}({ev})");
            }

            try
            {
                if (type != EventType.VMStart)
                {
                    logger.Trace($"HandleEventSet: ResumeVM ({ev})");
                    ResumeVM();
                }
            }
            catch (VMNotSuspendedException)
            {
                if (type != EventType.VMStart && _vm.Version.AtLeast(2, 2))
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }