@@ -5345,7 +5345,10 @@ get_set_notification_method (MonoClass* async_builder_class)
5345
5345
MonoError error ;
5346
5346
GPtrArray * array = mono_class_get_methods_by_name (async_builder_class , "SetNotificationForWaitCompletion" , 0x24 , FALSE, FALSE, & error );
5347
5347
mono_error_assert_ok (& error );
5348
- g_assert (array -> len == 1 );
5348
+ if (array -> len == 0 ) {
5349
+ g_ptr_array_free (array , TRUE);
5350
+ return NULL ;
5351
+ }
5349
5352
MonoMethod * set_notification_method = (MonoMethod * )g_ptr_array_index (array , 0 );
5350
5353
g_ptr_array_free (array , TRUE);
5351
5354
return set_notification_method ;
@@ -5431,7 +5434,9 @@ get_this_async_id (StackFrame *frame)
5431
5434
return get_objid (obj );
5432
5435
}
5433
5436
5434
- static void
5437
+ // Returns true if TaskBuilder has NotifyDebuggerOfWaitCompletion method
5438
+ // false if not(AsyncVoidBuilder)
5439
+ static gboolean
5435
5440
set_set_notification_for_wait_completion_flag (StackFrame * frame )
5436
5441
{
5437
5442
MonoClassField * builder_field = mono_class_get_field_from_name (frame -> method -> klass , "<>t__builder" );
@@ -5443,11 +5448,15 @@ set_set_notification_for_wait_completion_flag (StackFrame *frame)
5443
5448
gboolean arg = TRUE;
5444
5449
MonoError error ;
5445
5450
args [0 ] = & arg ;
5446
- mono_runtime_invoke_checked (get_set_notification_method (mono_class_from_mono_type (mono_field_get_type (builder_field ))), builder , args , & error );
5451
+ MonoMethod * method = get_set_notification_method (mono_class_from_mono_type (mono_field_get_type (builder_field )));
5452
+ if (method == NULL )
5453
+ return FALSE;
5454
+ mono_runtime_invoke_checked (method , builder , args , & error );
5447
5455
mono_error_assert_ok (& error );
5456
+ return TRUE;
5448
5457
}
5449
5458
5450
- static MonoMethod * notify_debugger_of_wait_completion_method_cache = NULL ;
5459
+ static MonoMethod * notify_debugger_of_wait_completion_method_cache ;
5451
5460
5452
5461
static MonoMethod *
5453
5462
get_notify_debugger_of_wait_completion_method (void )
@@ -6438,14 +6447,16 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI
6438
6447
ss_req -> depth = STEP_DEPTH_OUT ;//setting depth to step-out is important, don't inline IF, because code later depends on this
6439
6448
}
6440
6449
if (ss_req -> depth == STEP_DEPTH_OUT ) {
6441
- set_set_notification_for_wait_completion_flag (frames [0 ]);
6442
- ss_req -> async_id = get_this_async_id (frames [0 ]);
6443
- ss_req -> async_stepout_method = get_notify_debugger_of_wait_completion_method ();
6444
- ss_bp_add_one (ss_req , & ss_req_bp_count , & ss_req_bp_cache , ss_req -> async_stepout_method , 0 );
6445
- if (ss_req_bp_cache )
6446
- g_hash_table_destroy (ss_req_bp_cache );
6447
- mono_debug_free_method_async_debug_info (asyncMethod );
6448
- return ;
6450
+ //If we are inside `async void` method, do normal step-out
6451
+ if (set_set_notification_for_wait_completion_flag (frames [0 ])) {
6452
+ ss_req -> async_id = get_this_async_id (frames [0 ]);
6453
+ ss_req -> async_stepout_method = get_notify_debugger_of_wait_completion_method ();
6454
+ ss_bp_add_one (ss_req , & ss_req_bp_count , & ss_req_bp_cache , ss_req -> async_stepout_method , 0 );
6455
+ if (ss_req_bp_cache )
6456
+ g_hash_table_destroy (ss_req_bp_cache );
6457
+ mono_debug_free_method_async_debug_info (asyncMethod );
6458
+ return ;
6459
+ }
6449
6460
}
6450
6461
}
6451
6462
0 commit comments