提交 b91732c3 编写于 作者: T Thays Grazia 提交者: spatil

[debugger] Fixing two crashes while debugging an Android app. (#13373)

* [debugger] Fixing two crashes while debugging an Android app.

-> Doing stepping into in VSM in some situation the frame saved in TLS is not synchronised with what is really been executed in the main thread. This makes the debugger-agent crashes because it tries to get variable info in some memory that is not available anymore.
	-> To fix it I forced the update of stack when CMD_THREAD_GET_FRAME_INFO is called.

-> Doing step over in Visual Studio for Windows, if you have the threads debugger window enabled, VSW calls frame_commands for each thread that is showed, and if the thread is not really_suspended it tries to get variable info from a memory that is not available anymore because the thread is not suspended yet.
	-> To fix it I don't send variable info of a frame if the thread is not really_suspended and doesn't have an async_state valid.

Cherry-picked with some light massaging by Alex Thibodeau (case 1249172)
上级 d1d59bb1
......@@ -3515,7 +3515,7 @@ compute_frame_info_from (MonoInternalThread *thread, DebuggerTlsData *tls, MonoT
}
static void
compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls)
compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean force_update)
{
ComputeFramesUserData user_data;
GSList *tmp;
......@@ -3524,7 +3524,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls)
MonoUnwindOptions opts = (MonoUnwindOptions)(MONO_UNWIND_DEFAULT | MONO_UNWIND_REG_LOCATIONS);
// FIXME: Locking on tls
if (tls->frames && tls->frames_up_to_date)
if (tls->frames && tls->frames_up_to_date && !force_update)
return;
DEBUG_PRINTF (1, "Frames for %p(tid=%lx):\n", thread, thread->tid);
......@@ -5207,7 +5207,7 @@ static void ss_calculate_framecount (DebuggerTlsData *tls, MonoContext *ctx)
{
if (!tls->context.valid)
mono_thread_state_init_from_monoctx (&tls->context, ctx);
compute_frame_info (tls->thread, tls);
compute_frame_info (tls->thread, tls, FALSE);
}
static gboolean
......@@ -6484,7 +6484,7 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI
mono_loader_lock ();
locked = TRUE;
compute_frame_info (tls->thread, tls);
compute_frame_info (tls->thread, tls, FALSE);
frames = tls->frames;
nframes = tls->frame_count;
}
......@@ -6810,7 +6810,7 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte
if (frames && nframes)
frame = frames [0];
} else {
compute_frame_info (thread, tls);
compute_frame_info (thread, tls, FALSE);
if (tls->frame_count)
frame = tls->frames [0];
......@@ -11115,7 +11115,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
mono_loader_unlock ();
g_assert (tls);
compute_frame_info (thread, tls);
compute_frame_info (thread, tls, TRUE); //the last parameter is TRUE to force that the frame info that will be send is synchronised with the debugged thread
buffer_add_int (buf, tls->frame_count);
for (i = 0; i < tls->frame_count; ++i) {
......@@ -11172,7 +11172,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
mono_loader_unlock ();
g_assert (tls);
compute_frame_info (thread, tls);
compute_frame_info (thread, tls, FALSE);
if (tls->frame_count == 0 || tls->frames [0]->actual_method != method)
return ERR_INVALID_ARGUMENT;
......@@ -11276,6 +11276,9 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
if (i == tls->frame_count)
return ERR_INVALID_FRAMEID;
/* The thread is still running native code, can't get frame variables info */
if (!tls->really_suspended && !tls->async_state.valid)
return ERR_NOT_SUSPENDED;
frame_idx = i;
frame = tls->frames [frame_idx];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册