Skip to content

Commit

Permalink
[release/5.0] Browser support for Debugger::Break. (#45038)
Browse files Browse the repository at this point in the history
* Implementing support to Debugger::Break.

* Fix fix backport

* Fix the line number of the break command

Co-authored-by: Thays <thaystg@gmail.com>
  • Loading branch information
lewing and thaystg authored Nov 23, 2020
1 parent ea56d0c commit e564220
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/mono/mono/mini/mini-wasm-debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ mono_wasm_debugger_init (void)
objrefs = g_hash_table_new_full (NULL, NULL, NULL, mono_debugger_free_objref);

mini_get_dbg_callbacks ()->handle_exception = handle_exception;
mini_get_dbg_callbacks ()->user_break = mono_wasm_user_break;
}

MONO_API void
Expand Down Expand Up @@ -626,6 +627,12 @@ mono_wasm_breakpoint_hit (void)
// mono_wasm_fire_bp ();
}

void
mono_wasm_user_break (void)
{
mono_wasm_fire_bp ();
}

EMSCRIPTEN_KEEPALIVE int
mono_wasm_current_bp_id (void)
{
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/mini/mini-wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,6 @@ void mono_wasm_set_timeout (int timeout, int id);

void mono_wasm_single_step_hit (void);
void mono_wasm_breakpoint_hit (void);
void mono_wasm_user_break (void);

#endif /* __MONO_MINI_WASM_H__ */
19 changes: 18 additions & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1984,10 +1984,27 @@ async Task LoadAssemblyDynamically(string asm_file, string pdb_file)
}

[Fact]
public async Task StepOverHiddenSequencePoint()
public async Task BreakOnDebuggerBreak()
{
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);
await EvaluateAndCheck(
"window.setTimeout(function() { invoke_static_method_async('[debugger-test] UserBreak:BreakOnDebuggerBreakCommand'); }, 1);",
"dotnet://debugger-test.dll/debugger-test2.cs", 54, 4,
"BreakOnDebuggerBreakCommand");
});
}

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

Expand Down
9 changes: 8 additions & 1 deletion src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;

using System.Diagnostics;
public class Misc
{ //Only append content to this class as the test suite depends on line info
public static int CreateObject(int foo, int bar)
Expand Down Expand Up @@ -49,3 +49,10 @@ public static void Types()
var d = usMin + usMax;
}
}

public class UserBreak {
public static void BreakOnDebuggerBreakCommand()
{
Debugger.Break();
}
}

0 comments on commit e564220

Please sign in to comment.