public void BreakPointOnMainWillHit()
        {
            BreakpointEventRequest request = null;

            _vm.OnTypeLoad += e => {
                if (DebugeeProgramClassName == e.Type.FullName)
                {
                    var locations = e.Type.GetMethod("Main").Locations;
                    Assert.AreEqual(4, locations.Count);

                    Assert.AreEqual(7, locations[0].LineNumber);
                    Assert.AreEqual(8, locations[1].LineNumber);
                    Assert.AreEqual(9, locations[2].LineNumber);
                    Assert.AreEqual(9, locations[3].LineNumber);

                    request = _vm.SetBreakpoint(locations.First());
                    request.Enable();
                }
            };

            _vm.BreakpointHit += e => {
                Assert.AreEqual("Main", e.Method.Name);
                Assert.AreSame(e.Request, request);
                Finish();
            };

            WaitUntilFinished();
        }
Beispiel #2
0
        private int TryBindBreakpoints()
        {
            int countBounded = 0;

            try
            {
                AD7PendingBreakpoint[] pendingList;
                lock (_pendingBreakpoints)
                    pendingList = _pendingBreakpoints.Where(x => !x.Bound).ToArray();

                foreach (AD7PendingBreakpoint bp in pendingList)
                {
                    MonoBreakpointLocation location;
                    if (bp.TryBind(_types, out location))
                    {
                        try
                        {
                            BreakpointEventRequest request = _vm.SetBreakpoint(location.Method, location.IlOffset);
                            request.Enable();
                            bp.Bound       = true;
                            bp.LastRequest = request;
                            _engine.Callback.BoundBreakpoint(bp);
                            //_vm.Resume();
                            //bp.CurrentThread = null;
                            countBounded++;
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Cant bind breakpoint: " + ex);
                        }
                    }
                    else
                    {
                        logger.Error($"Cant bind breakpoint: {bp.DocumentName}:{bp.StartLine}");
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Cant bind breakpoint: " + ex);
            }

            return(countBounded);
        }
Beispiel #3
0
        private int TryBindBreakpoints()
        {
            int countBounded = 0;

            try
            {
                AD7PendingBreakpoint[] pendingList;
                lock (_pendingBreakpoints)
                    pendingList = _pendingBreakpoints.Where(x => !x.Bound).ToArray();

                foreach (AD7PendingBreakpoint bp in pendingList)
                {
                    MonoBreakpointLocation location;
                    if (bp.TryBind(_types, out location))
                    {
                        try
                        {
                            int ilOffset;
                            RoslynHelper.GetILOffset(bp, location.Method, out ilOffset);

                            BreakpointEventRequest request = _vm.SetBreakpoint(location.Method, ilOffset);
                            request.Enable();
                            bp.Bound       = true;
                            bp.LastRequest = request;
                            _engine.Callback.BoundBreakpoint(bp);
                            //_vm.Resume();
                            bp.CurrentThread = _mainThread;
                            countBounded++;
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Cant bind breakpoint: " + ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Cant bind breakpoint: " + ex);
            }

            return(countBounded);
        }