Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm][debugger] Implement support to modify values. #49557

Merged
merged 13 commits into from
Apr 16, 2021
26 changes: 6 additions & 20 deletions src/mono/mono/mini/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -5673,24 +5673,6 @@ set_var (MonoType *t, MonoDebugVarInfo *var, MonoContext *ctx, MonoDomain *domai
}
}

static void
set_interp_var (MonoType *t, gpointer addr, guint8 *val_buf)
{
int size;

if (t->byref) {
addr = *(gpointer*)addr;
g_assert (addr);
}

if (MONO_TYPE_IS_REFERENCE (t))
size = sizeof (gpointer);
else
size = mono_class_value_size (mono_class_from_mono_type_internal (t), NULL);

memcpy (addr, val_buf, size);
}

static void
clear_event_request (int req_id, int etype)
{
Expand Down Expand Up @@ -9009,7 +8991,9 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
addr = (guint8*)mini_get_interp_callbacks ()->frame_get_arg (frame->interp_frame, pos);
else
addr = (guint8*)mini_get_interp_callbacks ()->frame_get_local (frame->interp_frame, pos);
set_interp_var (t, addr, val_buf);
err = mono_de_set_interp_var (t, addr, val_buf);
if (err != ERR_NONE)
return err;
} else {
set_var (t, var, &frame->ctx, frame->de.domain, val_buf, frame->reg_locations, &tls->restore_state.ctx);
}
Expand Down Expand Up @@ -9040,7 +9024,9 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
guint8 *addr;

addr = (guint8*)mini_get_interp_callbacks ()->frame_get_this (frame->interp_frame);
set_interp_var (m_class_get_this_arg (frame->actual_method->klass), addr, val_buf);
err = mono_de_set_interp_var (m_class_get_this_arg (frame->actual_method->klass), addr, val_buf);
if (err != ERR_NONE)
return err;
} else {
var = jit->this_var;
if (!var) {
Expand Down
19 changes: 19 additions & 0 deletions src/mono/mono/mini/debugger-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,5 +1754,24 @@ get_notify_debugger_of_wait_completion_method (void)
return notify_debugger_of_wait_completion_method_cache;
}

DbgEngineErrorCode
mono_de_set_interp_var (MonoType *t, gpointer addr, guint8 *val_buf)
{
int size;

if (t->byref) {
addr = *(gpointer*)addr;
if (!addr)
return ERR_INVALID_OBJECT;
}

if (MONO_TYPE_IS_REFERENCE (t))
size = sizeof (gpointer);
else
size = mono_class_value_size (mono_class_from_mono_type_internal (t), NULL);

memcpy (addr, val_buf, size);
return ERR_NONE;
}

#endif
2 changes: 2 additions & 0 deletions src/mono/mono/mini/debugger-engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ DbgEngineErrorCode mono_de_ss_create (MonoInternalThread *thread, StepSize size,
void mono_de_cancel_ss (SingleStepReq *req);
void mono_de_cancel_all_ss (void);

DbgEngineErrorCode mono_de_set_interp_var (MonoType *t, gpointer addr, guint8 *val_buf);

gboolean set_set_notification_for_wait_completion_flag (DbgEngineStackFrame *frame);
MonoClass * get_class_to_get_builder_field(DbgEngineStackFrame *frame);
gpointer get_this_addr (DbgEngineStackFrame *the_frame);
Expand Down
Loading