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

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

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions mono/mini/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -3519,7 +3519,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;
Expand All @@ -3528,7 +3528,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);
Expand Down Expand Up @@ -5211,7 +5211,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
Expand Down Expand Up @@ -6533,7 +6533,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;
}
Expand Down Expand Up @@ -6866,7 +6866,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];
Expand Down Expand Up @@ -11189,7 +11189,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
if (tls == NULL)
return ERR_UNLOADED;

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) {
Expand Down Expand Up @@ -11246,7 +11246,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;

Expand Down Expand Up @@ -11350,6 +11350,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];

Expand Down