Example #1
0
        private MessageResult DoSetBreakpoints(SetBreakpointsMessage message)
        {
            var messageResult = new Dictionary <Breakpoint, bool>();

            foreach (var breakpoint in message.Breakpoints)
            {
                var id = (uint)Interlocked.Increment(ref _lastBreakpointId);
                IDebugBreakpoint2 breakpointToSet;
                var result = _control.AddBreakpoint2(DEBUG_BREAKPOINT_TYPE.CODE, id, out breakpointToSet);
                if (result != HResult.Ok)
                {
                    messageResult.Add(breakpoint, false);
                    continue;
                }

                ulong offset;
                result = _symbols.GetOffsetByLineWide((uint)breakpoint.Line, breakpoint.File, out offset);
                if (result != HResult.Ok)
                {
                    messageResult.Add(breakpoint, false);
                    continue;
                }

                result = breakpointToSet.SetOffset(offset);
                if (result != HResult.Ok)
                {
                    messageResult.Add(breakpoint, false);
                    continue;
                }
                result = breakpointToSet.SetFlags(DEBUG_BREAKPOINT_FLAG.ENABLED | DEBUG_BREAKPOINT_FLAG.GO_ONLY);
                if (result != HResult.Ok)
                {
                    messageResult.Add(breakpoint, false);
                    continue;
                }

                messageResult.Add(breakpoint, true);
                _breakpoints.Add(id, breakpoint);
            }

            return(new SetBreakpointsMessageResult(messageResult));
        }