Exemple #1
0
        protected override StackTraceResponse HandleStackTraceRequest(StackTraceArguments arguments)
        {
            var stackFrames = new List <StackFrame>();

            var frames = Controller.CallStack.ToArray();

            if (frames.Length > 0)
            {
                PushStackFrame(Controller.PC, frames[0].SubroutineAddress);
            }
            for (int i = 1; i < frames.Length; i++)
            {
                PushStackFrame(frames[i - 1].ReturnAddress, frames[i].SubroutineAddress);
            }

            return(new StackTraceResponse()
            {
                StackFrames = stackFrames,
                TotalFrames = stackFrames.Count
            });

            void PushStackFrame(uint address, uint subroutine)
            {
                var frame   = new StackFrame();
                var mapping = DebugMap?.GetMapping(address);

                if (mapping.HasValue)
                {
                    frame.Line   = mapping.Value.Line;
                    frame.Name   = DebugMap.FindNearestLabel(subroutine) ?? "???";
                    frame.Source = new Source()
                    {
                        Path = mapping.Value.Path
                    };
                }
                else
                {
                    frame.Name = "???";
                }
                stackFrames.Add(frame);
            }
        }
Exemple #2
0
        protected override SetBreakpointsResponse HandleSetBreakpointsRequest(SetBreakpointsArguments arguments)
        {
            var breakpoints = new List <Breakpoint>();
            var addresses   = new List <uint>();

            foreach (var bp in arguments.Breakpoints)
            {
                bool foundLine = false;
                for (int i = 0; i < 4; i++)
                {
                    var mapping = DebugMap?.GetMapping(arguments.Source.Path, bp.Line + i);
                    if (mapping.HasValue)
                    {
                        foundLine = true;
                        breakpoints.Add(new Breakpoint()
                        {
                            Line     = mapping.Value.Line,
                            Verified = true
                        });
                        addresses.Add(mapping.Value.Address);
                        break;
                    }
                }
                if (!foundLine)
                {
                    breakpoints.Add(new Breakpoint()
                    {
                        Line     = bp.Line,
                        Verified = false
                    });
                }
            }

            Controller.Breakpoints = addresses.ToImmutableArray();

            return(new SetBreakpointsResponse(breakpoints));
        }