Skip to content

[wasm][debugger] Stepping over await call to the next line, returns a garbage location #42424

@radical

Description

@radical

Test:

        [Fact]
        public async Task BreakOnAwaitThenStepOverToNextAwaitCall()
        {
            var insp = new Inspector();
            //Collect events
            var scripts = SubscribeToScripts(insp);

            await Ready();
            await insp.Ready(async (cli, token) =>
            {
                ctx = new DebugTestContext(cli, insp, token, scripts);
                string source_file = "dotnet://debugger-test.dll/debugger-async-step.cs";

                await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "MethodWithTwoAwaitsAsync", 2);
                await EvaluateAndCheck(
                    "window.setTimeout(function() { invoke_static_method_async('[debugger-test] DebuggerTests.AsyncStepClass:StepOverTestAsync'); }, 1);",
                    "dotnet://debugger-test.dll/debugger-async-step.cs", 53, 12,
                    "MoveNext");

                await StepAndCheck(StepKind.Over, source_file, 54, 12, "MoveNext");
            });
        }

This fails with:

---- Assert.Equal() Failure
                                 ↓ (pos 50)
Expected: ···ugger-async-step.cs#47#12
Actual:   ···ugger-async-step.cs#16707565#-1

The reason is that the location on the call frame is garbage:

  "location": {
    "scriptId": "dotnet://501_4",
    "lineNumber": 16707565,
    "columnNumber": -1
  },

.. though the functionLocation is correct:

  "functionLocation": {
    "scriptId": "dotnet://501_4",
    "lineNumber": 45,
    "columnNumber": 8
  },

This is the full call frame, for reference:

{
  "functionName": "MoveNext",
  "callFrameId": "dotnet:scope:1",
  "functionLocation": {
    "scriptId": "dotnet://501_4",
    "lineNumber": 45,
    "columnNumber": 8
  },
  "location": {
    "scriptId": "dotnet://501_4",
    "lineNumber": 16707565,
    "columnNumber": -1
  },
  "url": "file:///Users/radical/dev/r3/src/mono/wasm/debugger/tests/debugger-async-step.cs",
  "scopeChain": [
    {
      "type": "local",
      "object": {
        "type": "object",
        "className": "Object",
        "description": "Object",
        "objectId": "dotnet:scope:1"
      },
      "name": "MoveNext",
      "startLocation": {
        "scriptId": "dotnet://501_4",
        "lineNumber": 45,
        "columnNumber": 8
      },
      "endLocation": {
        "scriptId": "dotnet://501_4",
        "lineNumber": 16707565,
        "columnNumber": -1
      }
    }
  ]
}

This test is based on @thaystg's #42299

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions