@@ -379,7 +379,11 @@ public TypeInfoWithDebugInformation(TypeInfo typeInfo, int debugId, string name)
379379
380380 internal class MonoBinaryReader : BinaryReader
381381 {
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+ }
383387
384388 internal static unsafe void PutBytesBE ( byte * dest , byte * src , int count )
385389 {
@@ -656,9 +660,9 @@ internal class MonoSDBHelper
656660 private static int MINOR_VERSION = 61 ;
657661 private static int MAJOR_VERSION = 2 ;
658662
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 ;
662666
663667 internal Dictionary < int , ValueTypeClass > valueTypes = new Dictionary < int , ValueTypeClass > ( ) ;
664668 internal Dictionary < int , PointerValue > pointerValues = new Dictionary < int , PointerValue > ( ) ;
@@ -673,12 +677,16 @@ public MonoSDBHelper(MonoProxy proxy, ILogger logger)
673677 {
674678 this . proxy = proxy ;
675679 this . logger = logger ;
676- this . store = null ;
680+ ResetStore ( null ) ;
677681 }
678682
679- public void SetStore ( DebugStore store )
683+ public void ResetStore ( DebugStore store )
680684 {
681685 this . store = store ;
686+ this . methods = new ( ) ;
687+ this . assemblies = new ( ) ;
688+ this . types = new ( ) ;
689+ ClearCache ( ) ;
682690 }
683691
684692 public async Task < AssemblyInfo > GetAssemblyInfo ( SessionId sessionId , int assemblyId , CancellationToken token )
@@ -816,12 +824,12 @@ public async Task<bool> EnableReceiveRequests(SessionId sessionId, EventKind eve
816824 internal async Task < MonoBinaryReader > SendDebuggerAgentCommandInternal ( SessionId sessionId , int command_set , int command , MemoryStream parms , CancellationToken token )
817825 {
818826 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 > ( ) ) ;
821830 }
822- byte [ ] newBytes = Convert . FromBase64String ( res . Value ? [ "result" ] ? [ "value" ] ? [ "value" ] ? . Value < string > ( ) ) ;
823831 var retDebuggerCmd = new MemoryStream ( newBytes ) ;
824- var retDebuggerCmdReader = new MonoBinaryReader ( retDebuggerCmd ) ;
832+ var retDebuggerCmdReader = new MonoBinaryReader ( retDebuggerCmd , res . IsErr ) ;
825833 return retDebuggerCmdReader ;
826834 }
827835
@@ -854,12 +862,12 @@ internal Task<MonoBinaryReader> SendDebuggerAgentCommandWithParms<T>(SessionId s
854862 internal async Task < MonoBinaryReader > SendDebuggerAgentCommandWithParmsInternal ( SessionId sessionId , int command_set , int command , MemoryStream parms , int type , string extraParm , CancellationToken token )
855863 {
856864 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 > ( ) ) ;
859868 }
860- byte [ ] newBytes = Convert . FromBase64String ( res . Value ? [ "result" ] ? [ "value" ] ? [ "value" ] ? . Value < string > ( ) ) ;
861869 var retDebuggerCmd = new MemoryStream ( newBytes ) ;
862- var retDebuggerCmdReader = new MonoBinaryReader ( retDebuggerCmd ) ;
870+ var retDebuggerCmdReader = new MonoBinaryReader ( retDebuggerCmd , res . IsErr ) ;
863871 return retDebuggerCmdReader ;
864872 }
865873
@@ -2530,15 +2538,9 @@ public async Task<bool> SetVariableValue(SessionId sessionId, int thread_id, int
25302538 JArray locals = new JArray ( ) ;
25312539 retDebuggerCmdReader = await SendDebuggerAgentCommand < CmdFrame > ( sessionId , CmdFrame . GetValues , commandParams , token ) ;
25322540 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 )
25392543 return false ;
2540- }
2541-
25422544 return true ;
25432545 }
25442546 }
0 commit comments