From 61506db7a0c33661accc9aa14568f501dc695a07 Mon Sep 17 00:00:00 2001 From: Michal Rogalinski Date: Sun, 6 Nov 2016 21:43:28 +0100 Subject: [PATCH 1/2] - fix initial configuration generator - updates to configuration files - code cleanup in main functionality --- CHANGELOG.md | 8 ++++-- LICENSE | 4 +-- README.md | 7 ++++-- package.json | 2 +- src/bashDebug.ts | 16 ++++-------- src/extension.ts | 64 ++++++++++++++++++++++++++++-------------------- 6 files changed, 56 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4da0960..e628405 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ 0.0.1 ===== +## [Bugfix release v0.0.2-apha.2](https://github.com/rogalmic/vscode-bash-debug/releases/tag/v0.0.2-apha.2) +- fixed broken initial configurations (for VS Code 1.7.1) +- using single bash instance as backend +- dropping "tree-kill" usage (using unix pkill directly) + +## [Initial release v0.0.1-apha.1](https://github.com/rogalmic/vscode-bash-debug/releases/tag/v0.0.1-apha.1) -## What's New -- [Initial release v0.0.1-apha.1](https://github.com/rogalmic/vscode-bash-debug/releases/tag/v0.0.1-apha.1) diff --git a/LICENSE b/LICENSE index 707533e..8e230e5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -Copyright (c) Microsoft Corporation +Copyright (c) 2016 Microsoft Corporation, Michał Rogaliński -All rights reserved. +All rights reserved. MIT License diff --git a/README.md b/README.md index 4fe7abd..2e52bf2 100644 --- a/README.md +++ b/README.md @@ -14,5 +14,8 @@ Sample usage animation: ## Limitations and known problems * Currently debugger stops at first command. -* Bash unofficial strict mode "set -e" causes debugging script to exit. Consider using "trap 'exit $?' ERR" instead. -* On Windows 10, there is a problem with starting bash without console window (https://github.com/Microsoft/BashOnWindows/issues/2#issuecomment-209118529); \ No newline at end of file +* Executing "set -e" causes debugging script to exit (bashdb limitation). Consider using "trap 'exit $?' ERR" instead. +* On Windows 10, there is a problem with starting bash without console window (https://github.com/Microsoft/BashOnWindows/issues/2#issuecomment-209118529); + +## Homepage +[https://github.com/rogalmic/vscode-bash-debug/](https://github.com/rogalmic/vscode-bash-debug/) \ No newline at end of file diff --git a/package.json b/package.json index 44ce937..f4bd6da 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bash-debug", "displayName": "Bash Debug", - "version": "0.0.1", + "version": "0.0.2", "publisher": "rogalmic", "description": "A debugger extension for bash scripts (using bashdb).", "author": { diff --git a/src/bashDebug.ts b/src/bashDebug.ts index 745b97b..092708f 100644 --- a/src/bashDebug.ts +++ b/src/bashDebug.ts @@ -1,15 +1,10 @@ /// /// -import { - DebugSession, - InitializedEvent, TerminatedEvent, StoppedEvent, BreakpointEvent, OutputEvent, Event, - Thread, StackFrame, Scope, Source, Handles, Breakpoint -} from 'vscode-debugadapter'; +import {DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, BreakpointEvent, OutputEvent, Event, Thread, StackFrame, Scope, Source, Handles, Breakpoint} from 'vscode-debugadapter'; import {DebugProtocol} from 'vscode-debugprotocol'; +import {ChildProcess, spawn} from "child_process"; import {basename} from 'path'; -import {readFileSync, unlink, openSync, closeSync, createReadStream, ReadStream, existsSync, readFile} from 'fs'; -import * as ChildProcess from "child_process"; export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments { @@ -24,8 +19,7 @@ class BashDebugSession extends DebugSession { private static THREAD_ID = 42; private static END_MARKER = "############################################################"; - private _debuggerProcess: ChildProcess.ChildProcess; - private _pipeReadProcess: ChildProcess.ChildProcess; + private _debuggerProcess: ChildProcess; private _currentBreakpointIds = new Map>(); @@ -63,7 +57,7 @@ class BashDebugSession extends DebugSession { this.sendResponse(response) }); - ChildProcess.spawn("bash", ["-c", `pkill -9 -P ${this._debuggerProcessParentId}`]); + spawn("bash", ["-c", `pkill -9 -P ${this._debuggerProcessParentId}`]); } protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void { @@ -74,7 +68,7 @@ class BashDebugSession extends DebugSession { // use fifo, because --tty '&1' does not work properly for subshell (when bashdb spawns - $() ) // when this is fixed in bashdb, use &1 - this._debuggerProcess = ChildProcess.spawn("bash", ["-c", ` + this._debuggerProcess = spawn("bash", ["-c", ` # http://tldp.org/LDP/abs/html/io-redirection.html diff --git a/src/extension.ts b/src/extension.ts index 7583956..25aa98c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3,31 +3,41 @@ import * as vscode from 'vscode'; const initialConfigurations = { - configuration1: [ - { - name: 'Bash-Debug (select script from list of sh files)', - type: 'bashdb', - request: 'launch', - scriptPath: '${command.SelectScriptName}', - commandLineArguments: '' - }], - configuration2: [ - { - name: 'Bash-Debug (hardcoded script name)', - type: 'bashdb', - request: 'launch', - scriptPath: '${workspaceRoot}/path/to/script.sh', - commandLineArguments: '' - }], - configuration3: [ - { - name: 'Bash-Debug (type in script name)', - type: 'bashdb', - request: 'launch', - scriptPath: '${workspaceRoot}/${command.AskForScriptName}', - commandLineArguments: '' + configuration1: { + "version": "0.2.0", + "configurations": [ + { + name: 'Bash-Debug (select script from list of sh files)', + type: 'bashdb', + request: 'launch', + scriptPath: '${command.SelectScriptName}', + commandLineArguments: '' + }] + }, + configuration2: { + "version": "0.2.0", + "configurations": [ + { + name: 'Bash-Debug (hardcoded script name)', + type: 'bashdb', + request: 'launch', + scriptPath: '${workspaceRoot}/path/to/script.sh', + commandLineArguments: '' + }] + }, + configuration3: { + "version": "0.2.0", + "configurations": [ + { + name: 'Bash-Debug (type in script name)', + type: 'bashdb', + request: 'launch', + scriptPath: '${workspaceRoot}/${command.AskForScriptName}', + commandLineArguments: '' + } + ] } - ]} +} export function activate(context: vscode.ExtensionContext) { @@ -59,11 +69,11 @@ export function activate(context: vscode.ExtensionContext) { switch(parseInt(result.substr(0,1))) { case 1: - return JSON.stringify(initialConfigurations.configuration1); + return JSON.stringify(initialConfigurations.configuration1, null, "\t"); case 2: - return JSON.stringify(initialConfigurations.configuration2); + return JSON.stringify(initialConfigurations.configuration2, null, "\t"); default: - return JSON.stringify(initialConfigurations.configuration3); + return JSON.stringify(initialConfigurations.configuration3, null, "\t"); } }) })); From 064b08f54da549b2e32283a9aec093232d71cf56 Mon Sep 17 00:00:00 2001 From: Michal Rogalinski Date: Sun, 6 Nov 2016 22:08:10 +0100 Subject: [PATCH 2/2] configuration setup for bugfix release --- CHANGELOG.md | 6 ++++-- README.md | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e628405..07294a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,11 @@ -0.0.1 +0.0.2 ===== ## [Bugfix release v0.0.2-apha.2](https://github.com/rogalmic/vscode-bash-debug/releases/tag/v0.0.2-apha.2) - fixed broken initial configurations (for VS Code 1.7.1) -- using single bash instance as backend +- using single bash process instance as backend - dropping "tree-kill" usage (using unix pkill directly) +0.0.1 +===== ## [Initial release v0.0.1-apha.1](https://github.com/rogalmic/vscode-bash-debug/releases/tag/v0.0.1-apha.1) diff --git a/README.md b/README.md index 2e52bf2..ccba2f2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,18 @@ # VS Code Bash Debug A bash debugger GUI frontend based on awesome bashdb scripts. +Helpful links: + +[https://en.wikipedia.org/wiki/Bash_(Unix_shell)](https://en.wikipedia.org/wiki/Bash_%28Unix_shell%29) + +[https://www.gnu.org/software/bash/manual/](https://www.gnu.org/software/bash/manual/) + +Sources: + +[https://github.com/rogalmic/vscode-bash-debug/](https://github.com/rogalmic/vscode-bash-debug/) + +[https://sourceforge.net/p/bashdb/code/ci/master/tree/](https://sourceforge.net/p/bashdb/code/ci/master/tree/) + # Overview This is a SIMPLE bashdb debugger frontend. Useful for learning bash shell usage and writing simple scripts. @@ -10,12 +22,13 @@ Sample usage animation: 1. Creating launch configuration with "wizzard" 2. Running debug session +Dependencies: +1. bashdb 4.3 +2. cat, mkfifo, mktemp, rm, pkill + ![unfortunatly no animation for you](images/bash-debug.gif "Creating launch configuration, then launching debugger for one of scripts in workarea...") ## Limitations and known problems * Currently debugger stops at first command. * Executing "set -e" causes debugging script to exit (bashdb limitation). Consider using "trap 'exit $?' ERR" instead. * On Windows 10, there is a problem with starting bash without console window (https://github.com/Microsoft/BashOnWindows/issues/2#issuecomment-209118529); - -## Homepage -[https://github.com/rogalmic/vscode-bash-debug/](https://github.com/rogalmic/vscode-bash-debug/) \ No newline at end of file