private static int ResolveBreakpointReference(BreakpointReference bp)
 {
     return(CompileHelper.CompiledLinesLookup[
                bp.Function,
                bp.OriginalLineNumber,
                bp.OriginalColumnIndex]
            .CompiledLineNumber + 1);
 }
        /// <summary>
        /// Removes a breakpoint from the assocated debugger. If the debugger is running,
        /// it spawns a new thread that removes the breakpoint to avoid cross threading issues
        /// with MDbg (see http://blogs.msdn.com/jmstall/archive/2006/01/27/mdbg_threading_2.aspx for
        /// more information about this).
        /// </summary>
        /// <param name="function">The name of the function we are removing the breakpoint from.</param>
        /// <param name="functionLineNumber">The line number in the function code to remove the breakpoint from.</param>
        /// <param name="originalColumnIndex">The column index of the piece of function code to remove the breakpoint from.</param>
        public void RemoveBreakpoint(FunctionInfo function, int functionLineNumber, int originalColumnIndex)
        {
            BreakpointReference bp = new BreakpointReference(function, functionLineNumber, originalColumnIndex);

            _Breakpoints.Remove(bp);

            //if (DebuggerRunning)
            //{
            //    ThreadStart ts = () => Controller.Instance.DebuggerInstance.RemoveBreakpoint(ResolveBreakpointReference(bp));

            //    Thread thread = new Thread(ts);
            //    thread.SetApartmentState(ApartmentState.MTA);
            //    thread.Start();
            //}
        }
        /// <summary>
        /// Adds a breakpoint to the assocated debugger. If the debugger is running,
        /// it spawns a new thread that adds the breakpoint to avoid cross threading issues
        /// with MDbg (see http://blogs.msdn.com/jmstall/archive/2006/01/27/mdbg_threading_2.aspx for
        /// more information about this).
        /// </summary>
        /// <param name="function">The name of the function we are adding the breakpoint to.</param>
        /// <param name="functionLineNumber">The line number in the function code to add the breakpoint to.</param>
        /// <param name="originalColumnIndex">The column index of the piece of function code to add the breakpoint to.</param>
        public void SetBreakpoint(FunctionInfo function, int functionLineNumber, int originalColumnIndex)
        {
            BreakpointReference bp = new BreakpointReference(function, functionLineNumber, originalColumnIndex);

            foreach (BreakpointReference bpr in _Breakpoints)
            {
                if (bpr.Equals(bp))
                {
                    return;
                }
            }
            _Breakpoints.Add(bp);

            //if (DebuggerRunning)
            //{
            //    ThreadStart ts = () => Controller.Instance.DebuggerInstance.AddBreakpoint(ResolveBreakpointReference(bp));

            //    Thread thread = new Thread(ts);
            //    thread.SetApartmentState(ApartmentState.MTA);
            //    thread.Start();
            //}
        }