Skip to content

Commit 58fbddf

Browse files
committed
Еще танцы с бубном насчет остановки отладки
1 parent fc54bce commit 58fbddf

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

src/OneScript.DebugProtocol/TcpServer/DispatchingServer.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ private void ProcessSuccess(RpcCall message, ICommunicationChannel responseChann
5656
try
5757
{
5858
var methodResult = _requestProcessor.Dispatch(_requestService, message.Id, message.Parameters);
59-
if(methodResult != null)
59+
if (methodResult != null)
6060
callResult = RpcCallResult.Respond(message, methodResult);
6161
}
62+
catch (StopServiceException)
63+
{
64+
Stop();
65+
return;
66+
}
6267
catch (Exception e)
6368
{
6469
callResult = RpcCallResult.Exception(message, e);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*----------------------------------------------------------
2+
This Source Code Form is subject to the terms of the
3+
Mozilla Public License, v.2.0. If a copy of the MPL
4+
was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
----------------------------------------------------------*/
7+
8+
using System;
9+
10+
namespace OneScript.DebugProtocol.TcpServer
11+
{
12+
/// <summary>
13+
/// Прерывание сервера со стороны прикладного интерфейса. Кнопка "Выход" из диспетчера
14+
/// </summary>
15+
public class StopServiceException : ApplicationException
16+
{
17+
}
18+
}

src/OneScript.DebugServices/DefaultDebugService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This Source Code Form is subject to the terms of the
99
using System.Collections.Generic;
1010
using System.Linq;
1111
using OneScript.DebugProtocol;
12+
using OneScript.DebugProtocol.TcpServer;
1213
using OneScript.Language;
1314
using ScriptEngine.Machine;
1415
using StackFrame = OneScript.DebugProtocol.StackFrame;
@@ -188,6 +189,8 @@ public void Disconnect(bool terminate)
188189
{
189190
_breakpointManager.Clear();
190191
_threadManager.ReleaseAllThreads();
192+
193+
throw new StopServiceException();
191194
}
192195

193196
public int[] GetThreads()

src/VSCode.DebugAdapter/DebugeeProcess.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ public void HandleDisconnect(bool terminate)
166166
}
167167
}
168168

169+
public void Kill()
170+
{
171+
_process.Kill();
172+
_process.WaitForExit(1500);
173+
}
174+
169175
public Breakpoint[] SetBreakpoints(IEnumerable<Breakpoint> breakpoints)
170176
{
171177
var confirmedBreaks = _debugger.SetMachineBreakpoints(breakpoints.ToArray());

src/VSCode.DebugAdapter/OscriptDebugSession.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ public override void Launch(Response response, dynamic args)
111111
}
112112
catch (Exception e)
113113
{
114-
_process.HandleDisconnect(true);
115-
_process = null;
114+
_process.Kill();
115+
SendEvent(new TerminatedEvent());
116116
Log.Error(e, "Can't connect to debug server");
117117
SendErrorResponse(response, 4550, "Can't connect: " + e.ToString());
118118
return;

0 commit comments

Comments
 (0)