コード例 #1
0
ファイル: MonoProxy.cs プロジェクト: mrmandrake/maoui
        async Task SetBreakPoint(int msg_id, BreakPointRequest req, CancellationToken token)
        {
            var bp_loc = store.FindBestBreakpoint(req);

            Info($"BP request for '{req}' runtime ready {runtime_ready} location '{bp_loc}'");
            if (bp_loc == null)
            {
                Info($"Could not resolve breakpoint request: {req}");
                SendResponse(msg_id, Result.Err(JObject.FromObject(new
                {
                    code    = (int)MonoErrorCodes.BpNotFound,
                    message = $"C# Breakpoint at {req} not found."
                })), token);
                return;
            }

            Breakpoint bp = null;

            if (!runtime_ready)
            {
                bp = new Breakpoint(bp_loc, local_breakpoint_id++, BreakPointState.Pending);
            }
            else
            {
                bp = new Breakpoint(bp_loc, local_breakpoint_id++, BreakPointState.Disabled);

                var res = await EnableBreakPoint(bp, token);

                var ret_code = res.Value?["result"]?["value"]?.Value <int>();

                //if we fail we just buble that to the IDE (and let it panic over it)
                if (!ret_code.HasValue)
                {
                    SendResponse(msg_id, res, token);
                    return;
                }
            }

            var locations = new List <JObject>();

            locations.Add(JObject.FromObject(new
            {
                scriptId     = bp_loc.Id.ToString(),
                lineNumber   = bp_loc.Line,
                columnNumber = bp_loc.Column
            }));

            breakpoints.Add(bp);

            var ok = JObject.FromObject(new
            {
                breakpointId = $"dotnet:{bp.LocalId}",
                locations    = locations,
            });

            SendResponse(msg_id, Result.Ok(ok), token);
        }
コード例 #2
0
ファイル: MonoProxy.cs プロジェクト: mrmandrake/maoui
        protected override async Task <bool> AcceptCommand(int id, string method, JObject args, CancellationToken token)
        {
            switch (method)
            {
            case "Debugger.getScriptSource":
            {
                var script_id = args?["scriptId"]?.Value <string>();
                if (script_id.StartsWith("dotnet://", StringComparison.InvariantCultureIgnoreCase))
                {
                    await OnGetScriptSource(id, script_id, token);

                    return(true);
                }

                break;
            }

            case "Runtime.compileScript":
            {
                var exp = args?["expression"]?.Value <string>();
                if (exp.StartsWith("//dotnet:", StringComparison.InvariantCultureIgnoreCase))
                {
                    OnCompileDotnetScript(id, token);
                    return(true);
                }
                break;
            }

            case "Debugger.getPossibleBreakpoints":
            {
                var start = SourceLocation.Parse(args?["start"] as JObject);
                //FIXME support variant where restrictToFunction=true and end is omitted
                var end = SourceLocation.Parse(args?["end"] as JObject);
                if (start != null && end != null)
                {
                    return(GetPossibleBreakpoints(id, start, end, token));
                }
                break;
            }

            case "Debugger.setBreakpointByUrl":
            {
                Info($"BP req {args}");
                var bp_req = BreakPointRequest.Parse(args, store);
                if (bp_req != null)
                {
                    await SetBreakPoint(id, bp_req, token);

                    return(true);
                }
                break;
            }

            case "Debugger.removeBreakpoint":
            {
                return(await RemoveBreakpoint(id, args, token));
            }

            case "Debugger.resume":
            {
                await OnResume(token);

                break;
            }

            case "Debugger.stepInto":
            {
                if (this.current_callstack != null)
                {
                    await Step(id, StepKind.Into, token);

                    return(true);
                }
                break;
            }

            case "Debugger.stepOut":
            {
                if (this.current_callstack != null)
                {
                    await Step(id, StepKind.Out, token);

                    return(true);
                }
                break;
            }

            case "Debugger.stepOver":
            {
                if (this.current_callstack != null)
                {
                    await Step(id, StepKind.Over, token);

                    return(true);
                }
                break;
            }

            case "Runtime.getProperties":
            {
                var objId = args?["objectId"]?.Value <string>();
                if (objId.StartsWith("dotnet:scope:", StringComparison.InvariantCulture))
                {
                    await GetScopeProperties(id, int.Parse(objId.Substring("dotnet:scope:".Length)), token);

                    return(true);
                }
                if (objId.StartsWith("dotnet:", StringComparison.InvariantCulture))
                {
                    if (objId.StartsWith("dotnet:object:", StringComparison.InvariantCulture))
                    {
                        await GetDetails(id, int.Parse(objId.Substring("dotnet:object:".Length)), token, MonoCommands.GET_OBJECT_PROPERTIES);
                    }
                    if (objId.StartsWith("dotnet:array:", StringComparison.InvariantCulture))
                    {
                        await GetDetails(id, int.Parse(objId.Substring("dotnet:array:".Length)), token, MonoCommands.GET_ARRAY_VALUES);
                    }
                    return(true);
                }
                break;
            }
            }

            return(false);
        }