|
5 | 5 | import * as os from 'os';
|
6 | 6 | import * as fs from 'fs';
|
7 | 7 | import * as path from 'path';
|
| 8 | +import {ChildProcess} from 'child_process'; |
8 | 9 | import {Handles, StoppedEvent, InitializedEvent, TerminatedEvent, OutputEvent} from 'vscode-debugadapter';
|
9 | 10 | import {DebugProtocol} from 'vscode-debugprotocol';
|
10 | 11 | import {INSDebugConnection} from './connection/INSDebugConnection';
|
@@ -42,6 +43,7 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
|
42 | 43 | private _lastOutputEvent: OutputEvent;
|
43 | 44 | private _loggerFrontendHandler: LoggerHandler = args => this.fireEvent(new OutputEvent(`${args.message}\n`, args.type.toString()));
|
44 | 45 | private _request: DebugRequest;
|
| 46 | + private _tnsProcess: ChildProcess; |
45 | 47 |
|
46 | 48 | public constructor() {
|
47 | 49 | this._variableHandles = new Handles<IScopeVarHandle>();
|
@@ -153,9 +155,12 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
|
153 | 155 | }
|
154 | 156 |
|
155 | 157 | if (cliCommand.tnsProcess) {
|
| 158 | + this._tnsProcess = cliCommand.tnsProcess; |
156 | 159 | cliCommand.tnsProcess.stdout.on('data', data => { Services.logger().log(data.toString(), Tags.FrontendMessage); });
|
157 | 160 | cliCommand.tnsProcess.stderr.on('data', data => { Services.logger().error(data.toString(), Tags.FrontendMessage); });
|
158 |
| - cliCommand.tnsProcess.on('close', (code, signal) => { Services.logger().error(`[NSDebugAdapter] The tns command finished its execution with code ${code}.`, Tags.FrontendMessage); }); |
| 161 | + cliCommand.tnsProcess.on('close', (code, signal) => { |
| 162 | + Services.logger().error(`[NSDebugAdapter] The tns command finished its execution with code ${code}.`, Tags.FrontendMessage); |
| 163 | + }); |
159 | 164 | }
|
160 | 165 |
|
161 | 166 | let promiseResolve = null;
|
@@ -191,7 +196,10 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
|
191 | 196 | connection.on('Console.messageRepeatCountUpdated', params => this.onMessageRepeatCountUpdated(params));
|
192 | 197 | connection.on('Inspector.detached', () => this.terminateSession());
|
193 | 198 | connection.on('close', () => this.terminateSession());
|
194 |
| - connection.on('error', () => this.terminateSession()); |
| 199 | + connection.on('error', (error) => { |
| 200 | + Services.logger().log(error.toString()); |
| 201 | + this.terminateSession(); |
| 202 | + }); |
195 | 203 | connection.on('connect', () => this.onConnected())
|
196 | 204 | this._webKitConnection = connection;
|
197 | 205 | return connection;
|
@@ -220,6 +228,11 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
|
220 | 228 | this.clearClientContext();
|
221 | 229 | this.clearTargetContext();
|
222 | 230 |
|
| 231 | + if (this._tnsProcess) { |
| 232 | + this._tnsProcess.kill('SIGQUIT'); |
| 233 | + this._tnsProcess = null; |
| 234 | + } |
| 235 | + |
223 | 236 | if (this._webKitConnection) {
|
224 | 237 | Services.logger().log("Closing debug connection");
|
225 | 238 |
|
@@ -356,7 +369,6 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
|
356 | 369 | .then(responses => ({ breakpoints: this._webkitBreakpointResponsesToODPBreakpoints(targetScriptUrl, responses, args.lines) }));
|
357 | 370 |
|
358 | 371 | const inDebug = typeof (<any>global).v8debug === 'object';
|
359 |
| - console.log("InDebug: " + inDebug); |
360 | 372 | const setBreakpointsPTimeout = utils.promiseTimeout(setBreakpointsPFailOnError, /*timeoutMs*/inDebug ? 2000000 : 8000, 'Set breakpoints request timed out');
|
361 | 373 |
|
362 | 374 | // Do just one setBreakpointsRequest at a time to avoid interleaving breakpoint removed/breakpoint added requests to Chrome.
|
|
0 commit comments