@@ -27,13 +27,15 @@ public class DebugSession : ICDPListener, IDebuggeeListener, IRemoteControllerLi
2727 {
2828 public ICDPSender toVSCode ;
2929 public IDebuggeeSender toDebuggee ;
30- private Process process ;
30+ Process process ;
31+ RemoteController giderosRemoteController ;
3132 string giderosStdoutBuffer = "" ;
3233 string workingDirectory ;
3334 Tuple < string , int > fakeBreakpointMode = null ;
3435 string startCommand ;
3536 int startSeq ;
3637 bool jumpToGiderosErrorPosition = false ;
38+ bool stopGiderosWhenDebuggerStops = false ;
3739
3840 public DebugSession ( )
3941 {
@@ -158,6 +160,13 @@ void SendErrorResponse(string command, int seq, int id, string format, dynamic a
158160
159161 void Disconnect ( string command , int seq , dynamic arguments )
160162 {
163+ if ( giderosRemoteController != null &&
164+ stopGiderosWhenDebuggerStops )
165+ {
166+ MessageBox . OK ( "Stopping" ) ;
167+ giderosRemoteController . SendStop ( ) ;
168+ }
169+
161170 if ( process != null )
162171 {
163172 try
@@ -252,11 +261,11 @@ void Launch(string command, int seq, dynamic args)
252261 }
253262 else
254263 {
255- var rc = new RemoteController ( ) ;
264+ giderosRemoteController = new RemoteController ( ) ;
256265
257266 var connectStartedAt = DateTime . Now ;
258267 bool alreadyLaunched = false ;
259- while ( ! rc . TryStart ( "127.0.0.1" , 15000 , gprojPath , this ) )
268+ while ( ! giderosRemoteController . TryStart ( "127.0.0.1" , 15000 , gprojPath , this ) )
260269 {
261270 if ( DateTime . Now - connectStartedAt > TimeSpan . FromSeconds ( 10 ) )
262271 {
@@ -298,7 +307,7 @@ void Launch(string command, int seq, dynamic args)
298307 }
299308 }
300309
301- new System . Threading . Thread ( rc . ReadLoop ) . Start ( ) ;
310+ new System . Threading . Thread ( giderosRemoteController . ReadLoop ) . Start ( ) ;
302311 }
303312
304313 AcceptDebuggee ( command , seq , args , listener ) ;
@@ -381,6 +390,12 @@ bool ReadBasicConfiguration(string command, int seq, dynamic args)
381390 jumpToGiderosErrorPosition = true ;
382391 }
383392
393+ if ( args . stopGiderosWhenDebuggerStops != null &&
394+ ( bool ) args . stopGiderosWhenDebuggerStops == true )
395+ {
396+ stopGiderosWhenDebuggerStops = true ;
397+ }
398+
384399 return true ;
385400 }
386401
0 commit comments