Skip to content

Commit

Permalink
[wasm][debugger] Cancel Existing Single Step Request When Creating New (
Browse files Browse the repository at this point in the history
dotnet#2309)

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.
  • Loading branch information
monojenkins authored Jan 30, 2020
1 parent f6efab8 commit a85d902
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/mono/mono/mini/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -4968,6 +4970,12 @@ ss_args_destroy (SingleStepArgs *ss_args)
free_frames ((StackFrame**)ss_args->frames, ss_args->nframes);
}

static int
handle_multiple_ss_requests (void)
{
return DE_ERR_NOT_IMPLEMENTED;
}

static int
ensure_runtime_is_suspended (void)
{
Expand Down
8 changes: 6 additions & 2 deletions src/mono/mono/mini/debugger-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/mini/debugger-engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
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 @@ -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)
{
Expand All @@ -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);
Expand Down

0 comments on commit a85d902

Please sign in to comment.