1
>
/*---------------------------------------------------------------------------------------------
debugAdapter.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import * as cp from 'child_process';
7
>
import * as net from 'net';
8
>
import * as stream from 'stream';
9
>
import * as objects from '../../../../base/common/objects.js';
10
>
import * as path from '../../../../base/common/path.js';
11
>
import * as platform from '../../../../base/common/platform.js';
12
>
import * as strings from '../../../../base/common/strings.js';
13
>
import { Promises } from '../../../../base/node/pfs.js';
14
>
import * as nls from '../../../../nls.js';
15
>
import { IExtensionDescription } from '../../../../platform/extensions/common/extensions.js';
16
>
import { IDebugAdapterExecutable, IDebugAdapterNamedPipeServer, IDebugAdapterServer, IDebuggerContribution, IPlatformSpecificAdapterContribution } from '../common/debug.js';
17
>
import { AbstractDebugAdapter } from '../common/abstractDebugAdapter.js';
18
>
import { killTree } from '../../../../base/node/processes.js';
19
>
20
>
/**
21
>
* An implementation that communicates via two streams with the debug adapter.
22
>
*/
23
>
export abstract class StreamDebugAdapter extends AbstractDebugAdapter {
24
>
25
>
private static readonly TWO_CRLF = '\r\n\r\n';
26
>
private static readonly HEADER_LINESEPARATOR = /\r?\n/; // allow for non-RFC 2822 conforming line separators
27
>
private static readonly HEADER_FIELDSEPARATOR = /: */;
28
>
29
>
private outputStream!: stream.Writable;
30
>
private rawData = Buffer.allocUnsafe(0);
31
>
private contentLength = -1;
32
>
33
>
constructor() {
34
super();
35
}
37
>
protected connect(readable: stream.Readable, writable: stream.Writable): void {
38
39
this.outputStream = writable;