Skip to content

Commit

Permalink
Merge pull request #16 from rogalmic/feature/experimentalCheckPipeOpt…
Browse files Browse the repository at this point in the history
…ions

Feature/experimental check pipe options
  • Loading branch information
rogalmic authored Nov 6, 2016
2 parents 99cf0ad + 064b08f commit 6714b2f
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 45 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
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 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)

## What's New
- [Initial release v0.0.1-apha.1](https://github.com/rogalmic/vscode-bash-debug/releases/tag/v0.0.1-apha.1)
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Copyright (c) Microsoft Corporation
Copyright (c) 2016 Microsoft Corporation, Michał Rogaliński

All rights reserved.
All rights reserved.

MIT License

Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -10,9 +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.
* 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);
* 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);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
16 changes: 5 additions & 11 deletions src/bashDebug.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
/// <reference types="es6-collections" />
/// <reference types="node" />

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 {

Expand All @@ -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<string, Array<number>>();

Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
64 changes: 37 additions & 27 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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");
}
})
}));
Expand Down

0 comments on commit 6714b2f

Please sign in to comment.