@@ -186,6 +186,7 @@ export class DelveDAPOutputAdapter extends ProxyDebugAdapter {
186186 this . connected = undefined ;
187187 const dlvDapServer = this . dlvDapServer ;
188188 if ( dlvDapServer . exitCode !== null ) {
189+ console . log ( `dlv dap process(${ dlvDapServer . pid } ) exited ${ dlvDapServer . exitCode } ` ) ;
189190 return ;
190191 }
191192 await new Promise < void > ( ( resolve ) => {
@@ -195,6 +196,7 @@ export class DelveDAPOutputAdapter extends ProxyDebugAdapter {
195196 resolve ( ) ;
196197 } , 1_000 ) ;
197198 dlvDapServer . on ( 'exit' , ( ) => {
199+ console . log ( `dlv dap process(${ dlvDapServer . pid } ) exited` ) ;
198200 clearTimeout ( exitTimeoutToken ) ;
199201 resolve ( ) ;
200202 } ) ;
@@ -204,8 +206,9 @@ export class DelveDAPOutputAdapter extends ProxyDebugAdapter {
204206 private async startAndConnectToServer ( ) {
205207 const { port, host, dlvDapServer } = await startDapServer (
206208 this . config ,
207- ( msg ) => this . stdoutEvent ( msg ) ,
208- ( msg ) => this . stderrEvent ( msg )
209+ ( msg ) => this . outputEvent ( 'stdout' , msg ) ,
210+ ( msg ) => this . outputEvent ( 'stderr' , msg ) ,
211+ ( msg ) => this . outputEvent ( 'console' , msg )
209212 ) ;
210213 const socket = await new Promise < net . Socket > ( ( resolve , reject ) => {
211214 // eslint-disable-next-line prefer-const
@@ -226,25 +229,19 @@ export class DelveDAPOutputAdapter extends ProxyDebugAdapter {
226229 this . start ( this . socket , this . socket ) ;
227230 }
228231
229- stdoutEvent ( output : string , data ?: any ) {
232+ private outputEvent ( dest : string , output : string , data ?: any ) {
230233 this . sendMessageToClient ( new OutputEvent ( output , 'stdout' , data ) ) ;
231234 if ( this . outputToConsole ) {
232235 console . log ( output ) ;
233236 }
234237 }
235-
236- stderrEvent ( output : string , data ?: any ) {
237- this . sendMessageToClient ( new OutputEvent ( output , 'stderr' , data ) ) ;
238- if ( this . outputToConsole ) {
239- console . error ( output ) ;
240- }
241- }
242238}
243239
244240export async function startDapServer (
245241 configuration : vscode . DebugConfiguration ,
246242 log ?: ( msg : string ) => void ,
247- logErr ?: ( msg : string ) => void
243+ logErr ?: ( msg : string ) => void ,
244+ logConsole ?: ( msg : string ) => void
248245) : Promise < { port : number ; host : string ; dlvDapServer ?: ChildProcessWithoutNullStreams } > {
249246 const host = configuration . host || '127.0.0.1' ;
250247
@@ -260,7 +257,10 @@ export async function startDapServer(
260257 if ( ! logErr ) {
261258 logErr = appendToDebugConsole ;
262259 }
263- const dlvDapServer = await spawnDlvDapServerProcess ( configuration , host , port , log , logErr ) ;
260+ if ( ! logConsole ) {
261+ logConsole = appendToDebugConsole ;
262+ }
263+ const dlvDapServer = await spawnDlvDapServerProcess ( configuration , host , port , log , logErr , logConsole ) ;
264264 return { dlvDapServer, port, host } ;
265265}
266266
@@ -269,7 +269,8 @@ async function spawnDlvDapServerProcess(
269269 host : string ,
270270 port : number ,
271271 log : ( msg : string ) => void ,
272- logErr : ( msg : string ) => void
272+ logErr : ( msg : string ) => void ,
273+ logConsole : ( msg : string ) => void
273274) : Promise < ChildProcess > {
274275 const launchArgsEnv = launchArgs . env || { } ;
275276 const env = Object . assign ( { } , process . env , launchArgsEnv ) ;
@@ -301,7 +302,7 @@ async function spawnDlvDapServerProcess(
301302 if ( launchArgs . logOutput ) {
302303 dlvArgs . push ( '--log-output=' + launchArgs . logOutput ) ;
303304 }
304- log ( `Running: ${ dlvPath } ${ dlvArgs . join ( ' ' ) } ` ) ;
305+ logConsole ( `Running: ${ dlvPath } ${ dlvArgs . join ( ' ' ) } \n ` ) ;
305306
306307 const dir = parseProgramArgSync ( launchArgs ) . dirname ;
307308 // TODO(hyangah): determine the directories:
0 commit comments