Skip to content

Commit

Permalink
[wasm][debugger] Fix line number = 16777215 (dotnet#42640)
Browse files Browse the repository at this point in the history
* Fix line number = 16777215.

* Trying to get the line number before the hidden offset.

* Adding comments.

* Adding test case

* Removing extra new line

* Fixing line number
  • Loading branch information
thaystg authored Sep 24, 2020
1 parent 6a0cc8e commit b36bb89
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,16 @@ public SourceLocation GetLocationByIl(int pos)
SequencePoint prev = null;
foreach (SequencePoint sp in DebugInformation.SequencePoints)
{
if (sp.Offset > pos)
if (sp.Offset > pos) {
//get the earlier line number if the offset is in a hidden sequence point and has a earlier line number available
// if is doesn't continue and get the next line number that is not in a hidden sequence point
if (sp.IsHidden && prev == null)
continue;
break;
prev = sp;
}

if (!sp.IsHidden)
prev = sp;
}

if (prev != null)
Expand Down
29 changes: 29 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -999,5 +999,34 @@ await EvaluateAndCheck(
await StepAndCheck(StepKind.Resume, source_file, 56, 12, "MoveNext");
});
}

[Fact]
public async Task StepOverHiddenSequencePoint()
{
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);
var bp = await SetBreakpointInMethod("debugger-test.dll", "HiddenSequencePointTest", "StepOverHiddenSP2", 0);
var pause_location = await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method ('[debugger-test] HiddenSequencePointTest:StepOverHiddenSP'); }, 1);",
"dotnet://debugger-test.dll/debugger-test.cs", 546, 4,
"StepOverHiddenSP2");
var top_frame = pause_location["callFrames"][1];
Assert.Equal("StepOverHiddenSP", top_frame["functionName"].Value<string>());
Assert.Contains("debugger-test.cs", top_frame["url"].Value<string>());
CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 537, 8, scripts, top_frame["location"]);
});
}
}
}
17 changes: 17 additions & 0 deletions src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,20 @@ public static void LoadLazyAssembly(string asm_base64, string pdb_base64)
Console.WriteLine($"Loaded - {loadedAssembly}");
}
}

public class HiddenSequencePointTest {
public static void StepOverHiddenSP()
{
Console.WriteLine("first line");
#line hidden
Console.WriteLine("second line");
StepOverHiddenSP2();
#line default
Console.WriteLine("third line");

}
public static void StepOverHiddenSP2()
{
Console.WriteLine("StepOverHiddenSP2");
}
}

0 comments on commit b36bb89

Please sign in to comment.