Commit c25e2427 authored by rdubner's avatar rdubner
Browse files

Improved couldBeOutput() routine. Updated development_notes.md

parent 42e96b57
# Development Notes 2019-12-27, Bob Dubner
This folder is for developing the cbl-dbg extension.
This folder is for developing the cbl-dbg extension.
## First, of course, you have to have Visual Studio Code installed
Making sure you have the correct software installed so that you can install
additional correct software is the usual infinite regress bookended in insanity.
additional correct software is the usual infinite regress bookended in insanity.
I no longer recall how I got bootstrapped in; I think I installed `snap` (or
maybe it was already present on Ubuntu) and then used
maybe it was already present on Ubuntu) and then used
```
sudo snap install --classic code
sudo snap install --classic code
sudo snap install --classic code-insiders
```
for the regular and bleeding-edge versions of Visual Studio Code. You probably
don't need the bleeding-edge code-insiders version.
......@@ -22,11 +22,11 @@ involved running
npm install -g vsce
When this folder is initially cloned from a git repository, it is necessary to
When this folder is initially cloned from a git repository, it is necessary to
run
npm install
to appease the Microsoft software development demons. (It appears to create
a necessary massive folder called "node_modules". I don't know what else it
might be doing.)
......@@ -34,15 +34,15 @@ might be doing.)
## Everything is installed. Now what?
Creating the VSIX extension installation file is accomplished by running
vsce package
The resulting cbl-dbg-x.x.x.vsix package needs to be installed on a user's
system. This can be done by launching Visual Studio Code and displaying the
Extensions pane (Ctrl+Shift+X), then clicking the three-dot "More actions" item,
and then selecting "Install from VSIX...".
You can also get there via the Command Palette (Ctrl+Shift+P) and finding
You can also get there via the Command Palette (Ctrl+Shift+P) and finding
"Extensions: Install from VSIX...", which you can find by typing "VSIX".
It's also possible to install the VSIX package from the command line:
......@@ -116,12 +116,45 @@ The Client configuration controls what happens when the third instance of Visual
]
}
```
Note how the `Attach to debugServer` configuration expects to connect to a server instance through the matching port 4711.
Note how the `Attach to debugServer` configuration expects to connect to a server instance through the matching port 4711.
The `Attach to COBOL debugger` isn't used during sessions when one is debugging the debugger, but it is an example of how one uses the debug adapater extension once it is packaged up and installed.
The `Attach to COBOL debugger` isn't used during sessions when one is debugging the debugger, but it is an example of how one uses the debug adapter extension once it is packaged up and installed.
It should be mentioned that the `"inputs"` section defines the `attachtopid` input, which causes Visual Studio Code to ask the user for the PID that is going to be debugged after gdb attaches to it.
Here's launch.json for a specific program to run when debugging the debugging adapter. This is copied from the sample/optfde01 program elsewhere in the source code repository for this VSIX package:
```
{
// 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}/optfde01",
"cwd": "${workspaceFolder}",
"arguments": "",
"debugServer": 4711
},
{
"name": "cobc/cobst build and debug",
"type": "cbl-gdb",
"request": "launch",
"preLaunchTask": "make",
"program": "${workspaceFolder}/optfde01",
"cwd": "${workspaceFolder}",
"arguments": ""
}
]
}
```
......
......@@ -16,14 +16,67 @@ export function escape(str: string) {
return str.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
}
const nonOutput = /^(?:\d*|undefined)[\*\+\=]|[\~\@\&\^]/;
//const nonOutput = /^(?:\d*|undefined)[\*\+\=]|[\~\@\&\^]/;
const nonOutput = /^(?:\d*|undefined)[\*\=]|[\~\@\&\^]/; // Dubner removed '+'
const gdbMatch = /(?:\d*|undefined)\(gdb\)/;
const numRegex = /\d+/;
//function couldBeOutput(line: string) {
// if (nonOutput.exec(line))
// return false;
// return true;
//}
function couldBeOutput(line: string) {
if (nonOutput.exec(line))
return false;
return true;
// Return false if line starts with GDB/MI keyword
const gdbmi =
[
"(gdb)",
// Result records
"^done",
"^running",
"^connected",
"^error",
"^exit",
// Stream records
"~\"",
"@\"",
"&\"",
// Async records
"*running",
"*stopped",
"=thread-",
"=library-",
"=traceframe-",
"=tsv-",
"=tsv-",
"=breakpoint-",
"=record-",
"=cmd-",
"=memory-",
];
// Skip leading digits:
var nstart = 0;
var patt = new RegExp("^[0-9]");
while( nstart<line.length ) {
var onechar = line.slice(nstart,nstart+1) ;
if( !patt.test(onechar) ) {
break;
}
nstart += 1;
}
for( const possible of gdbmi ) {
var chunk = line.slice(nstart,nstart+possible.length);
if( possible == chunk ) {
return false;
}
}
return true;
}
const trace = false;
......@@ -370,15 +423,19 @@ export class MI2 extends EventEmitter implements IBackend {
}
stdout(data) {
if( this.buffer == undefined ) {
this.buffer = "";
}
if (trace)
this.log("stderr", "stdout: " + data);
if (typeof data == "string") {
this.buffer += data;
//console.log("(A): ", data);
//console.log("(A): ", data); //DUBNERDEBUG
}
else {
this.buffer += data.toString("utf8");
//console.log("(B): ", data.toString("utf8"));
//console.log("(B): ", data.toString("utf8")); //DUBNERDEBUG
}
var end = this.buffer.lastIndexOf('\n');
......@@ -457,6 +514,11 @@ export class MI2 extends EventEmitter implements IBackend {
onOutput(lines) {
lines = <string[]> lines.split('\n');
lines.forEach(line => {
if( line == "+000001031" )
{
console.log("PLUS")
}
if (couldBeOutput(line)) {
if (!gdbMatch.exec(line))
this.log("stdout", line);
......
......@@ -154,7 +154,7 @@ export function parseMI(output: string): MINode {
const asyncRecordType = {
"*": "exec",
"+": "status",
// "+": "status",
"=": "notify"
};
const streamRecordType = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment