@@ -286,9 +286,10 @@ typedef struct {
286
286
typedef struct {
287
287
const char * name ;
288
288
void (* connect ) (const char * address );
289
+ int (* wait_for_attach ) (void );
289
290
void (* close1 ) (void );
290
291
void (* close2 ) (void );
291
- gboolean (* send ) (void * buf , int len );
292
+ int (* send ) (void * buf , int len );
292
293
int (* recv ) (void * buf , int len );
293
294
} DebuggerTransport ;
294
295
@@ -1330,6 +1331,26 @@ socket_transport_accept (int socket_fd)
1330
1331
return conn_fd ;
1331
1332
}
1332
1333
1334
+ static int
1335
+ socket_transport_wait_for_attach (void )
1336
+ {
1337
+ if (listen_fd == -1 ) {
1338
+ DEBUG_PRINTF (1 , "[dbg] Invalid listening socket\n" );
1339
+ return 0 ;
1340
+ }
1341
+
1342
+ /* Block and wait for client connection */
1343
+ conn_fd = socket_transport_accept (listen_fd );
1344
+
1345
+ DEBUG_PRINTF (1 , "Accepted connection on %d\n" , conn_fd );
1346
+ if (conn_fd == -1 ) {
1347
+ DEBUG_PRINTF (1 , "[dbg] Bad client connection\n" );
1348
+ return 0 ;
1349
+ }
1350
+
1351
+ return 1 ;
1352
+ }
1353
+
1333
1354
static gboolean
1334
1355
socket_transport_send (void * data , int len )
1335
1356
{
@@ -1560,6 +1581,7 @@ register_socket_transport (void)
1560
1581
1561
1582
trans .name = "dt_socket" ;
1562
1583
trans .connect = socket_transport_connect ;
1584
+ trans .wait_for_attach = socket_transport_wait_for_attach ;
1563
1585
trans .close1 = socket_transport_close1 ;
1564
1586
trans .close2 = socket_transport_close2 ;
1565
1587
trans .send = socket_transport_send ;
@@ -1595,6 +1617,7 @@ register_socket_fd_transport (void)
1595
1617
/* This is the same as the 'dt_socket' transport, but receives an already connected socket fd */
1596
1618
trans .name = "socket-fd" ;
1597
1619
trans .connect = socket_fd_transport_connect ;
1620
+ trans .wait_for_attach = socket_transport_wait_for_attach ;
1598
1621
trans .close1 = socket_transport_close1 ;
1599
1622
trans .close2 = socket_transport_close2 ;
1600
1623
trans .send = socket_transport_send ;
@@ -1664,6 +1687,12 @@ transport_connect (const char *address)
1664
1687
transport -> connect (address );
1665
1688
}
1666
1689
1690
+ int
1691
+ transport_wait_for_attach (void )
1692
+ {
1693
+ return transport -> wait_for_attach ();
1694
+ }
1695
+
1667
1696
static void
1668
1697
transport_close1 (void )
1669
1698
{
@@ -3824,7 +3853,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv
3824
3853
break ;
3825
3854
}
3826
3855
#else
3827
- while (! found && (method = mono_class_get_methods (ei -> klass , & iter ))) {
3856
+ while ((method = mono_class_get_methods (ei -> klass , & iter ))) {
3828
3857
MonoDebugMethodInfo * minfo = mono_debug_lookup_method (method );
3829
3858
3830
3859
if (minfo ) {
@@ -5423,7 +5452,7 @@ static MonoMethod* notify_debugger_of_wait_completion_method_cache = NULL;
5423
5452
static MonoMethod *
5424
5453
get_notify_debugger_of_wait_completion_method (void )
5425
5454
{
5426
- #if IL2CPP_TINY
5455
+ #if IL2CPP_DOTS
5427
5456
return NULL ;
5428
5457
#else
5429
5458
if (notify_debugger_of_wait_completion_method_cache != NULL )
@@ -5436,7 +5465,7 @@ get_notify_debugger_of_wait_completion_method (void)
5436
5465
notify_debugger_of_wait_completion_method_cache = (MonoMethod * )g_ptr_array_index (array , 0 );
5437
5466
g_ptr_array_free (array , TRUE);
5438
5467
return notify_debugger_of_wait_completion_method_cache ;
5439
- #endif // IL2CPP_TINY
5468
+ #endif // IL2CPP_DOTS
5440
5469
}
5441
5470
5442
5471
#ifndef RUNTIME_IL2CPP
@@ -6823,20 +6852,27 @@ mono_debugger_agent_unhandled_exception (MonoException *exc)
6823
6852
#endif
6824
6853
6825
6854
#ifdef RUNTIME_IL2CPP
6826
- static Il2CppSequencePoint * il2cpp_find_catch_sequence_point_in_method ( Il2CppSequencePoint * callSp , MonoException * exc )
6855
+ static Il2CppCatchPoint * il2cpp_find_catch_point_in_method ( const MonoMethod * method , int8_t tryId , MonoException * exc )
6827
6856
{
6828
- uint8_t tryDepth = callSp -> tryDepth ;
6829
- MonoMethod * method = il2cpp_get_seq_point_method (callSp );
6830
- int32_t ilOffset = callSp -> ilOffset ;
6831
- Il2CppSequencePoint * sp ;
6857
+ Il2CppCatchPoint * cp ;
6858
+ int8_t nextId = tryId , id ;
6832
6859
6833
- void * seqPointIter = NULL ;
6834
- while (sp = il2cpp_get_method_sequence_points (method , & seqPointIter ))
6860
+ while (nextId >= 0 )
6835
6861
{
6836
- MonoClass * catchType = il2cpp_get_class_from_index (sp -> catchTypeIndex );
6837
- if (sp -> tryDepth == tryDepth && sp -> ilOffset > ilOffset && catchType != NULL && mono_class_is_assignable_from (catchType , mono_object_get_class (& exc -> object )))
6838
- return sp ;
6839
- }
6862
+ id = nextId ;
6863
+ nextId = -1 ;
6864
+ void * catchPointIter = NULL ;
6865
+ while (cp = il2cpp_get_method_catch_points (method , & catchPointIter ))
6866
+ {
6867
+ if (cp -> tryId == id )
6868
+ {
6869
+ MonoClass * catchType = il2cpp_get_class_from_index (cp -> catchTypeIndex );
6870
+ nextId = cp -> parentTryId ;
6871
+ if (catchType != NULL && mono_class_is_assignable_from (catchType , mono_object_get_class (& exc -> object )))
6872
+ return cp ;
6873
+ }
6874
+ }
6875
+ }
6840
6876
6841
6877
return NULL ;
6842
6878
}
@@ -6846,42 +6882,45 @@ static Il2CppSequencePoint* il2cpp_find_catch_sequence_point(DebuggerTlsData *tl
6846
6882
int frameIndex = tls -> il2cpp_context -> frameCount - 1 ;
6847
6883
while (frameIndex >= 0 )
6848
6884
{
6849
- Il2CppSequencePoint * sp = il2cpp_find_catch_sequence_point_in_method (tls -> il2cpp_context -> executionContexts [frameIndex ]-> currentSequencePoint , tls -> exception );
6850
- if (sp )
6851
- return sp ;
6885
+ Il2CppCatchPoint * cp = il2cpp_find_catch_point_in_method (tls -> il2cpp_context -> executionContexts [frameIndex ]-> method , tls -> il2cpp_context -> executionContexts [frameIndex ]-> tryId , tls -> exception );
6886
+ if (cp )
6887
+ {
6888
+ Il2CppSequencePoint * sp = il2cpp_get_seq_point_from_catch_point (cp );
6889
+ if (sp )
6890
+ return sp ;
6891
+ else
6892
+ return NULL ;
6893
+ }
6852
6894
6853
6895
-- frameIndex ;
6854
6896
}
6855
6897
6856
6898
return NULL ;
6857
6899
}
6858
6900
6859
- static Il2CppSequencePoint * il2cpp_find_catch_sequence_point_from_exeption (DebuggerTlsData * tls , MonoException * exc , Il2CppSequencePoint * firstSp )
6901
+ static void il2cpp_find_catch_sequence_point_from_exeption (DebuggerTlsData * tls , MonoException * exc , Il2CppCatchPoint * * catchPt , Il2CppSequencePoint * * seqPt )
6860
6902
{
6861
- Il2CppSequencePoint * sp ;
6862
-
6863
- if (firstSp )
6864
- {
6865
- sp = il2cpp_find_catch_sequence_point_in_method (firstSp , exc );
6866
- if (sp )
6867
- return sp ;
6868
- }
6903
+ * catchPt = NULL ;
6904
+ * seqPt = NULL ;
6869
6905
6870
6906
int frameIndex = tls -> il2cpp_context -> frameCount - 1 ;
6871
6907
while (frameIndex >= 0 )
6872
6908
{
6873
- sp = il2cpp_find_catch_sequence_point_in_method (tls -> il2cpp_context -> executionContexts [frameIndex ]-> currentSequencePoint , exc );
6874
- if (sp )
6875
- return sp ;
6909
+ * catchPt = il2cpp_find_catch_point_in_method (tls -> il2cpp_context -> executionContexts [frameIndex ]-> method , tls -> il2cpp_context -> executionContexts [frameIndex ]-> tryId , exc );
6910
+ if (* catchPt )
6911
+ {
6912
+ * seqPt = il2cpp_get_seq_point_from_catch_point (* catchPt );
6913
+ return ;
6914
+ }
6876
6915
6877
6916
-- frameIndex ;
6878
6917
}
6879
6918
6880
- return NULL ;
6919
+ return ;
6881
6920
}
6882
6921
6883
6922
void
6884
- unity_debugger_agent_handle_exception (MonoException * exc , Il2CppSequencePoint * sequencePoint )
6923
+ unity_debugger_agent_handle_exception (MonoException * exc )
6885
6924
{
6886
6925
int i , j , suspend_policy ;
6887
6926
GSList * events ;
@@ -6906,18 +6945,19 @@ unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *s
6906
6945
6907
6946
ei .exc = (MonoObject * )exc ;
6908
6947
ei .caught = FALSE;
6909
- Il2CppSequencePoint * catchSp = NULL ;
6948
+ Il2CppCatchPoint * catchPt ;
6949
+ Il2CppSequencePoint * seqPt ;
6910
6950
6911
6951
if (tls )
6912
6952
{
6913
- catchSp = il2cpp_find_catch_sequence_point_from_exeption (tls , exc , sequencePoint );
6914
- if (catchSp )
6953
+ il2cpp_find_catch_sequence_point_from_exeption (tls , exc , & catchPt , & seqPt );
6954
+ if (catchPt )
6915
6955
ei .caught = TRUE;
6916
6956
}
6917
6957
6918
6958
mono_loader_lock ();
6919
6959
6920
- MonoMethod * sp_method = il2cpp_get_seq_point_method ( sequencePoint ) ;
6960
+ MonoMethod * method = tls -> il2cpp_context -> executionContexts [ tls -> il2cpp_context -> frameCount - 1 ] -> method ;
6921
6961
6922
6962
/* Treat exceptions which are caught in non-user code as unhandled */
6923
6963
for (i = 0 ; i < event_requests -> len ; ++ i )
@@ -6930,7 +6970,7 @@ unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *s
6930
6970
{
6931
6971
Modifier * mod = & req -> modifiers [j ];
6932
6972
6933
- if (mod -> kind == MOD_KIND_ASSEMBLY_ONLY && sequencePoint )
6973
+ if (mod -> kind == MOD_KIND_ASSEMBLY_ONLY && method )
6934
6974
{
6935
6975
int k ;
6936
6976
gboolean found = FALSE;
@@ -6939,7 +6979,7 @@ unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *s
6939
6979
if (assemblies )
6940
6980
{
6941
6981
for (k = 0 ; assemblies [k ]; ++ k )
6942
- if (assemblies [k ] == mono_image_get_assembly (mono_class_get_image (mono_method_get_class (sp_method ))))
6982
+ if (assemblies [k ] == mono_image_get_assembly (mono_class_get_image (mono_method_get_class (method ))))
6943
6983
found = TRUE;
6944
6984
}
6945
6985
if (!found )
@@ -6955,11 +6995,11 @@ unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *s
6955
6995
{
6956
6996
if (!ss_req || !ss_req -> bps ) {
6957
6997
tls -> exception = exc ;
6958
- } else if (ss_req -> bps && catchSp ) {
6998
+ } else if (ss_req -> bps && seqPt ) {
6959
6999
int ss_req_bp_count = g_slist_length (ss_req -> bps );
6960
7000
GHashTable * ss_req_bp_cache = NULL ;
6961
7001
6962
- ss_bp_add_one_il2cpp (ss_req , & ss_req_bp_count , & ss_req_bp_cache , catchSp );
7002
+ ss_bp_add_one_il2cpp (ss_req , & ss_req_bp_count , & ss_req_bp_cache , seqPt );
6963
7003
6964
7004
if (ss_req_bp_cache )
6965
7005
g_hash_table_destroy (ss_req_bp_cache );
@@ -11892,19 +11932,8 @@ static gboolean
11892
11932
wait_for_attach (void )
11893
11933
{
11894
11934
#ifndef DISABLE_SOCKET_TRANSPORT
11895
- if (listen_fd == -1 ) {
11896
- DEBUG_PRINTF (1 , "[dbg] Invalid listening socket\n" );
11897
- return FALSE;
11898
- }
11899
-
11900
- /* Block and wait for client connection */
11901
- conn_fd = socket_transport_accept (listen_fd );
11902
-
11903
- DEBUG_PRINTF (1 , "Accepted connection on %d\n" , conn_fd );
11904
- if (conn_fd == -1 ) {
11905
- DEBUG_PRINTF (1 , "[dbg] Bad client connection\n" );
11935
+ if (!transport_wait_for_attach ())
11906
11936
return FALSE;
11907
- }
11908
11937
#else
11909
11938
g_assert_not_reached ();
11910
11939
#endif
0 commit comments