@@ -4782,6 +4782,19 @@ is_ip_protected (MonoMethodHeader *header, int offset)
47824782 return FALSE;
47834783}
47844784
4785+ static gboolean
4786+ should_insert_seq_point (TransformData * td )
4787+ {
4788+ //following the CoreCLR's algorithm for adding the sequence points
4789+ if ((* td -> ip == CEE_NOP ) ||
4790+ (* td -> ip == CEE_CALLVIRT ) ||
4791+ (* td -> ip == CEE_CALLI ) ||
4792+ (* td -> ip == CEE_CALL ) ||
4793+ (GPTRDIFF_TO_INT (td -> sp - td -> stack ) == 0 ))
4794+ return TRUE;
4795+ return FALSE;
4796+ }
4797+
47854798static gboolean
47864799generate_code (TransformData * td , MonoMethod * method , MonoMethodHeader * header , MonoGenericContext * generic_context , MonoError * error )
47874800{
@@ -4813,6 +4826,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
48134826 gboolean save_last_error = FALSE;
48144827 gboolean link_bblocks = TRUE;
48154828 gboolean inlining = td -> method != method ;
4829+ gboolean generate_enc_seq_points_without_debug_info = FALSE;
48164830 InterpBasicBlock * exit_bb = NULL ;
48174831
48184832 original_bb = bb = mono_basic_block_split (method , error , header );
@@ -4859,6 +4873,8 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
48594873 int n_il_offsets ;
48604874
48614875 mono_debug_get_seq_points (minfo , NULL , NULL , NULL , & sps , & n_il_offsets );
4876+ if (n_il_offsets == 0 )
4877+ generate_enc_seq_points_without_debug_info = mono_debug_generate_enc_seq_points_without_debug_info (minfo );
48624878 // FIXME: Free
48634879 seq_point_locs = mono_bitset_mem_new (mono_mempool_alloc0 (td -> mempool , mono_bitset_alloc_size (header -> code_size , 0 )), header -> code_size , 0 );
48644880 sym_seq_points = TRUE;
@@ -5084,6 +5100,9 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
50845100 WRITE64_INS (td -> last_ins , 0 , & counter );
50855101 }
50865102
5103+ if (G_UNLIKELY (generate_enc_seq_points_without_debug_info ) && should_insert_seq_point (td ))
5104+ last_seq_point = interp_add_ins (td , MINT_SDB_SEQ_POINT );
5105+
50875106 switch (* td -> ip ) {
50885107 case CEE_NOP :
50895108 /* lose it */
@@ -5353,7 +5372,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
53535372 if (!interp_transform_call (td , method , NULL , generic_context , constrained_class , readonly , error , TRUE, save_last_error , tailcall ))
53545373 goto exit ;
53555374
5356- if (need_seq_point ) {
5375+ if (need_seq_point && ! generate_enc_seq_points_without_debug_info ) {
53575376 // check if it is a nested call and remove the MONO_INST_NONEMPTY_STACK of the last breakpoint, only for non native methods
53585377 if (!(method -> flags & METHOD_IMPL_ATTRIBUTE_NATIVE )) {
53595378 if (emitted_funccall_seq_point ) {
0 commit comments