Esempio n. 1
0
 public static void ListBreakpoints(O2Thread.FuncVoidT1 <string> o2Callback)
 {
     if (CommandBase.Debugger.Processes.HaveActive)
     {
         MDbgBreakpointCollection breakpoints = CommandBase.Debugger.Processes.Active.Breakpoints;
         if (o2Callback != null)
         {
             CommandBase.WriteOutput("Current breakpoints:");
         }
         bool haveBps = false;
         foreach (MDbgBreakpoint b in breakpoints)
         {
             if (o2Callback != null)
             {
                 o2Callback(b.ToString());
             }
             else
             {
                 CommandBase.WriteOutput(b.ToString());
             }
             haveBps = true;
         }
         if (!haveBps)
         {
             if (o2Callback != null)
             {
                 DI.log.debug("There are no breakpoints set in the current active process");
             }
             else
             {
                 CommandBase.WriteOutput("No breakpoints!");
             }
         }
     }
 }
Esempio n. 2
0
        public void DisplayFile(string path, int highlight)
        {
            bool exists = false;

            for (int i = 0; i < _Buffers.Count; i++)
            {
                OutputBuffer buffer = _Buffers[i];
                if (buffer.Name.Equals(path))
                {
                    exists            = true;
                    _CurrentBufferIdx = i;
                    _CurrentView      = buffer;
                    break;
                }
            }

            if (!exists)
            {
                _CurrentView = new SourceViewer(path);
                string line;
                using (var reader = File.OpenText(path))
                {
                    while ((line = reader.ReadLine()) != null)
                    {
                        _CurrentView.Append(line);
                    }
                }

                _Buffers.Add(_CurrentView);
                _CurrentBufferIdx = _Buffers.Count - 1;
            }
            if (_CurrentView != null)
            {
                if (_CurrentView is SourceViewer)
                {
                    SourceViewer sviewer = _CurrentView as SourceViewer;
                    sviewer.HighLight = highlight;

                    MDbgBreakpointCollection breakpoints = _Shell.Debugger.Processes.Active.Breakpoints;
                    foreach (MDbgBreakpoint b in breakpoints)
                    {
                        if (b.Location is IBreakpointBySourceLine)
                        {
                            IBreakpointBySourceLine bp = b.Location as IBreakpointBySourceLine;
                            if (path.Equals(bp.FileName))
                            {
                                sviewer.AddBreakpoint(bp.LineNumber);
                            }
                        }
                    }
                }

                _CurrentView.Draw(0, Console.WindowHeight - 3);
            }
        }
Esempio n. 3
0
        public List <MDbgBreakpoint> getBreakPoints()
        {
            var currentBreakPoints = new List <MDbgBreakpoint>();

            if (o2MDbg.IsActive)
            {
                MDbgBreakpointCollection breakpoints = o2MDbg.ActiveProcess.Breakpoints;
                foreach (MDbgBreakpoint breakpoint in breakpoints)
                {
                    currentBreakPoints.Add(breakpoint);
                }
            }
            return(currentBreakPoints);
        }
Esempio n. 4
0
        // Toggle a breakpoint at the given line.
        // Called on UI thread.
        protected override void ToggleBreakpointAtLine(int row)
        {
            // Currently, we require an active process.
            // An alternative is if the source file remembered the unbound breakpoints and then bound them
            // when the process started (and modules got loaded).
            if (!GuiExtension.Shell.Debugger.Processes.HaveActive)
            {
                return;
            }

            // See if we have anything to remove.
            foreach (BreakpointPair p in m_Breakpoints)
            {
                if (p.m_iLine == row)
                {
                    MainForm.ExecuteOnWorkerThreadIfStoppedAndBlock(delegate(MDbgProcess process)
                    {
                        p.m_bp.Delete();
                    });
                    m_Breakpoints.Remove(p);
                    return;
                }
            }

            // Ideally, BreakpointCollection would fire events for new breakpoints being added and removed.
            // This would be good because:
            // - the Gui would then know about breakpoints set from the command line.
            // - the Gui could then set breakpoints by issuing a Text Command (instead of
            //   duplicating the logic again here).

            // Nothing to remove, so must be adding.
            MDbgBreakpoint b = null;

            MainForm.ExecuteOnWorkerThreadIfStoppedAndBlock(delegate(MDbgProcess proc)
            {
                MDbgBreakpointCollection c = proc.Breakpoints;
                {
                    b = c.CreateBreakpoint(this.Text, row);
                }
            });
            Debug.Assert(b != null);
            m_Breakpoints.Add(new BreakpointPair(b, row));
        }
Esempio n. 5
0
        public static void BreakCmd(string arguments, O2Thread.FuncVoidT1 <string> o2Callback)
        {
            if (arguments.Length == 0)
            {
                ListBreakpoints(o2Callback);
                return;
            }

            // We're adding a breakpoint. Parse the argument string.
            MDbgBreakpointCollection breakpoints = CommandBase.Debugger.Processes.Active.Breakpoints;
            ISequencePointResolver   bploc       = CommandBase.Shell.BreakpointParser.ParseFunctionBreakpoint(arguments);

            if (bploc == null)
            {
                throw new MDbgShellException("Invalid breakpoint syntax.");
            }

            MDbgBreakpoint bpnew = CommandBase.Debugger.Processes.Active.Breakpoints.CreateBreakpoint(bploc);

            CommandBase.WriteOutput(bpnew.ToString());
        }