Beispiel #1
0
        private void HandleEvent(GdbEvent ev)
        {
            if (ev.Name != "stopped")
            {
                return;
            }

            CleanTempVariableObjects();

            BreakEvent breakEvent = null;

            TargetEventType type = TargetEventType.TargetStopped;

            if (!string.IsNullOrEmpty(ev.Reason))
            {
                switch (ev.Reason)
                {
                case "breakpoint-hit":
                    type = TargetEventType.TargetHitBreakpoint;
                    var breakPointNumber = ev.GetInt("bkptno");
                    if (!CheckBreakpoint(breakPointNumber))
                    {
                        RunCommand("-exec-continue");
                        return;
                    }

                    breakEvent = breakpoints[breakPointNumber].BreakEvent;
                    break;

                case "watchpoint-trigger":
                    type = TargetEventType.TargetHitBreakpoint;

                    var watchPointNumber = ev.GetObject("wpt").GetInt("number");
                    breakEvent = breakpoints[watchPointNumber].BreakEvent;
                    break;

                case "signal-received":
                    if (ev.GetValue("signal-name") == "SIGINT")
                    {
                        type = TargetEventType.TargetInterrupted;
                    }
                    else
                    {
                        type = TargetEventType.TargetSignaled;
                    }
                    break;

                case "exited":
                case "exited-signalled":
                case "exited-normally":
                    type = TargetEventType.TargetExited;
                    break;

                default:
                    type = TargetEventType.TargetStopped;
                    break;
                }
            }

            ResultData curFrame = ev.GetObject("frame");

            FireTargetEvent(type, curFrame, breakEvent);
        }
Beispiel #2
0
        private void ProcessOutput(string line)
        {
            if (logGdb)
            {
                _console.WriteLine("dbg>: '" + line + "'");
            }
            switch (line[0])
            {
            case '^':
                lock (syncLock)
                {
                    lastResult = new GdbCommandResult(line);

                    lock (eventLock)
                    {
                        running = lastResult.Status == CommandStatus.Running;
                    }

                    Monitor.PulseAll(syncLock);
                }
                break;

            case '~':
            case '&':
                if (line.Length > 1 && line[1] == '"')
                {
                    line = line.Substring(2, line.Length - 5);
                }
                ThreadPool.QueueUserWorkItem(delegate
                {
                    OnTargetOutput(false, line + "\n");
                });
                break;

            case '*':
                GdbEvent ev = null;
                lock (eventLock)
                {
                    if (!line.StartsWith("*running"))
                    {
                        running = false;
                        ev      = new GdbEvent(line);
                        string ti = ev.GetValue("thread-id");
                        if (ti != null && ti != "all")
                        {
                            currentThread = activeThread = int.Parse(ti);
                        }
                        Monitor.PulseAll(eventLock);
                        if (internalStop)
                        {
                            internalStop = false;
                            return;
                        }
                    }
                }

                if (ev != null)
                {
                    ThreadPool.QueueUserWorkItem(delegate
                    {
                        try
                        {
                            HandleEvent(ev);
                        }
                        catch (Exception ex)
                        {
                            _console.WriteLine(ex.ToString());
                        }
                    });
                }
                break;
            }
        }