Skip to content

Commit 1061fab

Browse files
authored
[release/5.0-rc2][wasm][debugger] Fix line number information for hidden locations
1 parent e48e542 commit 1061fab

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,16 @@ public SourceLocation GetLocationByIl(int pos)
323323
SequencePoint prev = null;
324324
foreach (var sp in DebugInformation.SequencePoints)
325325
{
326-
if (sp.Offset > pos)
326+
if (sp.Offset > pos) {
327+
//get the earlier line number if the offset is in a hidden sequence point and has a earlier line number available
328+
// if is doesn't continue and get the next line number that is not in a hidden sequence point
329+
if (sp.IsHidden && prev == null)
330+
continue;
327331
break;
328-
prev = sp;
332+
}
333+
334+
if (!sp.IsHidden)
335+
prev = sp;
329336
}
330337

331338
if (prev != null)

src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,34 @@ async Task LoadAssemblyDynamically(string asm_file, string pdb_file)
19831983
Assert.True(load_assemblies_res.IsOk);
19841984
}
19851985

1986+
[Fact]
1987+
public async Task StepOverHiddenSequencePoint()
1988+
{
1989+
var insp = new Inspector();
1990+
1991+
//Collect events
1992+
var scripts = SubscribeToScripts(insp);
1993+
1994+
await Ready();
1995+
await insp.Ready(async (cli, token) =>
1996+
{
1997+
ctx = new DebugTestContext(cli, insp, token, scripts);
1998+
1999+
var bp = await SetBreakpointInMethod("debugger-test.dll", "HiddenSequencePointTest", "StepOverHiddenSP2", 0);
2000+
2001+
var pause_location = await EvaluateAndCheck(
2002+
"window.setTimeout(function() { invoke_static_method ('[debugger-test] HiddenSequencePointTest:StepOverHiddenSP'); }, 1);",
2003+
"dotnet://debugger-test.dll/debugger-test.cs", 546, 4,
2004+
"StepOverHiddenSP2");
2005+
2006+
var top_frame = pause_location["callFrames"][1];
2007+
Assert.Equal("StepOverHiddenSP", top_frame["functionName"].Value<string>());
2008+
Assert.Contains("debugger-test.cs", top_frame["url"].Value<string>());
2009+
2010+
CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 537, 8, scripts, top_frame["location"]);
2011+
2012+
});
2013+
}
19862014
//TODO add tests covering basic stepping behavior as step in/out/over
19872015
}
19882016
}

src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,3 +531,20 @@ public static void LoadLazyAssembly(string asm_base64, string pdb_base64)
531531
Console.WriteLine($"Loaded - {loadedAssembly}");
532532
}
533533
}
534+
535+
public class HiddenSequencePointTest {
536+
public static void StepOverHiddenSP()
537+
{
538+
Console.WriteLine("first line");
539+
#line hidden
540+
Console.WriteLine("second line");
541+
StepOverHiddenSP2();
542+
#line default
543+
Console.WriteLine("third line");
544+
545+
}
546+
public static void StepOverHiddenSP2()
547+
{
548+
Console.WriteLine("StepOverHiddenSP2");
549+
}
550+
}

0 commit comments

Comments
 (0)