@@ -223,7 +223,7 @@ async Task OnRuntimeReady (CancellationToken token)
223
223
Info ( "RUNTIME READY, PARTY TIME" ) ;
224
224
await RuntimeReady ( token ) ;
225
225
await SendCommand ( "Debugger.resume" , new JObject ( ) , token ) ;
226
- SendEvent ( "Mono.runtimeReady" , new JObject ( ) , token ) ;
226
+ SendEvent ( "Mono.runtimeReady" , new JObject ( ) , token ) ;
227
227
}
228
228
229
229
async Task OnBreakPointHit ( JObject args , CancellationToken token )
@@ -274,12 +274,18 @@ async Task OnBreakPointHit (JObject args, CancellationToken token)
274
274
var frames = new List < Frame > ( ) ;
275
275
int frame_id = 0 ;
276
276
var the_mono_frames = res . Value ? [ "result" ] ? [ "value" ] ? [ "frames" ] ? . Values < JObject > ( ) ;
277
+
277
278
foreach ( var mono_frame in the_mono_frames ) {
278
279
var il_pos = mono_frame [ "il_pos" ] . Value < int > ( ) ;
279
280
var method_token = mono_frame [ "method_token" ] . Value < int > ( ) ;
280
281
var assembly_name = mono_frame [ "assembly_name" ] . Value < string > ( ) ;
281
282
282
283
var asm = store . GetAssemblyByName ( assembly_name ) ;
284
+ if ( asm == null ) {
285
+ Info ( $ "Unable to find assembly: { assembly_name } ") ;
286
+ continue ;
287
+ }
288
+
283
289
var method = asm . GetMethodByToken ( method_token ) ;
284
290
285
291
if ( method == null ) {
@@ -374,7 +380,7 @@ async Task OnDefaultContext (int ctx_id, JObject aux_data, CancellationToken tok
374
380
//Debug ($"\t{is_ready}");
375
381
if ( is_ready . HasValue && is_ready . Value == true ) {
376
382
Debug ( "RUNTIME LOOK READY. GO TIME!" ) ;
377
- await RuntimeReady ( token ) ;
383
+ await OnRuntimeReady ( token ) ;
378
384
}
379
385
}
380
386
@@ -426,33 +432,38 @@ async Task GetDetails(int msg_id, int object_id, CancellationToken token, string
426
432
return ;
427
433
}
428
434
429
- var values = res . Value ? [ "result" ] ? [ "value" ] ? . Values < JObject > ( ) . ToArray ( ) ;
435
+ try {
436
+ var values = res . Value ? [ "result" ] ? [ "value" ] ? . Values < JObject > ( ) . ToArray ( ) ?? Array . Empty < JObject > ( ) ;
437
+ var var_list = new List < JObject > ( ) ;
438
+
439
+ // Trying to inspect the stack frame for DotNetDispatcher::InvokeSynchronously
440
+ // results in a "Memory access out of bounds", causing 'values' to be null,
441
+ // so skip returning variable values in that case.
442
+ for ( int i = 0 ; i < values . Length ; i += 2 )
443
+ {
444
+ string fieldName = ( string ) values [ i ] [ "name" ] ;
445
+ if ( fieldName . Contains ( "k__BackingField" ) ) {
446
+ fieldName = fieldName . Replace ( "k__BackingField" , "" ) ;
447
+ fieldName = fieldName . Replace ( "<" , "" ) ;
448
+ fieldName = fieldName . Replace ( ">" , "" ) ;
449
+ }
450
+ var value = values [ i + 1 ] ? [ "value" ] ;
451
+ if ( ( ( string ) value [ "description" ] ) == null )
452
+ value [ "description" ] = value [ "value" ] ? . ToString ( ) ;
430
453
431
- var var_list = new List < JObject > ( ) ;
432
-
433
- // Trying to inspect the stack frame for DotNetDispatcher::InvokeSynchronously
434
- // results in a "Memory access out of bounds", causing 'values' to be null,
435
- // so skip returning variable values in that case.
436
- for ( int i = 0 ; i < values . Length ; i += 2 )
437
- {
438
- string fieldName = ( string ) values [ i ] [ "name" ] ;
439
- if ( fieldName . Contains ( "k__BackingField" ) ) {
440
- fieldName = fieldName . Replace ( "k__BackingField" , "" ) ;
441
- fieldName = fieldName . Replace ( "<" , "" ) ;
442
- fieldName = fieldName . Replace ( ">" , "" ) ;
443
- }
444
- var_list . Add ( JObject . FromObject ( new
445
- {
446
- name = fieldName ,
447
- value = values [ i + 1 ] [ "value" ]
448
- } ) ) ;
454
+ var_list . Add ( JObject . FromObject ( new {
455
+ name = fieldName ,
456
+ value
457
+ } ) ) ;
449
458
459
+ }
460
+ o = JObject . FromObject ( new
461
+ {
462
+ result = var_list
463
+ } ) ;
464
+ } catch ( Exception e ) {
465
+ Debug ( $ "failed to parse { res . Value } ") ;
450
466
}
451
- o = JObject . FromObject ( new
452
- {
453
- result = var_list
454
- } ) ;
455
-
456
467
SendResponse ( msg_id , Result . Ok ( o ) , token ) ;
457
468
}
458
469
@@ -481,41 +492,51 @@ async Task GetScopeProperties (int msg_id, int scope_id, CancellationToken token
481
492
return ;
482
493
}
483
494
484
- var values = res . Value ? [ "result" ] ? [ "value" ] ? . Values < JObject > ( ) . ToArray ( ) ;
485
-
486
- var var_list = new List < JObject > ( ) ;
487
- int i = 0 ;
488
- // Trying to inspect the stack frame for DotNetDispatcher::InvokeSynchronously
489
- // results in a "Memory access out of bounds", causing 'values' to be null,
490
- // so skip returning variable values in that case.
491
- while ( values != null && i < vars . Length && i < values . Length ) {
492
- var value = values [ i ] [ "value" ] ;
493
- if ( ( ( string ) value [ "description" ] ) == null )
494
- value [ "description" ] = value [ "value" ] ? . ToString ( ) ;
495
-
496
- var_list . Add ( JObject . FromObject ( new {
497
- name = vars [ i ] . Name ,
498
- value = values [ i ] [ "value" ]
499
- } ) ) ;
500
- i ++ ;
495
+ try {
496
+ var values = res . Value ? [ "result" ] ? [ "value" ] ? . Values < JObject > ( ) . ToArray ( ) ;
497
+
498
+ var var_list = new List < JObject > ( ) ;
499
+ int i = 0 ;
500
+ // Trying to inspect the stack frame for DotNetDispatcher::InvokeSynchronously
501
+ // results in a "Memory access out of bounds", causing 'values' to be null,
502
+ // so skip returning variable values in that case.
503
+ while ( values != null && i < vars . Length && i < values . Length ) {
504
+ var value = values [ i ] [ "value" ] ;
505
+ if ( ( ( string ) value [ "description" ] ) == null )
506
+ value [ "description" ] = value [ "value" ] ? . ToString ( ) ;
507
+
508
+ var_list . Add ( JObject . FromObject ( new {
509
+ name = vars [ i ] . Name ,
510
+ value
511
+ } ) ) ;
512
+ i ++ ;
513
+ }
514
+ //Async methods are special in the way that local variables can be lifted to generated class fields
515
+ //value of "this" comes here either
516
+ while ( i < values . Length ) {
517
+ String name = values [ i ] [ "name" ] . ToString ( ) ;
518
+
519
+ if ( name . IndexOf ( ">" , StringComparison . Ordinal ) > 0 )
520
+ name = name . Substring ( 1 , name . IndexOf ( ">" , StringComparison . Ordinal ) - 1 ) ;
521
+
522
+ var value = values [ i + 1 ] [ "value" ] ;
523
+ if ( ( ( string ) value [ "description" ] ) == null )
524
+ value [ "description" ] = value [ "value" ] ? . ToString ( ) ;
525
+
526
+ var_list . Add ( JObject . FromObject ( new {
527
+ name ,
528
+ value
529
+ } ) ) ;
530
+ i = i + 2 ;
531
+ }
532
+ o = JObject . FromObject ( new {
533
+ result = var_list
534
+ } ) ;
535
+ SendResponse ( msg_id , Result . Ok ( o ) , token ) ;
501
536
}
502
- //Async methods are special in the way that local variables can be lifted to generated class fields
503
- //value of "this" comes here either
504
- while ( i < values . Length ) {
505
- String name = values [ i ] [ "name" ] . ToString ( ) ;
506
-
507
- if ( name . IndexOf ( ">" , StringComparison . Ordinal ) > 0 )
508
- name = name . Substring ( 1 , name . IndexOf ( ">" , StringComparison . Ordinal ) - 1 ) ;
509
- var_list . Add ( JObject . FromObject ( new {
510
- name = name ,
511
- value = values [ i + 1 ] [ "value" ]
512
- } ) ) ;
513
- i = i + 2 ;
537
+ catch ( Exception exc ) {
538
+ SendResponse ( msg_id , res , token ) ;
514
539
}
515
- o = JObject . FromObject ( new {
516
- result = var_list
517
- } ) ;
518
- SendResponse ( msg_id , Result . Ok ( o ) , token ) ;
519
540
}
520
541
521
542
async Task < Result > EnableBreakPoint ( Breakpoint bp , CancellationToken token )
0 commit comments