Skip to content

Commit 29ec808

Browse files
authored
Implementing support to Debugger::Break. (#44305)
1 parent 3d9bef9 commit 29ec808

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

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

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

446446
mini_get_dbg_callbacks ()->handle_exception = handle_exception;
447+
mini_get_dbg_callbacks ()->user_break = mono_wasm_user_break;
447448
}
448449

449450
MONO_API void
@@ -663,6 +664,12 @@ mono_wasm_breakpoint_hit (void)
663664
// mono_wasm_fire_bp ();
664665
}
665666

667+
void
668+
mono_wasm_user_break (void)
669+
{
670+
mono_wasm_fire_bp ();
671+
}
672+
666673
EMSCRIPTEN_KEEPALIVE int
667674
mono_wasm_current_bp_id (void)
668675
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ 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
int mono_wasm_assembly_already_added (const char *assembly_name);
116117

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,23 @@ async Task LoadAssemblyDynamically(string asm_file, string pdb_file)
11581158
Assert.True(load_assemblies_res.IsOk);
11591159
}
11601160

1161+
[Fact]
1162+
public async Task BreakOnDebuggerBreak()
1163+
{
1164+
var insp = new Inspector();
1165+
//Collect events
1166+
var scripts = SubscribeToScripts(insp);
1167+
1168+
await Ready();
1169+
await insp.Ready(async (cli, token) =>
1170+
{
1171+
ctx = new DebugTestContext(cli, insp, token, scripts);
1172+
await EvaluateAndCheck(
1173+
"window.setTimeout(function() { invoke_static_method_async('[debugger-test] UserBreak:BreakOnDebuggerBreakCommand'); }, 1);",
1174+
"dotnet://debugger-test.dll/debugger-test2.cs", 56, 4,
1175+
"BreakOnDebuggerBreakCommand");
1176+
});
1177+
}
11611178
//TODO add tests covering basic stepping behavior as step in/out/over
11621179
}
11631180
}

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)