diff options
author | Steve Pfister <steveisok@users.noreply.github.com> | 2020-01-30 17:19:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-30 17:19:31 +0300 |
commit | e0fcb6093b71a1fdc9b9ad84e425c90452deed28 (patch) | |
tree | a20a6b1840b155ba2855e4107529ee5e8c984746 | |
parent | e3624d356baa0747a8178fb22472661f685ad3ce (diff) |
[wasm][debugger] Cancel Existing Single Step Request When Creating New (#18608)
When stepping out of a c# breakpoint into the runtime (or JS... Not sure if that's accurate),
multiple single step requests can be created when the breakpoint is hit again. In order to handle this scenario for wasm,
we just cancel the existing one.
NOTE: The debugger args addition seemed a better way to handle this than outright canceling in debugger-engine. If there
are implications to doing this, I can take it out.
-rw-r--r-- | mono/mini/debugger-agent.c | 8 | ||||
-rw-r--r-- | mono/mini/debugger-engine.c | 8 | ||||
-rw-r--r-- | mono/mini/debugger-engine.h | 1 | ||||
-rw-r--r-- | mono/mini/mini-wasm-debugger.c | 7 | ||||
-rw-r--r-- | sdks/wasm/Makefile | 6 |
5 files changed, 28 insertions, 2 deletions
diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index f4efdf5e9df..94da5e554fd 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -740,6 +740,7 @@ static void* create_breakpoint_events (GPtrArray *ss_reqs, GPtrArray *bp_reqs, M static void process_breakpoint_events (void *_evts, MonoMethod *method, MonoContext *ctx, int il_offset); static int ss_create_init_args (SingleStepReq *ss_req, SingleStepArgs *args); static void ss_args_destroy (SingleStepArgs *ss_args); +static int handle_multiple_ss_requests (void); static GENERATE_TRY_GET_CLASS_WITH_CACHE (fixed_buffer, "System.Runtime.CompilerServices", "FixedBufferAttribute") @@ -970,6 +971,7 @@ debugger_agent_init (void) cbs.process_breakpoint_events = process_breakpoint_events; cbs.ss_create_init_args = ss_create_init_args; cbs.ss_args_destroy = ss_args_destroy; + cbs.handle_multiple_ss_requests = handle_multiple_ss_requests; mono_de_init (&cbs); @@ -4969,6 +4971,12 @@ ss_args_destroy (SingleStepArgs *ss_args) } static int +handle_multiple_ss_requests (void) +{ + return DE_ERR_NOT_IMPLEMENTED; +} + +static int ensure_runtime_is_suspended (void) { if (suspend_count == 0) diff --git a/mono/mini/debugger-engine.c b/mono/mini/debugger-engine.c index fc5624c70d1..6bf2d3890c0 100644 --- a/mono/mini/debugger-engine.c +++ b/mono/mini/debugger-engine.c @@ -1489,8 +1489,12 @@ mono_de_ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, S // FIXME: Multiple requests if (the_ss_req) { - DEBUG_PRINTF (0, "Received a single step request while the previous one was still active.\n"); - return DE_ERR_NOT_IMPLEMENTED; + err = rt_callbacks.handle_multiple_ss_requests (); + + if (err == DE_ERR_NOT_IMPLEMENTED) { + DEBUG_PRINTF (0, "Received a single step request while the previous one was still active.\n"); + return DE_ERR_NOT_IMPLEMENTED; + } } DEBUG_PRINTF (1, "[dbg] Starting single step of thread %p (depth=%s).\n", thread, ss_depth_to_string (depth)); diff --git a/mono/mini/debugger-engine.h b/mono/mini/debugger-engine.h index bd9fd62ab77..d42e1dbd8dc 100644 --- a/mono/mini/debugger-engine.h +++ b/mono/mini/debugger-engine.h @@ -251,6 +251,7 @@ typedef struct { int (*ss_create_init_args) (SingleStepReq *ss_req, SingleStepArgs *args); void (*ss_args_destroy) (SingleStepArgs *ss_args); + int (*handle_multiple_ss_requests)(void); } DebuggerEngineCallbacks; diff --git a/mono/mini/mini-wasm-debugger.c b/mono/mini/mini-wasm-debugger.c index 665bad11f39..7dffb14ad8a 100644 --- a/mono/mini/mini-wasm-debugger.c +++ b/mono/mini/mini-wasm-debugger.c @@ -291,6 +291,12 @@ ss_args_destroy (SingleStepArgs *ss_args) //nothing to do } +static int +handle_multiple_ss_requests (void) { + mono_de_cancel_ss (); + return 1; +} + void mono_wasm_debugger_init (void) { @@ -313,6 +319,7 @@ mono_wasm_debugger_init (void) .process_breakpoint_events = process_breakpoint_events, .ss_create_init_args = ss_create_init_args, .ss_args_destroy = ss_args_destroy, + .handle_multiple_ss_requests = handle_multiple_ss_requests, }; mono_debug_init (MONO_DEBUG_FORMAT_MONO); diff --git a/sdks/wasm/Makefile b/sdks/wasm/Makefile index 1cfc10e38a9..7c6b39a55d2 100644 --- a/sdks/wasm/Makefile +++ b/sdks/wasm/Makefile @@ -599,6 +599,8 @@ run-aot-all: build-aot-all build-debug-sample: .stamp-build-debug-sample +rebuild-debug-sample: clean-debug-sample build-debug-sample + build-debugger-test-app: .stamp-build-debugger-test-app build-managed: build-debug-sample build-test-suite @@ -741,6 +743,10 @@ canary: check-aot: do-aot-hello +clean-debug-sample: + $(RM) .stamp-build-debug-sample + $(RM) .stamp-build-debugger-test-app + clean-sdk: $(RM) -r sdk/**/bin $(RM) -r sdk/**/obj |