Skip to content

Commit 37ff3f5

Browse files
author
brianradunity
authored
IL2CPP debugger fixes for working with Unity players (#772)
* IL2CPP debugger fixes for working with Unity players * Ignoring setp_out sequence points when searching for sequence points that don't correspond to step_out requests. * Not returning step_out sequence points when retrieving method debug info. The step out sequence points have the same offset as other sequence points, but different line numbers. * Hardened the il2cpp_mono_free_method_signatures() function against multiple calls by setting the method_signatures hash table to null after it is cleared. * The isActive field in Il2CppSequencePoint should be a uint8_t, not a bool, as it gets incremented. I think this change was made in the previous C-only type for this struct but not propagated to the C++ version, which is the only version we use now. * Fixed missed issue with duplicate inner loop variable
1 parent cae4850 commit 37ff3f5

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

mono/mini/debugger-agent.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4756,6 +4756,16 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError
47564756
{
47574757
if (bp_matches_method(bp, seqPoint->method) && seqPoint->ilOffset == bp->il_offset)
47584758
{
4759+
if (req->event_kind == EVENT_KIND_BREAKPOINT && seqPoint->kind == kSequencePointKind_StepOut)
4760+
continue;
4761+
4762+
if (req->event_kind == EVENT_KIND_STEP)
4763+
{
4764+
SingleStepReq *ssreq = (SingleStepReq*)req->info;
4765+
if (ssreq->depth == STEP_DEPTH_OUT && seqPoint->kind != kSequencePointKind_StepOut)
4766+
continue;
4767+
}
4768+
47594769
BreakpointInstance* inst = g_new0(BreakpointInstance, 1);
47604770
inst->il_offset = bp->il_offset;// it.seq_point.il_offset;
47614771
inst->native_offset = 0;// it.seq_point.native_offset;
@@ -10282,10 +10292,25 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
1028210292
buffer_add_string(buf, "");
1028310293
}
1028410294
}
10285-
buffer_add_int(buf, sequencePoints->len);
10295+
10296+
int numSeqPoints = 0;
10297+
10298+
for (i = 0; i < sequencePoints->len; ++i) {
10299+
Il2CppSequencePoint* sequencePoint = g_ptr_array_index(sequencePoints, i);
10300+
if (sequencePoint->kind == kSequencePointKind_StepOut)
10301+
continue;
10302+
else
10303+
++numSeqPoints;
10304+
}
10305+
10306+
buffer_add_int(buf, numSeqPoints);
1028610307
DEBUG_PRINTF(10, "Line number table for method %s:\n", mono_method_full_name(method, TRUE));
1028710308
for (i = 0; i < sequencePoints->len; ++i) {
1028810309
Il2CppSequencePoint* sequencePoint = g_ptr_array_index(sequencePoints, i);
10310+
10311+
if (sequencePoint->kind == kSequencePointKind_StepOut)
10312+
continue;
10313+
1028910314
DEBUG_PRINTF(10, "IL%x -> %s:%d %d %d %d\n", sequencePoint->ilOffset, sequencePoint->sourceFile,
1029010315
sequencePoint->lineStart, sequencePoint->columnStart, sequencePoint->lineEnd, sequencePoint->columnEnd);
1029110316
buffer_add_int(buf, sequencePoint->ilOffset);
@@ -12048,10 +12073,10 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp
1204812073
inst = (BreakpointInstance *)g_ptr_array_index(bp->children, j);
1204912074
if (inst->il_offset == sequencePoint->ilOffset) {
1205012075
if (bp->req->event_kind == EVENT_KIND_STEP) {
12051-
for (int j = 0; j < bp->children->len; ++j)
12076+
for (int k = 0; k < bp->children->len; ++k)
1205212077
{
12053-
BreakpointInstance *inst = (BreakpointInstance *)g_ptr_array_index(bp->children, j);
12054-
if (inst->seq_point == sequencePoint)
12078+
BreakpointInstance *inst1 = (BreakpointInstance *)g_ptr_array_index(bp->children, k);
12079+
if (inst1->seq_point == sequencePoint)
1205512080
{
1205612081
g_ptr_array_add(ss_reqs_orig, bp->req);
1205712082
break;

mono/mini/il2cpp-stubs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ void il2cpp_mono_free_method_signatures()
141141
{
142142
mono_g_hash_table_foreach(method_signatures, il2cpp_mono_free_method_signature, NULL);
143143
mono_g_hash_table_destroy(method_signatures);
144+
method_signatures = NULL;
144145
}
145146
}
146147

0 commit comments

Comments
 (0)