Skip to content

Commit a751963

Browse files
authored
Merge pull request #1306 from Unity-Technologies/unity-master-fix-1249172
[debugger] Fixing two crashes while debugging an Android app. (mono#13373) (unity case 1249172)
2 parents f46df39 + b58e3d0 commit a751963

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

mono/mini/debugger-agent.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -3519,7 +3519,7 @@ compute_frame_info_from (MonoInternalThread *thread, DebuggerTlsData *tls, MonoT
35193519
}
35203520

35213521
static void
3522-
compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls)
3522+
compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean force_update)
35233523
{
35243524
ComputeFramesUserData user_data;
35253525
GSList *tmp;
@@ -3528,7 +3528,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls)
35283528
MonoUnwindOptions opts = (MonoUnwindOptions)(MONO_UNWIND_DEFAULT | MONO_UNWIND_REG_LOCATIONS);
35293529

35303530
// FIXME: Locking on tls
3531-
if (tls->frames && tls->frames_up_to_date)
3531+
if (tls->frames && tls->frames_up_to_date && !force_update)
35323532
return;
35333533

35343534
DEBUG_PRINTF (1, "Frames for %p(tid=%lx):\n", thread, thread->tid);
@@ -5211,7 +5211,7 @@ static void ss_calculate_framecount (DebuggerTlsData *tls, MonoContext *ctx)
52115211
{
52125212
if (!tls->context.valid)
52135213
mono_thread_state_init_from_monoctx (&tls->context, ctx);
5214-
compute_frame_info (tls->thread, tls);
5214+
compute_frame_info (tls->thread, tls, FALSE);
52155215
}
52165216

52175217
static gboolean
@@ -6533,7 +6533,7 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI
65336533
mono_loader_lock ();
65346534
locked = TRUE;
65356535

6536-
compute_frame_info (tls->thread, tls);
6536+
compute_frame_info (tls->thread, tls, FALSE);
65376537
frames = tls->frames;
65386538
nframes = tls->frame_count;
65396539
}
@@ -6866,7 +6866,7 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte
68666866
if (frames && nframes)
68676867
frame = frames [0];
68686868
} else {
6869-
compute_frame_info (thread, tls);
6869+
compute_frame_info (thread, tls, FALSE);
68706870

68716871
if (tls->frame_count)
68726872
frame = tls->frames [0];
@@ -11189,7 +11189,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
1118911189
if (tls == NULL)
1119011190
return ERR_UNLOADED;
1119111191

11192-
compute_frame_info (thread, tls);
11192+
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
1119311193

1119411194
buffer_add_int (buf, tls->frame_count);
1119511195
for (i = 0; i < tls->frame_count; ++i) {
@@ -11246,7 +11246,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
1124611246
mono_loader_unlock ();
1124711247
g_assert (tls);
1124811248

11249-
compute_frame_info (thread, tls);
11249+
compute_frame_info (thread, tls, FALSE);
1125011250
if (tls->frame_count == 0 || tls->frames [0]->actual_method != method)
1125111251
return ERR_INVALID_ARGUMENT;
1125211252

@@ -11350,6 +11350,9 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
1135011350
if (i == tls->frame_count)
1135111351
return ERR_INVALID_FRAMEID;
1135211352

11353+
/* The thread is still running native code, can't get frame variables info */
11354+
if (!tls->really_suspended && !tls->async_state.valid)
11355+
return ERR_NOT_SUSPENDED;
1135311356
frame_idx = i;
1135411357
frame = tls->frames [frame_idx];
1135511358

0 commit comments

Comments
 (0)