From f696b86fe657b5a602a8961e2bc4cea329047292 Mon Sep 17 00:00:00 2001 From: Bob Dubner <rdubner@symas.com> Date: Fri, 19 Mar 2021 09:46:30 -0400 Subject: [PATCH] Release candidate 4.2.3 -- Implements the COBOL ACCEPT statement. This version also handles some race conditions that were resulting in "...variable not iterable..." responses that prevented proper display in the VARIABLES pane. The main functional change is this version's ability to work with the COBOL ACCEPT statement. All input and output is from the VSC "DEBUG CONSOLE" panel. The debugging adapter, however, keeps track of whether GDB thinks the inferior is *running or *stopped. When *running, all VSC attempts to talk to the inferior are inhibited, and any keyboard commands are stripped of the '-interpreter-exec' wrapper and sent in raw form to the inferior. This seems to work. The C/C++ debugger for VSC works differently; it sets up pipes for stdin and stdout, which are used for sending and receiving command information to GDB. Meanwhile, the inferior's TTY is redirected to the "Integrated Terminal" pane of VSC. I didn't try to duplicate that because I didn't want to take the time at this time, and because after several hours of investigation I was unable to determine how to set the inferior's TTY to the integrated terminal pane. --- CblGdbExt/CblGdb/package.json | 2 +- CblGdbExt/CblGdb/src/backend/mi2/mi2.ts | 31 +++++++++++++------------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CblGdbExt/CblGdb/package.json b/CblGdbExt/CblGdb/package.json index 5b97cca..f077c4c 100644 --- a/CblGdbExt/CblGdb/package.json +++ b/CblGdbExt/CblGdb/package.json @@ -8,7 +8,7 @@ "debug" ], "license": "COBOLworx", - "version": "4.2.2", + "version": "4.2.3", "publisher": "COBOLworx", "icon": "images/COBOLworx.png", "engines": { diff --git a/CblGdbExt/CblGdb/src/backend/mi2/mi2.ts b/CblGdbExt/CblGdb/src/backend/mi2/mi2.ts index d9eeac0..b8dfe91 100644 --- a/CblGdbExt/CblGdb/src/backend/mi2/mi2.ts +++ b/CblGdbExt/CblGdb/src/backend/mi2/mi2.ts @@ -504,7 +504,7 @@ export class MI2 extends EventEmitter implements IBackend { // DUBNER SEZ: By replacing "location-reached" with "end-stepping-range", we prevent // the alarming red EXCEPTION OCCURRED warning when we replace "-exec-next" with "cnext" this.buffer += data.toString("utf8").replace("location-reached","end-stepping-range"); - console.log("(B): ", data.toString("utf8")); //DUBNERDEBUG + //console.log("(B): ", data.toString("utf8")); //DUBNERDEBUG } var end = this.buffer.lastIndexOf('\n'); @@ -540,14 +540,14 @@ export class MI2 extends EventEmitter implements IBackend { const leading_stopped:string = '*stopped' ; var lines = <string[]> this.buffer.split('\n'); for( var i=0; i<lines.length; i++) { + // Don't break out of this loop. When stepping it's common for *running and *stopped + // to appear in the response. var line = lines[i]; if( line.substr(0,leading_running.length) == leading_running ) { this.starState = leading_running; - break; } if( line.substr(0,leading_stopped.length) == leading_stopped ) { this.starState = leading_stopped; - break; } } @@ -893,9 +893,6 @@ export class MI2 extends EventEmitter implements IBackend { if (trace) this.log("stderr", "getThreads"); const ret: Thread[] = []; - if( this.starState == "*running" ) { - return ret; - } const command = "thread-info"; const result = await this.sendCommand(command); const threads = result.result("threads"); @@ -1081,7 +1078,7 @@ export class MI2 extends EventEmitter implements IBackend { } sendRaw(raw: string) { - console.log("sendRaw():", raw, '(', this.starState,')'); // DUBNERDEBUG + //console.log("sendRaw():", raw, '(', this.starState,')'); // DUBNERDEBUG if (this.printCalls) this.log("log", raw); if (this.isSSH) @@ -1108,7 +1105,6 @@ export class MI2 extends EventEmitter implements IBackend { } sendCommand(command: string, suppressFailure: boolean = false): Thenable<MINode> { - const sel = this.currentToken++; return new Promise((resolve, reject) => { this.handlers[sel] = (node: MINode) => { @@ -1123,13 +1119,18 @@ export class MI2 extends EventEmitter implements IBackend { }; if( this.starState == "*running" ) { // When in running mode, assume the command is for the inferior - // rather than for gdb. Somebody "up there" has helpfully encased whatever the user typed - // into 'interpreter-exec console "4321"; we need to disinter it: - var n1:number = command.indexOf('"'); - var n2:number = command.lastIndexOf('"'); - command = command.slice(n1+1,n2); - this.sendRaw(command); - this.sendRaw("\n"); + // rather than for gdb. We will pay attention only to an instruction + // encased in 'interpreter-exec', and we will extract the meat of + // that instruction and send it unadorned. + if( command.indexOf('interpreter-exec') == 0) { + var n1:number = command.indexOf('"'); + var n2:number = command.lastIndexOf('"'); + if( n1 != -1 && n2 != -1 ) { + command = command.slice(n1+1,n2); + this.sendRaw(command); + this.sendRaw("\n"); + } + } } else { this.sendRaw(sel + "-" + command); -- GitLab