From f3a41de5a8ca5cb6251c1191383640752870de15 Mon Sep 17 00:00:00 2001
From: Bob Dubner <rdubner@symas.com>
Date: Tue, 22 Sep 2020 11:31:20 -0400
Subject: [PATCH] Development of 4.1.1  Frankly, I don't recall what these
 changes do.

---
 CblGdbExt/CblGdb/package-lock.json            |   2 +-
 CblGdbExt/CblGdb/package.json                 |   2 +-
 CblGdbExt/CblGdb/src/backend/mi2/mi2.ts       |   2 +-
 CblGdbExt/CblGdb/src/mibase.ts                |  30 +---
 CblGdbExt/samples/ref_test_2/.gitignore       |   7 +
 .../samples/ref_test_2/.vscode/launch.json    |  29 +++
 .../samples/ref_test_2/.vscode/tasks.json     |  16 ++
 CblGdbExt/samples/ref_test_2/Makefile         |   6 +
 CblGdbExt/samples/ref_test_2/rtest.cbl        | 169 ++++++++++++++++++
 9 files changed, 236 insertions(+), 27 deletions(-)
 create mode 100644 CblGdbExt/samples/ref_test_2/.gitignore
 create mode 100755 CblGdbExt/samples/ref_test_2/.vscode/launch.json
 create mode 100644 CblGdbExt/samples/ref_test_2/.vscode/tasks.json
 create mode 100644 CblGdbExt/samples/ref_test_2/Makefile
 create mode 100644 CblGdbExt/samples/ref_test_2/rtest.cbl

diff --git a/CblGdbExt/CblGdb/package-lock.json b/CblGdbExt/CblGdb/package-lock.json
index 6949ce5..4013bdd 100644
--- a/CblGdbExt/CblGdb/package-lock.json
+++ b/CblGdbExt/CblGdb/package-lock.json
@@ -1,6 +1,6 @@
 {
 	"name": "cbl-gdb",
-	"version": "3.2.1",
+	"version": "4.1.1",
 	"lockfileVersion": 1,
 	"requires": true,
 	"dependencies": {
diff --git a/CblGdbExt/CblGdb/package.json b/CblGdbExt/CblGdb/package.json
index 09b77d6..71a289e 100644
--- a/CblGdbExt/CblGdb/package.json
+++ b/CblGdbExt/CblGdb/package.json
@@ -8,7 +8,7 @@
 		"debug"
 	],
 	"license": "COBOLworx",
-	"version": "3.2.1",
+	"version": "4.1.1",
 	"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 a0c2427..4838c74 100644
--- a/CblGdbExt/CblGdb/src/backend/mi2/mi2.ts
+++ b/CblGdbExt/CblGdb/src/backend/mi2/mi2.ts
@@ -737,7 +737,7 @@ export class MI2 extends EventEmitter implements IBackend {
 	changeVariable(name: string, rawValue: string): Thenable<any> {
 		if (trace)
 			this.log("stderr", "changeVariable");
-			return this.sendStraightCommand("p/m " + name.substr(3) + "=" + rawValue);
+			return this.sendStraightCommand("p/m " + name + "=" + rawValue);
 		}
 
 	loadBreakPoints(breakpoints: Breakpoint[]): Thenable<[boolean, Breakpoint][]> {
diff --git a/CblGdbExt/CblGdb/src/mibase.ts b/CblGdbExt/CblGdb/src/mibase.ts
index da3a898..63b2ba0 100644
--- a/CblGdbExt/CblGdb/src/mibase.ts
+++ b/CblGdbExt/CblGdb/src/mibase.ts
@@ -10,6 +10,7 @@ import * as systemPath from "path";
 import * as net from "net";
 import * as os from "os";
 import * as fs from "fs";
+import { print } from 'util';
 
 const resolve = posix.resolve;
 const relative = posix.relative;
@@ -22,27 +23,6 @@ class ExtendedVariable {
 const STACK_HANDLES_START = 1000;
 const VAR_HANDLES_START = 512 * 256 + 1000;
 
-function DeEscape(vstr:string) {
-	let retval = "";
-	let i = 0;
-	let escaped = false;
-	while( i<vstr.length ) {
-		let ch = vstr[i];
-		i += 1;
-		if( escaped ) {
-			retval += ch;
-			escaped = false;
-			continue;
-		}
-		if( ch == '\\' ){
-			escaped = true;
-			continue;
-		}
-		retval += ch;
-	}
-	return retval;
-}
-
 export class MI2DebugSession extends DebugSession {
 	protected variableHandles = new Handles<string | VariableObject | ExtendedVariable>(VAR_HANDLES_START);
 	protected variableHandlesReverse: { [id: string]: number } = {};
@@ -196,6 +176,10 @@ export class MI2DebugSession extends DebugSession {
 
 	protected async setVariableRequest(response: DebugProtocol.SetVariableResponse, args: DebugProtocol.SetVariableArguments): Promise<void> {
 		try {
+			console.log(`setVariableRequest: ${args.name} ${args.value} (${args.variablesReference})`);
+
+			// We might need to build up the fully-qualified name, assuming there are containers involved:
+
 			if (this.useVarObjects) {
 				let name = args.name;
 				if (args.variablesReference >= VAR_HANDLES_START) {
@@ -446,9 +430,6 @@ export class MI2DebugSession extends DebugSession {
 							if(vstr == "") {
 								vstr = '""' ;
 							}
-//							if( vstr && vstr[0] != '{' ){
-//								vstr = DeEscape(vstr) ;
-//							}
 							//console.log("findOrCreateVariable(1)", vstr); //DUBNERDEBUG
 							let expanded = expandValue(createVariable, `{${variable.name}=${vstr}`, "", variable.raw);
 							if (expanded) {
@@ -460,6 +441,7 @@ export class MI2DebugSession extends DebugSession {
 											variablesReference: 0
 										}
 									];
+
 								variables.push(expanded[0]);
 							}
 						} else
diff --git a/CblGdbExt/samples/ref_test_2/.gitignore b/CblGdbExt/samples/ref_test_2/.gitignore
new file mode 100644
index 0000000..8a3f6d8
--- /dev/null
+++ b/CblGdbExt/samples/ref_test_2/.gitignore
@@ -0,0 +1,7 @@
+*.h
+*.i
+*.o
+*.c
+*.s
+rtest
+rtest.so
diff --git a/CblGdbExt/samples/ref_test_2/.vscode/launch.json b/CblGdbExt/samples/ref_test_2/.vscode/launch.json
new file mode 100755
index 0000000..fb8d796
--- /dev/null
+++ b/CblGdbExt/samples/ref_test_2/.vscode/launch.json
@@ -0,0 +1,29 @@
+{
+    // Use IntelliSense to learn about possible attributes.
+    // Hover to view descriptions of existing attributes.
+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "Build ${file} with cobc/cobst, debug with debugServer",
+            "type": "node",
+            "request": "launch",
+            "skipFiles": ["<node_internals>/**"],
+            "preLaunchTask": "make",
+            "program": "${workspaceRoot}/rtest",
+            "cwd": "${workspaceFolder}",
+            "arguments": "",
+            "debugServer": 4711
+        },
+        {
+            "name": "cobc/cobst build and debug",
+            "type": "cbl-gdb",
+            "request": "launch",
+            "preLaunchTask": "make",
+            "program": "${workspaceFolder}/rtest",
+            "cwd": "${workspaceFolder}",
+            "arguments": ""
+        }
+        
+    ]
+}
\ No newline at end of file
diff --git a/CblGdbExt/samples/ref_test_2/.vscode/tasks.json b/CblGdbExt/samples/ref_test_2/.vscode/tasks.json
new file mode 100644
index 0000000..076b506
--- /dev/null
+++ b/CblGdbExt/samples/ref_test_2/.vscode/tasks.json
@@ -0,0 +1,16 @@
+{
+    // See https://go.microsoft.com/fwlink/?LinkId=733558
+    // for the documentation about the tasks.json format
+    "version": "2.0.0",
+    "tasks": [
+        {
+            "label": "make",
+            "type": "shell",
+            "command": "make",
+            "group": {
+                "kind": "build",
+                "isDefault": true
+            }            
+        }
+    ]
+}
\ No newline at end of file
diff --git a/CblGdbExt/samples/ref_test_2/Makefile b/CblGdbExt/samples/ref_test_2/Makefile
new file mode 100644
index 0000000..11a800c
--- /dev/null
+++ b/CblGdbExt/samples/ref_test_2/Makefile
@@ -0,0 +1,6 @@
+project=rtest
+
+all : rtest
+
+rtest : rtest.cbl
+	COBCDNOCLEAN=1 cobcd -x rtest.cbl
diff --git a/CblGdbExt/samples/ref_test_2/rtest.cbl b/CblGdbExt/samples/ref_test_2/rtest.cbl
new file mode 100644
index 0000000..7e0e0f2
--- /dev/null
+++ b/CblGdbExt/samples/ref_test_2/rtest.cbl
@@ -0,0 +1,169 @@
+        >>SOURCE FREE
+ID DIVISION.
+PROGRAM-ID. rtest.
+DATA DIVISION.
+LOCAL-STORAGE SECTION.
+
+01  GEORGE.
+    02 FILLER     PIC  A(13) VALUE SPACES.
+    02 NAME-FIRST PIC  A(10) VALUE "GEORGE".
+01  WASHINGTON.
+    02 FILLER     PIC  A(23) VALUE SPACES.
+    02 NAME-FIRST PIC  A(10) VALUE "WASHINGTON".
+    02 LOCATION   PIC  A(10) VALUE "DC".
+    02 TEMPERATURE PIC A(10) VALUE "HOT".
+    66  WABASH RENAMES NAME-FIRST OF WASHINGTON.
+01  CARVER.
+    02 FILLER     PIC  A(43) VALUE SPACES.
+    02 NAME-FIRST PIC  A(10) VALUE "CARVER".
+01  PEANUTS.
+    02 FILLER     PIC  A(63) VALUE SPACES.
+    02 NAME-FIRST PIC  999V999999 VALUE 123.456789.
+01  LEGUMES REDEFINES PEANUTS.
+    02 FILLER     PIC  A(63).
+    02 NAME-FIRST PIC  999999V999.
+
+PROCEDURE DIVISION.
+    DISPLAY "entering: rtest".
+    CALL 'JIMBOB'.
+    DISPLAY NAME-FIRST of GEORGE.
+    DISPLAY NAME-FIRST of WASHINGTON.
+    DISPLAY NAME-FIRST of CARVER.
+    DISPLAY NAME-FIRST of PEANUTS.
+    DISPLAY NAME-FIRST of LEGUMES.
+    MOVE "Wabash" TO WABASH.
+    DISPLAY NAME-FIRST of WASHINGTON.
+
+    END PROGRAM rtest.
+
+IDENTIFICATION DIVISION.
+PROGRAM-ID. JIMBOB.
+DATA DIVISION.
+WORKING-STORAGE SECTION.
+   77 TEST-NUMBER-A             PIC 9(9) VALUE 123456789.
+   77 TEST-NUMBER-B1            PIC 9999999V9 VALUE 1234567.8 .
+   77 TEST-NUMBER-B2            REDEFINES TEST-NUMBER-B1 PIC 999999V99 .
+   77 TEST-NUMBER-C             PIC 9(9) VALUE 123456789.
+   77   errno    BINARY-LONG EXTERNAL.
+
+   01 WS-JIM GLOBAL.
+        02 WS-FIRSTNAME         PIC A(10)   VALUE "James".
+        02 WS-MIDDLE-INITIAL    PIC X(1)    VALUE '"'.
+        02 FILLER               PIC A(1)    VALUE SPACE.
+        02 WS-LASTNAME          PIC A(10)   VALUE "Lowden".
+   01 WS-BOB EXTERNAL.
+        02 WS-FIRSTNAME         PIC A(10)   .
+        02 WS-MIDDLE-INITIAL    PIC A(1)    .
+        02 FILLER               PIC A(1)    .
+        02 WS-LASTNAME          PIC A(10)   .
+   01 WS-JUDY. 
+   02 WS-FIRSTNAME PIC A(10) VALUE "Judy".
+   02 WS-MIDDLE-INITIAL PIC A(1) VALUE "L". 
+   02 FILLER PIC A(1) VALUE SPACE. 
+   02 WS-LASTNAME PIC A(10) VALUE "Ruderman".
+
+   01 UNUSED.
+      02 NOT-USED PIC A(24).
+   01 WS-FLOATTEST COMP-1 GLOBAL VALUE 1.234.
+PROCEDURE DIVISION.
+    MOVE    SPACES to WS-BOB.
+    MOVE    "Robert" to WS-FIRSTNAME IN WS-BOB.
+    MOVE    "J" to WS-MIDDLE-INITIAL IN WS-BOB.
+    MOVE    "Dubner" to WS-LASTNAME IN WS-BOB.
+    DISPLAY "entering: jimbob"
+    DISPLAY TEST-NUMBER-B1.
+    DISPLAY TEST-NUMBER-B2.
+    CALL 'JIM'.
+    CALL 'BOB'.
+    CALL 'DISPLAY-JIM-OR-BOB' USING WS-JUDY,WS-JIM
+    CALL 'JUST_ONE' USING 1031.
+    DISPLAY WS-FLOATTEST.
+    GOBACK.
+
+IDENTIFICATION DIVISION.
+PROGRAM-ID. JIM.
+PROCEDURE DIVISION.
+    DISPLAY "entering: jim"
+    DISPLAY WS-JIM.
+    DISPLAY "by pargraphs:"
+    PERFORM ParaFirstName.
+    PERFORM ParaMiddleInitial.
+    PERFORM ParaLastName.
+    DISPLAY "by threw"
+    PERFORM ParaFirstName THRU ParaLastName.
+    DISPLAY "by sekshun:"
+    PERFORM FirstMiddleLast.
+    GOBACK.
+FirstMiddleLast SECTION.
+    ParaFirstName.      DISPLAY WS-FIRSTNAME OF WS-JIM.
+    ParaMiddleInitial.  DISPLAY WS-MIDDLE-INITIAL OF WS-JIM.
+    ParaLastName.       DISPLAY WS-LASTNAME OF WS-JIM.
+    END PROGRAM JIM.
+
+IDENTIFICATION DIVISION.
+PROGRAM-ID. DISPLAY-JIM-OR-BOB.
+DATA DIVISION.
+LINKAGE SECTION.
+   01 LS-JORB.
+        02 LS-FIRSTNAME         PIC A(10)   .
+        02 LS-MIDDLE-INITIAL    PIC A(1)    .
+        02 FILLER               PIC A(1)    .
+        02 LS-LASTNAME          PIC A(10)   .
+   01 LS-JORB-2.
+        02 LS-FIRSTNAME         PIC A(10)   .
+        02 LS-MIDDLE-INITIAL    PIC A(1)    .
+        02 FILLER               PIC A(1)    .
+        02 LS-LASTNAME          PIC A(10)   .
+PROCEDURE DIVISION USING LS-JORB, LS-JORB-2.
+    DISPLAY "entering: jorb"
+*>    DISPLAY LS-JORB
+    DISPLAY LS-MIDDLE-INITIAL OF LS-JORB.
+*>    DISPLAY LS-JORB-2
+    DISPLAY LS-MIDDLE-INITIAL OF LS-JORB-2.
+    END PROGRAM DISPLAY-JIM-OR-BOB.
+
+IDENTIFICATION DIVISION.
+PROGRAM-ID. JUST_ONE.
+DATA DIVISION.
+LINKAGE SECTION.
+   01 A_BINARY_NUMBER USAGE BINARY-LONG.
+PROCEDURE DIVISION USING A_BINARY_NUMBER.
+    DISPLAY "entering: JUST_ONE"
+    DISPLAY A_BINARY_NUMBER.
+    END PROGRAM JUST_ONE.
+
+IDENTIFICATION DIVISION.
+PROGRAM-ID. BOB.
+DATA DIVISION.
+WORKING-STORAGE SECTION.
+   01 WS-BOB EXTERNAL.
+        02 WS-FIRSTNAME         PIC A(10)   .
+        02 WS-MIDDLE-INITIAL    PIC A(1)    .
+        02 FILLER               PIC A(1)    .
+        02 WS-LASTNAME          PIC A(10)   .
+PROCEDURE DIVISION.
+    DISPLAY "entering: bob"
+    DISPLAY WS-BOB.
+    DISPLAY "by pargraphs:"
+    PERFORM ParaFirstName.
+    PERFORM ParaMiddleInitial.
+    PERFORM ParaLastName.
+    DISPLAY "by threw"
+    PERFORM ParaFirstName THROUGH ParaLastName.
+    DISPLAY "by sekshun:"
+    PERFORM FirstMiddleLast.
+    MOVE 4.321 TO WS-FLOATTEST
+    GOBACK.
+FirstMiddleLast SECTION.
+    ParaFirstName.      DISPLAY WS-FIRSTNAME OF WS-BOB.
+    ParaMiddleInitial.  DISPLAY WS-MIDDLE-INITIAL OF WS-BOB.
+    ParaLastName.       DISPLAY WS-LASTNAME OF WS-BOB.
+    END PROGRAM BOB.
+
+END PROGRAM JIMBOB.
+
+
+
+
+
+
-- 
GitLab