Skip to content

Commit e564220

Browse files
lewingthaystg
andauthored
[release/5.0] Browser support for Debugger::Break. (#45038)
* Implementing support to Debugger::Break. * Fix fix backport * Fix the line number of the break command Co-authored-by: Thays <thaystg@gmail.com>
1 parent ea56d0c commit e564220

4 files changed

Lines changed: 34 additions & 2 deletions

File tree

src/mono/mono/mini/mini-wasm-debugger.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ mono_wasm_debugger_init (void)
416416
objrefs = g_hash_table_new_full (NULL, NULL, NULL, mono_debugger_free_objref);
417417

418418
mini_get_dbg_callbacks ()->handle_exception = handle_exception;
419+
mini_get_dbg_callbacks ()->user_break = mono_wasm_user_break;
419420
}
420421

421422
MONO_API void
@@ -626,6 +627,12 @@ mono_wasm_breakpoint_hit (void)
626627
// mono_wasm_fire_bp ();
627628
}
628629

630+
void
631+
mono_wasm_user_break (void)
632+
{
633+
mono_wasm_fire_bp ();
634+
}
635+
629636
EMSCRIPTEN_KEEPALIVE int
630637
mono_wasm_current_bp_id (void)
631638
{

src/mono/mono/mini/mini-wasm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,6 @@ void mono_wasm_set_timeout (int timeout, int id);
111111

112112
void mono_wasm_single_step_hit (void);
113113
void mono_wasm_breakpoint_hit (void);
114+
void mono_wasm_user_break (void);
114115

115116
#endif /* __MONO_MINI_WASM_H__ */

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1984,10 +1984,27 @@ async Task LoadAssemblyDynamically(string asm_file, string pdb_file)
19841984
}
19851985

19861986
[Fact]
1987-
public async Task StepOverHiddenSequencePoint()
1987+
public async Task BreakOnDebuggerBreak()
19881988
{
19891989
var insp = new Inspector();
1990+
//Collect events
1991+
var scripts = SubscribeToScripts(insp);
19901992

1993+
await Ready();
1994+
await insp.Ready(async (cli, token) =>
1995+
{
1996+
ctx = new DebugTestContext(cli, insp, token, scripts);
1997+
await EvaluateAndCheck(
1998+
"window.setTimeout(function() { invoke_static_method_async('[debugger-test] UserBreak:BreakOnDebuggerBreakCommand'); }, 1);",
1999+
"dotnet://debugger-test.dll/debugger-test2.cs", 54, 4,
2000+
"BreakOnDebuggerBreakCommand");
2001+
});
2002+
}
2003+
2004+
[Fact]
2005+
public async Task StepOverHiddenSequencePoint()
2006+
{
2007+
var insp = new Inspector();
19912008
//Collect events
19922009
var scripts = SubscribeToScripts(insp);
19932010

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
5+
using System.Diagnostics;
66
public class Misc
77
{ //Only append content to this class as the test suite depends on line info
88
public static int CreateObject(int foo, int bar)
@@ -49,3 +49,10 @@ public static void Types()
4949
var d = usMin + usMax;
5050
}
5151
}
52+
53+
public class UserBreak {
54+
public static void BreakOnDebuggerBreakCommand()
55+
{
56+
Debugger.Break();
57+
}
58+
}

0 commit comments

Comments
 (0)