3636import { ChildProcess , spawn } from 'child_process' ;
3737import { EventEmitter } from 'events' ;
3838import { existsSync } from 'fs' ;
39+ import * as vscode from 'vscode' ;
3940
4041import * as CommandFactory from './commandFactory' ;
4142import { logger } from '../../util/logger' ;
4243import { GDBMIParser , GDBMIOutput ,
43- GDBMIResult , GDBMIOutOfBandRecord , GDBMIAsyncOutput
44+ GDBMIResult , GDBMIOutOfBandRecord , GDBMIAsyncOutput , GDBMIStreamRecordType
4445 } from '../parser/gdbParser' ;
4546
4647export enum GDBCommandFlag {
@@ -199,8 +200,7 @@ export class GDBAdapter extends EventEmitter {
199200 this . processGDBMIOutOfBandRecord ( miOutOfBandRecord ) ;
200201 }
201202 } else {
202- this . programOutput += response ;
203- // todo
203+ this . writeToDebugConsole ( response ) ;
204204 }
205205
206206 if ( this . gdbmiCommandOutput ) {
@@ -227,6 +227,13 @@ export class GDBAdapter extends EventEmitter {
227227 } ) ;
228228 }
229229
230+ private writeToDebugConsole ( output : string ) {
231+ this . programOutput += output ;
232+ const debugConsole = vscode . debug . activeDebugConsole ;
233+ // Use the appendLine method
234+ debugConsole . appendLine ( output ) ;
235+ }
236+
230237 /**
231238 * Processes GDB/MI out-of-band records.
232239 *
@@ -249,8 +256,19 @@ export class GDBAdapter extends EventEmitter {
249256 } else if ( outOfBandRecord . miStreamRecord ) {
250257 // Handle stream records (e.g., console, target, or log output)
251258 const streamOutput = outOfBandRecord . miStreamRecord ?. value ;
252- if ( streamOutput ) {
253- this . programOutput += streamOutput ;
259+ switch ( outOfBandRecord . miStreamRecord ?. type ) {
260+ case GDBMIStreamRecordType . consoleStream :
261+ // todo. Add configuration to show/hide console output
262+ break ;
263+ case GDBMIStreamRecordType . targetStream :
264+ this . writeToDebugConsole ( streamOutput ) ;
265+ break ;
266+ case GDBMIStreamRecordType . logStream :
267+ // todo. Add configuration to show/hide log output
268+ break ;
269+ default :
270+ logger . error ( `GDB: Unknown stream record type: ${ outOfBandRecord . miStreamRecord ?. type } ` ) ;
271+ break ;
254272 }
255273 }
256274 }
0 commit comments