Ejemplo n.º 1
0
 public Frame(MethodInfoWithDebugInformation method, SourceLocation location, int id)
 {
     this.Method   = method;
     this.Location = location;
     this.Id       = id;
 }
Ejemplo n.º 2
0
    private async Task <bool> GetFrames(SessionId sessionId, ExecutionContext context, JObject args, CancellationToken token)
    {
        var ctx             = context as FirefoxExecutionContext;
        var orig_callframes = await SendCommand(sessionId, "frames", args, token);

        var callFrames          = new List <object>();
        var frames              = new List <Frame>();
        var commandParamsWriter = new MonoBinaryWriter();

        commandParamsWriter.Write(context.ThreadId);
        commandParamsWriter.Write(0);
        commandParamsWriter.Write(-1);
        var retDebuggerCmdReader = await context.SdbAgent.SendDebuggerAgentCommand(CmdThread.GetFrameInfo, commandParamsWriter, token);

        var frame_count = retDebuggerCmdReader.ReadInt32();

        for (int j = 0; j < frame_count; j++)
        {
            var frame_id = retDebuggerCmdReader.ReadInt32();
            var methodId = retDebuggerCmdReader.ReadInt32();
            var il_pos   = retDebuggerCmdReader.ReadInt32();
            retDebuggerCmdReader.ReadByte();
            MethodInfoWithDebugInformation method = await context.SdbAgent.GetMethodInfo(methodId, token);

            if (method is null)
            {
                continue;
            }

            SourceLocation location = method.Info?.GetLocationByIl(il_pos);
            if (location == null)
            {
                continue;
            }

            Log("debug", $"frame il offset: {il_pos} method token: {method.Info.Token} assembly name: {method.Info.Assembly.Name}");
            Log("debug", $"\tmethod {method.Name} location: {location}");
            frames.Add(new Frame(method, location, frame_id));

            var frameItem = JObject.FromObject(new
            {
                actor       = $"dotnet:scope:{frame_id}",
                displayName = method.Name,
                type        = "call",
                state       = "on-stack",
                asyncCause  = (string)null,
                where       = new
                {
                    actor  = location.Id.ToString(),
                    line   = location.Line + 1,
                    column = location.Column
                }
            });
            if (j > 0)
            {
                frameItem.Add("depth", j);
            }
            callFrames.Add(frameItem);

            context.CallStack = frames;
        }
        foreach (JObject frame in orig_callframes.Value["result"]?["value"]?["frames"])
        {
            string function_name = frame["displayName"]?.Value <string>();
            if (function_name != null && !(function_name.StartsWith("Module._mono_wasm", StringComparison.Ordinal) ||
                                           function_name.StartsWith("Module.mono_wasm", StringComparison.Ordinal) ||
                                           function_name == "mono_wasm_fire_debugger_agent_message" ||
                                           function_name == "_mono_wasm_fire_debugger_agent_message" ||
                                           function_name == "(wasmcall)"))
            {
                callFrames.Add(frame);
            }
        }
        var o = JObject.FromObject(new
        {
            frames = callFrames,
            from   = ctx.ThreadName
        });

        await SendEvent(sessionId, "", o, token);

        return(false);
    }