Skip to content

Commit 4da283c

Browse files
authored
[mono][debugger] Fix assertion when stepping (#118458)
This PR fixes assertion failures when stepping in the Mono debugger on ARM64 by aligning the breakpoint address calculation logic with the AMD64 implementation. The changes remove the division by 4 that was causing incorrect indexing into the breakpoint addresses array.
1 parent fdf73d8 commit 4da283c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/mono/mono/mini/mini-arm64.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4203,8 +4203,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
42034203
guint32 val;
42044204

42054205
arm_ldrx (code, ARMREG_IP1, info_var->inst_basereg, GTMREG_TO_INT (info_var->inst_offset));
4206-
/* Add the bp_tramp_offset */
4207-
val = ((bp_tramp_offset / 4) * sizeof (target_mgreg_t)) + MONO_STRUCT_OFFSET (SeqPointInfo, bp_addrs);
4206+
val = (bp_tramp_offset * sizeof (target_mgreg_t)) + MONO_STRUCT_OFFSET (SeqPointInfo, bp_addrs);
42084207
/* Load the info->bp_addrs [bp_tramp_offset], which is either 0 or the address of the bp trampoline */
42094208
code = emit_ldrx (code, ARMREG_IP1, ARMREG_IP1, val);
42104209
/* Skip the load if its 0 */
@@ -6876,9 +6875,7 @@ mono_arch_set_breakpoint (MonoJitInfo *ji, guint8 *ip)
68766875

68776876
if (enable_ptrauth)
68786877
NOT_IMPLEMENTED;
6879-
g_assert (native_offset % 4 == 0);
6880-
g_assert (info->bp_addrs [native_offset / 4] == 0);
6881-
info->bp_addrs [native_offset / 4] = (guint8*)mini_get_breakpoint_trampoline ();
6878+
info->bp_addrs [native_offset] = (guint8*)mini_get_breakpoint_trampoline ();
68826879
} else {
68836880
/* ip points to an ldrx */
68846881
code += 4;
@@ -6901,8 +6898,7 @@ mono_arch_clear_breakpoint (MonoJitInfo *ji, guint8 *ip)
69016898
if (enable_ptrauth)
69026899
NOT_IMPLEMENTED;
69036900

6904-
g_assert (native_offset % 4 == 0);
6905-
info->bp_addrs [native_offset / 4] = NULL;
6901+
info->bp_addrs [native_offset] = NULL;
69066902
} else {
69076903
/* ip points to an ldrx */
69086904
code += 4;

0 commit comments

Comments
 (0)