@@ -379,7 +379,11 @@ public TypeInfoWithDebugInformation(TypeInfo typeInfo, int debugId, string name)
379
379
380
380
internal class MonoBinaryReader : BinaryReader
381
381
{
382
- public MonoBinaryReader ( Stream stream ) : base ( stream ) { }
382
+ public bool HasError { get ; }
383
+ public MonoBinaryReader ( Stream stream , bool hasError = false ) : base ( stream )
384
+ {
385
+ HasError = hasError ;
386
+ }
383
387
384
388
internal static unsafe void PutBytesBE ( byte * dest , byte * src , int count )
385
389
{
@@ -656,9 +660,9 @@ internal class MonoSDBHelper
656
660
private static int MINOR_VERSION = 61 ;
657
661
private static int MAJOR_VERSION = 2 ;
658
662
659
- private Dictionary < int , MethodInfoWithDebugInformation > methods = new ( ) ;
660
- private Dictionary < int , AssemblyInfo > assemblies = new ( ) ;
661
- private Dictionary < int , TypeInfoWithDebugInformation > types = new ( ) ;
663
+ private Dictionary < int , MethodInfoWithDebugInformation > methods ;
664
+ private Dictionary < int , AssemblyInfo > assemblies ;
665
+ private Dictionary < int , TypeInfoWithDebugInformation > types ;
662
666
663
667
internal Dictionary < int , ValueTypeClass > valueTypes = new Dictionary < int , ValueTypeClass > ( ) ;
664
668
internal Dictionary < int , PointerValue > pointerValues = new Dictionary < int , PointerValue > ( ) ;
@@ -673,12 +677,16 @@ public MonoSDBHelper(MonoProxy proxy, ILogger logger)
673
677
{
674
678
this . proxy = proxy ;
675
679
this . logger = logger ;
676
- this . store = null ;
680
+ ResetStore ( null ) ;
677
681
}
678
682
679
- public void SetStore ( DebugStore store )
683
+ public void ResetStore ( DebugStore store )
680
684
{
681
685
this . store = store ;
686
+ this . methods = new ( ) ;
687
+ this . assemblies = new ( ) ;
688
+ this . types = new ( ) ;
689
+ ClearCache ( ) ;
682
690
}
683
691
684
692
public async Task < AssemblyInfo > GetAssemblyInfo ( SessionId sessionId , int assemblyId , CancellationToken token )
@@ -816,12 +824,12 @@ public async Task<bool> EnableReceiveRequests(SessionId sessionId, EventKind eve
816
824
internal async Task < MonoBinaryReader > SendDebuggerAgentCommandInternal ( SessionId sessionId , int command_set , int command , MemoryStream parms , CancellationToken token )
817
825
{
818
826
Result res = await proxy . SendMonoCommand ( sessionId , MonoCommands . SendDebuggerAgentCommand ( GetId ( ) , command_set , command , Convert . ToBase64String ( parms . ToArray ( ) ) ) , token ) ;
819
- if ( res . IsErr ) {
820
- throw new Exception ( $ "SendDebuggerAgentCommand Error - { ( CommandSet ) command_set } - { command } ") ;
827
+ byte [ ] newBytes = Array . Empty < byte > ( ) ;
828
+ if ( ! res . IsErr ) {
829
+ newBytes = Convert . FromBase64String ( res . Value ? [ "result" ] ? [ "value" ] ? [ "value" ] ? . Value < string > ( ) ) ;
821
830
}
822
- byte [ ] newBytes = Convert . FromBase64String ( res . Value ? [ "result" ] ? [ "value" ] ? [ "value" ] ? . Value < string > ( ) ) ;
823
831
var retDebuggerCmd = new MemoryStream ( newBytes ) ;
824
- var retDebuggerCmdReader = new MonoBinaryReader ( retDebuggerCmd ) ;
832
+ var retDebuggerCmdReader = new MonoBinaryReader ( retDebuggerCmd , res . IsErr ) ;
825
833
return retDebuggerCmdReader ;
826
834
}
827
835
@@ -854,12 +862,12 @@ internal Task<MonoBinaryReader> SendDebuggerAgentCommandWithParms<T>(SessionId s
854
862
internal async Task < MonoBinaryReader > SendDebuggerAgentCommandWithParmsInternal ( SessionId sessionId , int command_set , int command , MemoryStream parms , int type , string extraParm , CancellationToken token )
855
863
{
856
864
Result res = await proxy . SendMonoCommand ( sessionId , MonoCommands . SendDebuggerAgentCommandWithParms ( GetId ( ) , command_set , command , Convert . ToBase64String ( parms . ToArray ( ) ) , parms . ToArray ( ) . Length , type , extraParm ) , token ) ;
857
- if ( res . IsErr ) {
858
- throw new Exception ( "SendDebuggerAgentCommandWithParms Error" ) ;
865
+ byte [ ] newBytes = Array . Empty < byte > ( ) ;
866
+ if ( ! res . IsErr ) {
867
+ newBytes = Convert . FromBase64String ( res . Value ? [ "result" ] ? [ "value" ] ? [ "value" ] ? . Value < string > ( ) ) ;
859
868
}
860
- byte [ ] newBytes = Convert . FromBase64String ( res . Value ? [ "result" ] ? [ "value" ] ? [ "value" ] ? . Value < string > ( ) ) ;
861
869
var retDebuggerCmd = new MemoryStream ( newBytes ) ;
862
- var retDebuggerCmdReader = new MonoBinaryReader ( retDebuggerCmd ) ;
870
+ var retDebuggerCmdReader = new MonoBinaryReader ( retDebuggerCmd , res . IsErr ) ;
863
871
return retDebuggerCmdReader ;
864
872
}
865
873
@@ -2530,15 +2538,9 @@ public async Task<bool> SetVariableValue(SessionId sessionId, int thread_id, int
2530
2538
JArray locals = new JArray ( ) ;
2531
2539
retDebuggerCmdReader = await SendDebuggerAgentCommand < CmdFrame > ( sessionId , CmdFrame . GetValues , commandParams , token ) ;
2532
2540
int etype = retDebuggerCmdReader . ReadByte ( ) ;
2533
- try
2534
- {
2535
- retDebuggerCmdReader = await SendDebuggerAgentCommandWithParms < CmdFrame > ( sessionId , CmdFrame . SetValues , commandParams , etype , newValue , token ) ;
2536
- }
2537
- catch ( Exception )
2538
- {
2541
+ retDebuggerCmdReader = await SendDebuggerAgentCommandWithParms < CmdFrame > ( sessionId , CmdFrame . SetValues , commandParams , etype , newValue , token ) ;
2542
+ if ( retDebuggerCmdReader . HasError )
2539
2543
return false ;
2540
- }
2541
-
2542
2544
return true ;
2543
2545
}
2544
2546
}
0 commit comments