@@ -31,9 +31,13 @@ class IOSDebugService implements IDebugService {
31
31
private $utils : IUtils ,
32
32
private $iOSNotification : IiOSNotification ,
33
33
private $iOSSocketRequestExecutor : IiOSSocketRequestExecutor ,
34
- private $socketProxyFactory : ISocketProxyFactory ) { }
34
+ private $processService : IProcessService ,
35
+ private $socketProxyFactory : ISocketProxyFactory ) {
36
+ this . $processService . attachToProcessExitSignals ( this , this . debugStop ) ;
37
+ }
35
38
36
39
private _lldbProcess : ChildProcess ;
40
+ private _sockets : net . Socket [ ] = [ ] ;
37
41
38
42
public get platform ( ) : string {
39
43
return "ios" ;
@@ -76,6 +80,11 @@ class IOSDebugService implements IDebugService {
76
80
77
81
public debugStop ( ) : IFuture < void > {
78
82
return ( ( ) => {
83
+ this . $socketProxyFactory . stopServer ( ) ;
84
+ for ( let socket of this . _sockets ) {
85
+ socket . destroy ( ) ;
86
+ }
87
+ this . _sockets = [ ] ;
79
88
if ( this . _lldbProcess ) {
80
89
this . _lldbProcess . stdin . write ( "process detach\n" ) ;
81
90
this . _lldbProcess . kill ( ) ;
@@ -105,19 +114,27 @@ class IOSDebugService implements IDebugService {
105
114
if ( lineText && _ . startsWith ( lineText , this . $projectData . projectId ) ) {
106
115
let pid = _ . trimStart ( lineText , this . $projectData . projectId + ": " ) ;
107
116
this . _lldbProcess = this . $childProcess . spawn ( "lldb" , [ "-p" , pid ] ) ;
108
- this . _lldbProcess . stdin . write ( "process continue\n" ) ;
117
+ this . _lldbProcess . stdin . write ( "process continue\n" ) ;
109
118
} else {
110
119
process . stdout . write ( line + "\n" ) ;
111
120
}
112
121
} ) ;
113
122
114
- this . wireDebuggerClient ( ( ) => net . connect ( inspectorBackendPort ) ) . wait ( ) ;
123
+ this . wireDebuggerClient ( ( ) => {
124
+ let socket = net . connect ( inspectorBackendPort ) ;
125
+ this . _sockets . push ( socket ) ;
126
+ return socket ;
127
+ } ) . wait ( ) ;
115
128
} ) . future < void > ( ) ( ) ;
116
129
}
117
130
118
131
private emulatorStart ( ) : IFuture < void > {
119
132
return ( ( ) => {
120
- this . wireDebuggerClient ( ( ) => net . connect ( inspectorBackendPort ) ) . wait ( ) ;
133
+ this . wireDebuggerClient ( ( ) => {
134
+ let socket = net . connect ( inspectorBackendPort ) ;
135
+ this . _sockets . push ( socket ) ;
136
+ return socket ;
137
+ } ) . wait ( ) ;
121
138
122
139
let attachRequestMessage = this . $iOSNotification . attachRequest ;
123
140
@@ -152,7 +169,11 @@ class IOSDebugService implements IDebugService {
152
169
let readyForAttachTimeout = this . getReadyForAttachTimeout ( timeout ) ;
153
170
154
171
this . $iOSSocketRequestExecutor . executeLaunchRequest ( device , timeout , readyForAttachTimeout , shouldBreak ) . wait ( ) ;
155
- this . wireDebuggerClient ( ( ) => device . connectToPort ( inspectorBackendPort ) ) . wait ( ) ;
172
+ this . wireDebuggerClient ( ( ) => {
173
+ let socket = device . connectToPort ( inspectorBackendPort ) ;
174
+ this . _sockets . push ( socket ) ;
175
+ return socket ;
176
+ } ) . wait ( ) ;
156
177
} ) . future < void > ( ) ( ) ;
157
178
}
158
179
@@ -167,7 +188,11 @@ class IOSDebugService implements IDebugService {
167
188
return ( ( ) => {
168
189
let timeout = this . getReadyForAttachTimeout ( ) ;
169
190
this . $iOSSocketRequestExecutor . executeAttachRequest ( device , timeout ) . wait ( ) ;
170
- this . wireDebuggerClient ( ( ) => device . connectToPort ( inspectorBackendPort ) ) . wait ( ) ;
191
+ this . wireDebuggerClient ( ( ) => {
192
+ let socket = device . connectToPort ( inspectorBackendPort ) ;
193
+ this . _sockets . push ( socket ) ;
194
+ return socket ;
195
+ } ) . wait ( ) ;
171
196
} ) . future < void > ( ) ( ) ;
172
197
}
173
198
0 commit comments