├── bashdb_dir
├── lib
│ ├── cmd-hooks.sh
│ ├── unescape.sh
│ ├── run.sh
│ ├── sort.sh
│ ├── stepping.sh
│ ├── dbg-call.sh
│ ├── validate.sh
│ ├── subcmd.sh
│ ├── alias.sh
│ ├── setshow.sh
│ ├── shell.sh
│ ├── journal.sh
│ └── commands.sh
├── AUTHORS
├── LICENSE
├── command
│ ├── show_sub
│ │ ├── version.sh
│ │ ├── warranty.sh
│ │ ├── debug.sh
│ │ ├── width.sh
│ │ ├── annotate.sh
│ │ ├── prompt.sh
│ │ ├── args.sh
│ │ ├── different.sh
│ │ ├── autoeval.sh
│ │ ├── tty.sh
│ │ ├── listsize.sh
│ │ ├── autolist.sh
│ │ ├── basename.sh
│ │ ├── highlight.sh
│ │ ├── history.sh
│ │ ├── alias.sh
│ │ ├── editing.sh
│ │ ├── directories.sh
│ │ ├── style.sh
│ │ └── commands.sh
│ ├── info_sub
│ │ ├── stack.sh
│ │ ├── handle.sh
│ │ ├── line.sh
│ │ ├── display.sh
│ │ ├── program.sh
│ │ ├── source.sh
│ │ ├── watchpoints.sh
│ │ ├── functions.sh
│ │ ├── breakpoints.sh
│ │ ├── files.sh
│ │ ├── signals.sh
│ │ └── warranty.sh
│ ├── set_sub
│ │ ├── prompt.sh
│ │ ├── debug.sh
│ │ ├── debugging.sh
│ │ ├── different.sh
│ │ ├── autoeval.sh
│ │ ├── basename.sh
│ │ ├── trace-commands.sh
│ │ ├── dollar0.sh
│ │ ├── autolist.sh
│ │ ├── args.sh
│ │ ├── width.sh
│ │ ├── annotate.sh
│ │ ├── showcommand.sh
│ │ ├── editing.sh
│ │ ├── listsize.sh
│ │ ├── tty.sh
│ │ ├── linetrace.sh
│ │ ├── history.sh
│ │ └── highlight.sh
│ ├── pwd.sh
│ ├── clear.sh
│ ├── finish.sh
│ ├── tty.sh
│ ├── return.sh
│ ├── file.sh
│ ├── disable.sh
│ ├── display.sh
│ ├── next.sh
│ ├── source.sh
│ ├── skip.sh
│ ├── undisplay.sh
│ ├── alias.sh
│ ├── export.sh
│ ├── untrace.sh
│ ├── enable.sh
│ ├── edit.sh
│ ├── load.sh
│ ├── frame.sh
│ ├── signal.sh
│ ├── complete.sh
│ ├── commands.sh
│ ├── watch.sh
│ ├── delete.sh
│ ├── continue.sh
│ ├── condition.sh
│ ├── down.sh
│ ├── up.sh
│ ├── set.sh
│ ├── info.sh
│ ├── history.sh
│ ├── kill.sh
│ ├── debug.sh
│ ├── trace.sh
│ ├── run.sh
│ └── quit.sh
├── THANKS
├── dbg-set-d-vars.inc
├── data
│ └── shell.sh
├── init
│ ├── require.sh
│ └── io.sh
└── bashdb-main.inc
├── jasmine.json
├── .gitignore
├── images
├── bash-debug-icon.png
└── bash-debug-icon.svg
├── .vscodeignore
├── CODE_OF_CONDUCT.md
├── .eslintrc.js
├── .vscode
├── tasks.json
├── settings.json
└── launch.json
├── src
├── tsconfig.json
├── eventSource.ts
├── handlePath.ts
├── spawnBash.ts
└── handlePath.spec.ts
├── bash-debug.code-workspace
├── .travis.yml
├── LICENSE
├── .github
└── ISSUE_TEMPLATE.md
└── CONTRIBUTING.md
/bashdb_dir/lib/cmd-hooks.sh:
--------------------------------------------------------------------------------
1 | typeset -A _Dbg_cmdloop_hooks
2 |
--------------------------------------------------------------------------------
/jasmine.json:
--------------------------------------------------------------------------------
1 | {
2 | "spec_dir": "src",
3 | "spec_files": ["**/*[sS]pec.ts"]
4 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | out/
4 | npm-debug.log
5 | bash-debug.txt
6 | *.vsix
7 |
--------------------------------------------------------------------------------
/images/bash-debug-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rogalmic/vscode-bash-debug/HEAD/images/bash-debug-icon.png
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | .vscode-test/**
3 | src/**
4 | .gitignore
5 | .travis.yml
6 | **/tsconfig.json
7 | **/tslint.json
8 | **/*.map
9 | **/*.ts
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Standards
4 |
5 | * Using welcoming and inclusive language
6 | * Focusing on what is best for the community
7 | * Being respectful of differing viewpoints and experiences
8 | * Accepting constructive criticism
9 |
10 |
--------------------------------------------------------------------------------
/images/bash-debug-icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/bashdb_dir/AUTHORS:
--------------------------------------------------------------------------------
1 | R. Bernstein (rocky@gnu.org)
2 |
3 | with ideas from (via a predecessor bashdb):
4 |
5 | Bill Rosenblatt,
6 | Michael Loukides,
7 | Cigy Cyriac,
8 | Chet Ramey,
9 | Gary V. Vaughan
10 |
11 | and other debuggers, e.g. ruby-debug, pdb, pydb, zshdb:
12 |
13 | Kent Sibilev
14 |
15 |
16 | Kate Ward is the author of shunit2 used in unit testing
17 |
18 | Stéphane Chazelas is the author of getopts_long.sh for GNU long options
19 | processing
20 |
21 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parser: "@typescript-eslint/parser",
3 | parserOptions: {
4 | ecmaVersion: 2020,
5 | sourceType: "module" // Allows for the use of imports
6 | },
7 | extends: [
8 | "plugin:@typescript-eslint/recommended" // Uses the recommended rules from the @typescript-eslint/eslint-plugin
9 | ],
10 | rules: {
11 | "@typescript-eslint/ban-types": "off",
12 | "@typescript-eslint/no-unused-vars": "off"
13 | }
14 | };
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "type": "npm",
7 | "script": "watch",
8 | "problemMatcher": "$tsc-watch",
9 | "isBackground": true,
10 | "presentation": {
11 | "reveal": "never"
12 | },
13 | "group": {
14 | "kind": "build",
15 | "isDefault": true
16 | }
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.FALSE
2 | {
3 | "javascript.validate.enable": false,
4 | "typescript.tsdk": "node_modules/typescript/lib",
5 | "files.trimTrailingWhitespace": true,
6 | "editor.insertSpaces": true,
7 | "editor.detectIndentation": false,
8 | "editor.formatOnSave": true,
9 | "editor.renderWhitespace": "all",
10 | "shellcheck.exclude": [
11 | "SC2148",
12 | "SC2154",
13 | "SC1090",
14 | "SC2034"
15 | ],
16 | "shellcheck.customArgs": [
17 | "--external-sources"
18 | ]
19 | }
--------------------------------------------------------------------------------
/src/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es2018",
5 | "lib": [
6 | "es2020"
7 | ],
8 | "noImplicitAny": false,
9 | "removeComments": true,
10 | "noUnusedLocals": true,
11 | "noImplicitThis": true,
12 | "inlineSourceMap": false,
13 | "sourceMap": true,
14 | "outDir": "../out",
15 | "preserveConstEnums": true,
16 | "strictNullChecks": true,
17 | "noUnusedParameters": true
18 | },
19 | "exclude": [
20 | "node_modules",
21 | ".vscode-test"
22 | ]
23 | }
--------------------------------------------------------------------------------
/bash-debug.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": "."
5 | }
6 | ],
7 | "settings": {
8 | "javascript.validate.enable": false,
9 | "typescript.tsdk": "./node_modules/typescript/lib",
10 | "shellcheck.exclude": [
11 | "SC2148",
12 | "SC2154",
13 | "SC1090",
14 | "SC2034"
15 | ],
16 | "shellcheck.customArgs": [
17 | "--external-sources"
18 | ]
19 | },
20 | "extensions": {
21 | "recommendations": [
22 | "ms-vscode.vscode-js-profile-flame",
23 | "dbaeumer.vscode-eslint"
24 | ]
25 | }
26 | }
--------------------------------------------------------------------------------
/bashdb_dir/LICENSE:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2 | # 2009, 2010, 2011 Rocky Bernstein
3 | #
4 | # This program is free software; you can redistribute it and/or
5 | # modify it under the terms of the GNU General Public License as
6 | # published by the Free Software Foundation; either version 2, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program; see the file COPYING. If not, write to
16 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
17 | # MA 02111 USA.
18 | #
19 |
20 | See https://sourceforge.net/p/bashdb/code/ci/master/tree/ for details.
--------------------------------------------------------------------------------
/bashdb_dir/lib/unescape.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # unescape.sh - info help Routines
3 |
4 | # Copyright (C) 2018
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | function _Dbg_unescape_arg() {
23 | builtin echo -n -e "$@"
24 | }
25 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/run.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Copyright (C) 2008 Rocky Bernstein rocky@gnu.org
3 | #
4 | # bashdb is free software; you can redistribute it and/or modify it under
5 | # the terms of the GNU General Public License as published by the Free
6 | # Software Foundation; either version 2, or (at your option) any later
7 | # version.
8 | #
9 | # bashdb is distributed in the hope that it will be useful, but WITHOUT ANY
10 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 | # for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License along
15 | # with bashdb; see the file COPYING. If not, write to the Free Software
16 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
17 |
18 | _Dbg_not_running () {
19 | if (( ! _Dbg_running )) ; then
20 | _Dbg_errmsg 'The program is not being run.'
21 | return 0
22 | fi
23 | return 1
24 | }
25 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/version.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show version" debugger command
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY VERSION; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show version \
22 | 'Show debugger version.' 1
23 |
24 | # _Dbg_do_show_version() is defined elsewhere
25 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | node_js:
4 | - '12.18.3'
5 |
6 | os:
7 | - linux
8 |
9 | group: dev
10 | sudo: required
11 | dist: bionic
12 |
13 | branches:
14 | only:
15 | - master
16 | - /^v\d+\.\d+\.\d+$/
17 |
18 | env:
19 | global:
20 | - RELEASE_TAG_EXPRESSION=^v?[0-9]+\.[0-9]+\.[0-9]+$
21 |
22 | install:
23 | - npm install
24 |
25 | script:
26 | - npm run test
27 | - npm run package
28 |
29 | deploy:
30 | - provider: releases
31 | api_key: $GITHUB_TOKEN
32 | file_glob: true
33 | file: "*.vsix"
34 | skip_cleanup: true
35 | on:
36 | branch: master
37 | condition: "$TRAVIS_OS_NAME == linux"
38 | - provider: script
39 | script: npx vsce publish -p $VSCE_TOKEN --packagePath *.vsix
40 | skip_cleanup: true
41 | on:
42 | tags: true
43 | condition: "$TRAVIS_TAG =~ $RELEASE_TAG_EXPRESSION"
44 | - provider: script
45 | script: npx ovsx publish *.vsix -p $OVSX_TOKEN
46 | skip_cleanup: true
47 | on:
48 | tags: true
49 | condition: "$TRAVIS_TAG =~ $RELEASE_TAG_EXPRESSION"
50 |
51 | cache:
52 | directories:
53 | - node_modules
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/stack.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "info stack" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info stack \
22 | "**info stack** [*count* [*frame-index*]]
23 |
24 | Same as \"backtrace\"." 1
25 |
26 | _Dbg_do_info_stack() {
27 | _Dbg_do_backtrace $@
28 | }
29 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/prompt.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set prompt" debugger command
3 | #
4 | # Copyright (C) 2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set prompt \
22 | 'set prompt PROMPT-STRING
23 |
24 | Set the debugger prompt string.' 1
25 |
26 | _Dbg_do_set_prompt() {
27 | _Dbg_prompt_str="$1"
28 | return $?
29 | }
30 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/handle.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "info signals" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info handle \
22 | '**info handle**
23 |
24 | Same as \"info signals\".' 1
25 |
26 | # List signal handlers in effect.
27 | function _Dbg_do_info_handle {
28 | _Dbg_do_info_signals $@
29 | }
30 |
--------------------------------------------------------------------------------
/src/eventSource.ts:
--------------------------------------------------------------------------------
1 | export class EventSource {
2 | private callbacks: { callback: () => void; oneTime: boolean; callCount: number }[] = [];
3 |
4 | public setEvent(): void {
5 | this.callbacks = this.callbacks.filter(c => !(c.oneTime === true && c.callCount !== 0));
6 | this.callbacks.forEach(c => {
7 | c.callback();
8 | c.callCount++;
9 | });
10 | }
11 |
12 | public onEvent(): Promise {
13 | return new Promise((resolve) => {
14 | this.scheduleOnce(() => resolve());
15 | });
16 | }
17 |
18 | public schedule(callback: () => void): void {
19 | const multipleTimesCallback =
20 | {
21 | callback: () => { callback(); }, oneTime: false, callCount: 0
22 | };
23 |
24 | this.callbacks.push(multipleTimesCallback);
25 | }
26 |
27 | public scheduleOnce(callback: () => void): void {
28 | const oneTimeCallback =
29 | {
30 | callback: () => { callback(); }, oneTime: true, callCount: 0
31 | };
32 |
33 | this.callbacks.push(oneTimeCallback);
34 | }
35 | }
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/warranty.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show warranty" debugger command
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show warranty \
22 | 'info warranty
23 |
24 | Lack of warranty of this debugger.' 1
25 |
26 | _Dbg_show_nolist[warranty]=1
27 |
28 | _Dbg_do_show_warranty() {
29 | _Dbg_do_info_warranty
30 | return 0
31 | }
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 Microsoft Corporation, Michał Rogaliński
2 |
3 | All rights reserved.
4 |
5 | MIT License
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/debug.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set debug" debugger command
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set debug \
22 | 'set debug [on|off]
23 |
24 | When set, we allow debugging the debugger.' 1
25 |
26 | _Dbg_next_complete[set debug]='_Dbg_complete_onoff'
27 |
28 | _Dbg_do_set_debug() {
29 | _Dbg_set_onoff "$1" 'debug'
30 | return $?
31 | }
32 |
--------------------------------------------------------------------------------
/bashdb_dir/command/pwd.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Debugger pwd command.
3 | #
4 | # Copyright (C) 2002-2004, 2006, 2008, 2010, 2016 Rocky Bernstein
5 | #
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add pwd \
23 | '**pwd**
24 |
25 | Show working directory.'
26 |
27 | _Dbg_do_pwd() {
28 | typeset _Dbg_cwd; _Dbg_cwd=$(pwd)
29 | (( _Dbg_set_basename )) && _Dbg_cwd=${_Dbg_cwd##*/}
30 | _Dbg_msg "Working directory ${_Dbg_cwd}."
31 | }
32 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/debugging.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set debugging" debugger command
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set debug \
22 | 'set debug [on|off]
23 |
24 | When set, we allow debugging the debugger.' 1
25 |
26 | _Dbg_next_complete[set debug]='_Dbg_complete_onoff'
27 |
28 | _Dbg_do_set_debug() {
29 | _Dbg_set_onoff "$1" 'debug'
30 | return $?
31 | }
32 |
--------------------------------------------------------------------------------
/bashdb_dir/command/clear.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # A perl5-ish clear breakpoint command
3 | # Copyright (C) 2011 Rocky Bernstein
4 | #
5 | # This program is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU General Public License as
7 | # published by the Free Software Foundation; either version 2, or
8 | # (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | # General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program; see the file COPYING. If not, write to
17 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
18 | # MA 02111 USA.
19 |
20 | _Dbg_help_add clear \
21 | 'clear LINE
22 |
23 | clear all breakpoints at a line LINE.' 1
24 |
25 |
26 | _Dbg_do_clear() {
27 | _Dbg_do_clear_brkpt $_Dbg_args
28 | _Dbg_last_cmd='clear'
29 | return $?
30 | }
31 |
32 | # To be compatible with Perl.
33 | _Dbg_alias_add d clear
34 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/debug.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show debugging" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show debug \
22 | "Show if we are set to debug the debugger." 1
23 |
24 | _Dbg_do_show_debug() {
25 | [[ -n $1 ]] && label=$(_Dbg_printf_nocr "%-12s: " debug)
26 | _Dbg_show_onoff 'debug' 'Allow debugging the debugger' "$label"
27 | return 0
28 | }
29 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/different.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set different" debugger command
3 | #
4 | # Copyright (C) 2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set different \
22 | '**set different** [**off**|**on**]
23 |
24 | Set to stop at a different line
25 |
26 | See also:
27 | ---------
28 |
29 | **show different**'
30 |
31 | _Dbg_do_set_different() {
32 | _Dbg_set_onoff "$1" 'different'
33 | return $?
34 | }
35 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/width.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show width" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show width \
22 | 'show width
23 |
24 | Show maximum width of a line
25 |
26 | See also \"set width\".' 1
27 |
28 | _Dbg_do_show_width() {
29 | [[ -n $label ]] && label=$(_Dbg_printf_nocr "%-12s: " width)
30 | _Dbg_msg \
31 | "${label}Line width is $_Dbg_set_linewidth."
32 | return 0
33 | }
34 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/annotate.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show annotate" debugger command
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show annotate \
22 | 'show annotate
23 |
24 | Show annotation level.
25 |
26 | See \"set annotate\" for level numbers.
27 | ' 1
28 |
29 | _Dbg_do_show_annotate() {
30 | [[ -n $1 ]] && label=$(_Dbg_printf_nocr "%-12s: " annotate)
31 | _Dbg_msg \
32 | "${label}Annotation_level is $_Dbg_set_annotate."
33 | }
34 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/autoeval.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set autoeval" debugger command
3 | #
4 | # Copyright (C) 2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set autoeval \
22 | '**set autoeval** [**on**|**off**]
23 |
24 | Evaluate unrecognized commands
25 |
26 | See also:
27 | ---------
28 |
29 | **show autoeval**
30 | ' 1
31 |
32 | _Dbg_next_complete[set autoeval]='_Dbg_complete_onoff'
33 |
34 | _Dbg_do_set_autoeval() {
35 | _Dbg_set_onoff "$1" 'autoeval'
36 | return $?
37 | }
38 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | In addition to the details for issue, please provide us *Executables* information and *Debug output* unless you have confidence that they don't help us.
2 |
3 | ## Executables
4 | Version of bash-debug: (can be checked in: ctrl+shift+X or command+shift+X -> INSTALLED: Bash Debug)
5 |
6 | Output of following commands (on windows, execute them in Command Prompt or PowerShell):
7 |
8 | ```
9 | where bash
10 | # if `code` not found on macOS, follow the instructions in:
11 | # https://code.visualstudio.com/docs/setup/mac
12 | code --version
13 | bash -c 'uname -a; for P in bash bashdb cat mkfifo pkill; do echo ---; which -a $P; command $P --version; done'
14 | ```
15 |
16 | ## Debug output
17 | Paste here outputs in DEBUG CONSOLE (ctrl+shift+D or command+shift+D) with `"showDebugOutput": true` and `"trace": true` in `launch.json`.
18 | Your `launch.json` may looks like:
19 |
20 | ```json
21 | {
22 | "version": "0.2.0",
23 | "configurations": [
24 | {
25 | "type": "bashdb",
26 | "request": "launch",
27 | "name": "Bash Debug",
28 | "program": "${workspaceFolder}/src/foo.sh",
29 | "showDebugOutput": true,
30 | "trace": true
31 | }
32 | ]
33 | }
34 | ```
35 |
36 | ## Details
37 | Details goes here.
38 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/prompt.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show directories" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show prompt \
22 | 'show prompt
23 |
24 | Show prompt string.' 1
25 | # FIXME add dir and then See also dir.
26 |
27 | _Dbg_do_show_prompt() {
28 | [[ -n $1 ]] && label=$(_Dbg_printf_nocr "%-12s: " prompt)
29 | _Dbg_msg \
30 | "${label}${_Dbg_debugger_name}'s prompt is:\n" \
31 | " \"$_Dbg_prompt_str\"."
32 | return 0
33 | }
34 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/args.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show args" debugger command
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show args \
22 | 'show args
23 |
24 | Print the argument list to given when debugged program restarts.
25 | ' 1
26 |
27 | _Dbg_do_show_args() {
28 | [[ -n $1 ]] && label=$(_Dbg_printf_nocr "%-12s: " args)
29 | _Dbg_msg \
30 | "${label}Argument list to give script when debugged program starts is:\n" \
31 | " \"${_Dbg_orig_script_args[@]}\"."
32 | }
33 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/basename.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set basename" debugger command
3 | #
4 | # Copyright (C) 2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set basename \
22 | '**set basename** [**on**|**off**]
23 |
24 |
25 | Set short filenames (the basename) in debug output
26 |
27 | See also:
28 | ---------
29 |
30 | **show basename**
31 | '
32 |
33 | _Dbg_next_complete[set basename]='_Dbg_complete_onoff'
34 |
35 | _Dbg_do_set_basename() {
36 | _Dbg_set_onoff "$1" 'basename'
37 | return $?
38 | }
39 |
--------------------------------------------------------------------------------
/bashdb_dir/THANKS:
--------------------------------------------------------------------------------
1 | The following kind people have contributed to this debugger:
2 |
3 | Eric Blake - packaging/build fixes. cygwin packaging
4 | Manfred Tremmel - RPM building for SuSE
5 | Masatake YAMATO - Emacs support, screenshots, progress meter
6 | Matthias Klose - making build system and
7 | package more industrial
8 | strength.
9 | Mikael Andersson snikkt at telia dot com - "V" command auto* fixes
10 | Oleksandr Moskalenko Debian packaging
11 | Matt Fleming - NetBSD packaging
12 | Alberto Griggio - Annotate patch #1781965 (for pydb)
13 |
14 | Some ideas from Kent Sibilev's ruby-debug have been encorporated into
15 | this debugger.
16 |
17 | The O'Reilly book on the Korn shell by Bill Rosenblatt suggested that
18 | it might be possible to write a debugger.
19 |
20 | Thanks to Chet Ramey for continued support of bash and
21 | adding/encorprating changes needed to support debugging better.
22 |
23 | --
24 |
25 | The following software is used in this debugger:
26 |
27 | getopts_long.sh by Stéphane Chazelas - GNU-compatible long-options parsing
28 | shunit2 by Kate Ward - unit tests
29 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/different.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show different" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show different \
22 | 'show different
23 |
24 | Show whether stepping forces a new line.
25 |
26 | See also \"set different\".' 1
27 |
28 | _Dbg_do_show_different() {
29 | [[ -n $1 ]] && label=$(_Dbg_printf_nocr "%-12s: " different)
30 | _Dbg_msg \
31 | "${label}Show stepping forces a new line is" $(_Dbg_onoff $_Dbg_set_different)
32 | return 0
33 | }
34 |
--------------------------------------------------------------------------------
/bashdb_dir/command/finish.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # finsh.sh - Debugger "finish" (step out) commmand.
3 | #
4 | # Copyright (C) 2010 Rocky Bernstein rocky@gnu.org
5 | #
6 | # bashdb is free software; you can redistribute it and/or modify it under
7 | # the terms of the GNU General Public License as published by the Free
8 | # Software Foundation; either version 2, or (at your option) any later
9 | # version.
10 | #
11 | # bashdb is distributed in the hope that it will be useful, but WITHOUT ANY
12 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | # for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License along
17 | # with bashdb; see the file COPYING. If not, write to the Free Software
18 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
19 |
20 | _Dbg_help_add finish \
21 | "finish
22 |
23 | Continue execution until leaving the current function.
24 | Sometimes this is called 'step out'."
25 |
26 | _Dbg_do_finish() {
27 | _Dbg_not_running && return 3
28 |
29 | (( _Dbg_return_level=${#FUNCNAME[@]}-5 ))
30 | _Dbg_last_cmd='finish'
31 | _Dbg_inside_skip=0
32 | _Dbg_continue_rc=0
33 | return 0
34 | }
35 |
36 | _Dbg_alias_add fin finish
37 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/autoeval.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show autoeval" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show autoeval \
22 | 'show autoeval
23 |
24 | Show whether unrecognized commands are automatically evaluated.
25 |
26 | See also \"set autoeval\".' 1
27 |
28 | _Dbg_do_show_autoeval() {
29 | [[ -n $1 ]] && label=$(_Dbg_printf_nocr "%-12s: " autoeval)
30 | _Dbg_msg \
31 | "${label}Evaluate unrecognized commands is" $(_Dbg_onoff $_Dbg_set_autoeval)
32 | return 0
33 | }
34 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/tty.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show tty" debugger command
3 | #
4 | # Copyright (C) 2011-2012 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY
12 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | # for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show tty \
22 | "Show tty used for debugger output" 1
23 |
24 | _Dbg_do_show_tty() {
25 | typeset label
26 | [[ -n $1 ]] && label=$(builtin printf '%-12s: ' 'show tty') || label=''
27 | _Dbg_msg_nocr \
28 | "${label}Debugger output goes to "
29 | if [[ -n $_Dbg_tty ]] ; then
30 | _Dbg_msg $(tty)
31 | else
32 | _Dbg_msg $_Dbg_tty
33 | fi
34 | return 0
35 | }
36 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/listsize.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show listsize" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show listsize \
22 | 'show listsize
23 |
24 | Show maximum number of lines in a \"list\" display
25 |
26 | See also \"set listsize\".' 1
27 |
28 | _Dbg_do_show_listsize() {
29 | [[ -n $label ]] && label=$(_Dbg_printf_nocr "%-12s: " listsize)
30 | _Dbg_msg \
31 | "${label}Number of source lines ${_Dbg_debugger_name} will list by default is" \
32 | "$_Dbg_set_listsize."
33 | return 0
34 | }
35 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/line.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info line" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info line \
22 | '**info line**
23 |
24 | Show line and filename for stopped position in program.
25 |
26 | See also:
27 | ---------
28 |
29 | **info program**.' 1
30 |
31 | _Dbg_do_info_line() {
32 | if (( ! _Dbg_running )) ; then
33 | _Dbg_errmsg 'No line number information available.'
34 | return 1
35 | fi
36 |
37 | _Dbg_msg "Line $_Dbg_frame_last_lineno of \"$_Dbg_frame_last_filename\""
38 | return 0
39 | }
40 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/autolist.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show autoeval" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show autolist \
22 | 'show autolist
23 |
24 | Show whether to run a \"list\" commands entering debugger
25 |
26 | See also \"set autolist\".' 1
27 |
28 | _Dbg_do_show_autolist() {
29 | [[ -n $1 ]] && label=$(_Dbg_printf_nocr "%-12s: " autolist)
30 | typeset onoff="on."
31 | [[ -z ${_Dbg_cmdloop_hooks["list"]} ]] && onoff='off.'
32 | _Dbg_msg \
33 | "${label}Auto run of 'list' command is ${onoff}"
34 | return 0
35 | }
36 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/basename.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show basename" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show basename \
22 | 'show basename
23 |
24 | Show whether use short filenames
25 |
26 | See also \"set basename\".' 1
27 |
28 | _Dbg_do_show_basename() {
29 | [[ -n $1 ]] && label=$(_Dbg_printf_nocr "%-12s: " basename)
30 | _Dbg_msg \
31 | "${label}Show short filenames (the basename) in debug output is" $(_Dbg_onoff $_Dbg_set_basename)
32 | typeset onoff="on."
33 | [[ -z ${_Dbg_cmdloop_hooks["list"]} ]] && onoff='off.'
34 | return 0
35 | }
36 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/highlight.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show highlight" debugger command
3 | #
4 | # Copyright (C) 2011, 2015 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY
12 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | # for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show highlight \
22 | "Show syntax highlight of listings" 1
23 |
24 | _Dbg_do_show_highlight() {
25 | typeset label
26 | [[ -n $1 ]] && label=$(_Dbg_printf_nocr "%-12s: " highlight) || label=''
27 | _Dbg_msg_nocr \
28 | "${label}Syntax highlight in source listings is "
29 | if [[ -n $_Dbg_set_highlight ]] ; then
30 | _Dbg_msg "${_Dbg_set_highlight}."
31 | else
32 | _Dbg_msg 'off.'
33 | fi
34 | return 0
35 | }
36 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/history.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show history" debugger command
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show history \
22 | "Show information on command history saving" 1
23 |
24 | _Dbg_do_show_history() {
25 | _Dbg_printf "%-12s-- " history
26 | _Dbg_msg \
27 | " filename: The filename in which to record the command history is $_Dbg_histfile"
28 | _Dbg_msg \
29 | " save: Saving of history save is" $(_Dbg_onoff $_Dbg_set_history)
30 | _Dbg_msg \
31 | " size: Debugger history size is $_Dbg_history_length"
32 | typeset label="$1"
33 | return 0
34 | }
35 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/alias.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show alias" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show alias \
22 | 'show alias [NAME1 NAME2 ...]
23 |
24 | If aliases names are given, show their definition. If left blank, show
25 | all alias names' 1
26 |
27 | _Dbg_show_nolist[alias]=1
28 |
29 | _Dbg_do_show_alias() {
30 | typeset -a list
31 | list=()
32 | for alias in "${!_Dbg_aliases[@]}"; do
33 | [[ -z ${_Dbg_aliases[$alias]} ]] && continue
34 | list+=("${alias}: ${_Dbg_aliases[$alias]}")
35 | done
36 | _Dbg_list_columns ' | '
37 | return 0
38 | }
39 |
--------------------------------------------------------------------------------
/bashdb_dir/dbg-set-d-vars.inc:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | #$Id: dbg-set-d-vars.inc,v 1.5 2008/08/04 00:43:17 rockyb Exp $
3 | # Copyright (C) 2002, 2003, 2004, 2007, 2008 Rocky Bernstein rocky@gnu.org
4 | #
5 | # bashdb is free software; you can redistribute it and/or modify it under
6 | # the terms of the GNU General Public License as published by the Free
7 | # Software Foundation; either version 2, or (at your option) any later
8 | # version.
9 | #
10 | # bashdb is distributed in the hope that it will be useful, but WITHOUT ANY
11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 | # for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License along
16 | # with bashdb; see the file COPYING. If not, write to the Free Software
17 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
18 |
19 | # set dollar variables ($1, $2, ... $?)
20 | # to their values in the debugged environment before we entered the debugger.
21 |
22 | local _Dbg_set_str='set --'
23 | local -i _Dbg__i
24 | for (( _Dbg__i=1 ; _Dbg__i<=${#_Dbg_arg[@]}; _Dbg__i++ )) ; do
25 | local dq_argi=$(_Dbg_esc_dq "${_Dbg_arg[$_Dbg__i]}")
26 | _Dbg_set_str="$_Dbg_set_str \"$dq_argi\""
27 | done
28 | eval "$_Dbg_set_str"
29 |
30 | PS4="$_Dbg_old_PS4"
31 | IFS="$_Dbg_old_IFS"
32 |
33 | # Setting $? has to be done last.
34 | _Dbg_set_dol_q
35 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/editing.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show editing" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show editing \
22 | "Show editing of command lines as they are typed" 1
23 |
24 | _Dbg_do_show_editing() {
25 | typeset label="$1"
26 | [[ -n $label ]] && label=$(_Dbg_printf_nocr "%-12s: " editing)
27 | _Dbg_msg_nocr \
28 | "${label}Editing of command lines as they are typed is "
29 | if [[ -z $_Dbg_edit ]] ; then
30 | _Dbg_msg 'off.'
31 | else
32 | _Dbg_msg 'on.'
33 | _Dbg_msg \
34 | " Edit style is $_Dbg_edit_style."
35 | fi
36 | return 0
37 | }
38 |
--------------------------------------------------------------------------------
/bashdb_dir/command/tty.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # tty command.
3 | #
4 | # Copyright (C) 2002, 2003, 2004, 2006, 2008, 2012 Rocky Bernstein
5 | # rocky@gnu.org
6 | #
7 | # bashdb is free software; you can redistribute it and/or modify it under
8 | # the terms of the GNU General Public License as published by the Free
9 | # Software Foundation; either version 2, or (at your option) any later
10 | # version.
11 | #
12 | # bashdb is distributed in the hope that it will be useful, but WITHOUT ANY
13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 | # for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with bashdb; see the file COPYING. If not, write to the Free Software
19 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
20 |
21 | _Dbg_help_add tty \
22 | 'tty
23 |
24 | Set the output device for debugger output. Use "&1" if you want debugger
25 | output to go to STDOUT.
26 | '
27 |
28 | # Set output tty
29 | _Dbg_do_tty() {
30 | typeset -i rc=0
31 | if (( $# < 1 )) ; then
32 | _Dbg_errmsg "Argument required (terminal name for running target process)."
33 | return 1
34 | fi
35 | typeset tty=$1
36 | if _Dbg_check_tty $tty ; then
37 | _Dbg_tty=$tty
38 | _Dbg_prompt_output=$_Dbg_tty
39 | _Dbg_msg "Debugger output set to go to $_Dbg_tty"
40 | fi
41 | return 0
42 | }
43 |
--------------------------------------------------------------------------------
/bashdb_dir/command/return.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "return" (return from fn immediately) debugger command
3 | #
4 | # Copyright (C) 2010, 2016 Rocky Bernstein
5 | #
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | # Move default values up $1 or one in the stack.
23 | _Dbg_help_add return \
24 | '**return**
25 |
26 | Force an immediate return from a function.
27 |
28 | The remainder of function will not be executed.
29 |
30 | See also:
31 | ---------
32 |
33 | **finish**, **quit**, and **run**.'
34 |
35 | function _Dbg_do_return {
36 | _Dbg_step_ignore=1
37 | _Dbg_write_journal "_Dbg_step_ignore=$_Dbg_step_ignore"
38 | IFS="$_Dbg_old_IFS";
39 | _Dbg_last_cmd='return'
40 | _Dbg_inside_skip=0
41 | _Dbg_continue_rc=2
42 | return 0
43 | }
44 |
--------------------------------------------------------------------------------
/bashdb_dir/data/shell.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # shell.sh - helper routines for 'shell' debugger command
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | trap '_Dbg_write_saved_vars' EXIT
22 | typeset -a _Dbg_save_vars
23 |
24 | # _Dbg_tmpdir='/tmp'
25 | # _Dbg_restore_info="${_Dbg_tmpdir}/${_Dbg_debugger_name}_restore_$$"
26 | typeset -a _Dbg_save_vars; _Dbg_save_vars=()
27 |
28 | # User level routine which should be called to mark which
29 | # variables should persist.
30 | save_vars() {
31 | _Dbg_save_vars+=($@)
32 | }
33 |
34 | _Dbg_write_saved_vars() {
35 | typeset param
36 | for param in "${_Dbg_save_vars[@]}" ; do
37 | typeset -p $param | sed -e 's:declare [^ ]* ::'
38 | done > $_Dbg_restore_info
39 | }
40 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/directories.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show directories" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub show directories \
22 | 'show directories
23 |
24 | Show list of drectories used to search for not fully qualified file names.' 1
25 | # FIXME add dir and then See also dir.
26 |
27 | _Dbg_do_show_directories() {
28 | # Don't do anything if called as part of "show" (all)
29 | [[ -n $1 ]] && return
30 |
31 | typeset list=${_Dbg_dir[0]}
32 | typeset -i n=${#_Dbg_dir[@]}
33 | typeset -i i
34 | for (( i=1 ; i < n; i++ )) ; do
35 | list="${list}:${_Dbg_dir[i]}"
36 | done
37 |
38 | _Dbg_msg "Source directories searched: $list"
39 | return 0
40 | }
41 |
--------------------------------------------------------------------------------
/src/handlePath.ts:
--------------------------------------------------------------------------------
1 | import { join } from 'path';
2 |
3 | export function expandPath(path?: string, rootPath?: string): string | undefined {
4 |
5 | if (!path) {
6 | return undefined;
7 | }
8 |
9 | if (rootPath) {
10 | path = path.replace("{workspaceFolder}", rootPath).split("\\").join("/");
11 | }
12 |
13 | return path;
14 | }
15 |
16 | export function getWSLPath(path?: string): string | undefined {
17 |
18 | if (!path) {
19 | return undefined;
20 | }
21 |
22 | if (!path.startsWith("/")) {
23 | path = "/mnt/" + path.substr(0, 1).toLowerCase() + path.substr("X:".length).split("\\").join("/");
24 | }
25 |
26 | return path;
27 | }
28 |
29 | export function reverseWSLPath(wslPath: string): string {
30 |
31 | if (wslPath.startsWith("/mnt/")) {
32 | return wslPath.substr("/mnt/".length, 1).toUpperCase() + ":" + wslPath.substr("/mnt/".length + 1).split("/").join("\\");
33 | }
34 |
35 | return wslPath.split("/").join("\\");
36 | }
37 |
38 | export function getWSLLauncherPath(useInShell: boolean): string {
39 |
40 | if (useInShell) {
41 | return "wsl.exe";
42 | }
43 |
44 | return process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432') ?
45 | join("C:", "Windows", "sysnative", "wsl.exe") :
46 | join("C:", "Windows", "System32", "wsl.exe");
47 | }
48 |
49 | export function escapeCharactersInBashdbArg(path: string): string {
50 | return path.replace(/\s/g, (m) => "\\\\" + ("0000" + m.charCodeAt(0).toString(8)).slice(-4));
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/display.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info display" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info display \
22 | "**info display**" 1
23 |
24 | # List display command(s)
25 | _Dbg_do_info_display() {
26 | if [ ${#_Dbg_disp_exp[@]} != 0 ]; then
27 | typeset i=0
28 | _Dbg_msg "Auto-display statements now in effect:"
29 | _Dbg_msg "Num Enb Expression "
30 | for (( i=0; i < _Dbg_disp_max; i++ )) ; do
31 | if [ -n "${_Dbg_disp_exp[$i]}" ] ;then
32 | _Dbg_printf '%-3d %3d %s' \
33 | $i ${_Dbg_disp_enable[$i]} "${_Dbg_disp_exp[$i]}"
34 | fi
35 | done
36 | else
37 | _Dbg_msg "No display expressions have been set."
38 | fi
39 | return 0
40 | }
41 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/program.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info program" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info program '
22 | **info program**
23 |
24 | Information about debugged program stopping point.
25 |
26 | See also:
27 | ---------
28 |
29 | \"info line\".' 1
30 |
31 | _Dbg_do_info_program() {
32 | if (( _Dbg_running )) ; then
33 | _Dbg_msg "Program stopped."
34 | if [[ -n $_Dbg_stop_reason ]] ; then
35 | _Dbg_msg "It stopped ${_Dbg_stop_reason}."
36 | fi
37 | if [[ -n $_Dbg_bash_command ]] ; then
38 | _Dbg_msg "Next statement to be run is:\n\t${_Dbg_bash_command}"
39 | fi
40 | else
41 | _Dbg_errmsg "The program being debugged is not being run."
42 | fi
43 | return $?
44 | }
45 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/source.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "info source" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info source \
22 | '**info source**
23 |
24 | Information about the current source file.
25 |
26 | See also:
27 | ---------
28 |
29 | \"info program\", \"info file\" and \"info line\".' 1
30 |
31 | # list source and break condition.
32 | # If $1 is given just list those associated for that line.
33 | _Dbg_do_info_source() {
34 | _Dbg_msg "Current script file is $_Dbg_frame_last_filename"
35 | _Dbg_msg "Located in ${_Dbg_file2canonic[$_Dbg_frame_last_filename]}"
36 | typeset -i max_line
37 | max_line=$(_Dbg_get_maxline $_Dbg_frame_last_filename)
38 | _Dbg_msg "Contains $max_line lines."
39 | _Dbg_do_list_brkpt $*
40 | return 0
41 | }
42 |
--------------------------------------------------------------------------------
/src/spawnBash.ts:
--------------------------------------------------------------------------------
1 | import { ChildProcess, SpawnSyncReturns, spawnSync, spawn } from 'child_process';
2 | import { getWSLLauncherPath } from './handlePath';
3 |
4 | export function spawnBashScript(scriptCode: string, pathBash: string, outputHandler?: (output: string, category?: string) => void): ChildProcess {
5 | const currentShell = (process.platform === "win32") ? getWSLLauncherPath(false) : pathBash;
6 | const optionalBashPathArgument = (currentShell !== pathBash) ? pathBash : "";
7 |
8 | const spawnedProcess = spawn(currentShell, [optionalBashPathArgument, "-c", scriptCode].filter(arg => arg !== ""), { stdio: ["pipe", "pipe", "pipe"], shell: false });
9 |
10 | if (outputHandler) {
11 | spawnedProcess.on("error", (error) => {
12 | outputHandler(`${error}`, `console`);
13 | });
14 |
15 | spawnedProcess.stderr.on("data", (data) => {
16 | outputHandler(`${data}`, `stderr`);
17 | });
18 |
19 | spawnedProcess.stdout.on("data", (data) => {
20 | outputHandler(`${data}`, `stdout`);
21 | });
22 | }
23 |
24 | return spawnedProcess;
25 | }
26 |
27 | export function spawnBashScriptSync(scriptCode: string, pathBash: string, spawnTimeout: number): SpawnSyncReturns {
28 | const currentShell = (process.platform === "win32") ? getWSLLauncherPath(false) : pathBash;
29 | const optionalBashPathArgument = (currentShell !== pathBash) ? pathBash : "";
30 |
31 | return spawnSync(currentShell, [optionalBashPathArgument, "-c", scriptCode].filter(arg => arg !== ""), { timeout: spawnTimeout, shell: false });
32 | }
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/trace-commands.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set trace-commands" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | # Sets whether or not to display command before executing it.
22 | typeset _Dbg_set_trace_commands='off'
23 |
24 | # Handled special because of the dash in the command name.
25 | # _Dbg_help_add_sub set trace-commands \
26 | # 'Set showing debugger commands' 1
27 |
28 | _Dbg_do_set_trace_commands() {
29 | case "$1" in
30 | 1 )
31 | _Dbg_write_journal_eval "_Dbg_set_trace_commands=on"
32 | ;;
33 | 0 )
34 | _Dbg_write_journal_eval "_Dbg_set_trace_commands=off"
35 | ;;
36 | on | off )
37 | _Dbg_write_journal_eval "_Dbg_set_trace_commands=$1"
38 | ;;
39 | * )
40 | _Dbg_msg "\"on\", \"off\" expected."
41 | esac
42 | return $?
43 | }
44 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/dollar0.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # set dollar0 sets $0
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | # Load set0 if possible.
22 | if [[ -f "$_Dbg_libdir/builtin/set0" ]] ; then
23 | enable -f "$_Dbg_libdir/builtin/set0" set0 2>/dev/null
24 | fi
25 |
26 | # If it was set0 loaded, then we can add a debugger command "set dollar0"
27 | if enable -a set0 2>/dev/null ; then
28 | _Dbg_help_add_sub set dollar0 \
29 | 'set dollar0 PROGRAM_NAME
30 |
31 | Set $0 to PROGRAM_NAME.' 1
32 |
33 | _Dbg_do_set_dollar0() {
34 | # We use the loop below rather than _Dbg_set_args="(@)" because
35 | # we want to preserve embedded blanks in the arguments.
36 | if enable -a set0 2>/dev/null ; then
37 | set0 "$1"
38 | else
39 | _Dbg_errmsg "Can't do becasue set0 module is not loaded."
40 | fi
41 | return 0
42 | }
43 | fi
44 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/sort.sh:
--------------------------------------------------------------------------------
1 | # Sort global array, $list, starting from $1 to up to $2. 0 is
2 | # returned if everything went okay, and nonzero if there was an error.
3 |
4 | # We use the recursive quicksort of Tony Hoare with inline array
5 | # swapping to partition the array. The partition item is the middle
6 | # array item. String comparison is used. The sort is not stable.
7 |
8 | sort_list() {
9 | (($# != 2)) && return 1
10 | typeset -i left=$1
11 | ((left < 0)) || (( 0 == ${#list[@]})) && return 2
12 | typeset -i right=$2
13 | ((right >= ${#list[@]})) && return 3
14 | typeset -i i=$left; typeset -i j=$right
15 | typeset -i mid; ((mid= (left+right) / 2))
16 | typeset partition_item; partition_item="${list[$mid]}"
17 | typeset temp
18 | while ((j > i)) ; do
19 | item=${list[i]}
20 | while [[ "${list[$i]}" < "$partition_item" ]] ; do
21 | ((i++))
22 | done
23 | while [[ "${list[$j]}" > "$partition_item" ]] ; do
24 | ((j--))
25 | done
26 | if ((i <= j)) ; then
27 | temp="${list[$i]}"; list[$i]="${list[$j]}"; list[$j]="$temp"
28 | ((i++))
29 | ((j--))
30 | fi
31 | done
32 | ((left < j)) && sort_list $left $j
33 | ((right > i)) && sort_list $i $right
34 | return 0
35 | }
36 |
37 | if [[ $0 == *sorting.sh ]] ; then
38 | [[ -n $ZSH_VERSION ]] && setopt ksharrays
39 | typeset -a list
40 | list=()
41 | sort_list -1 0
42 | typeset -p list
43 | list=('one')
44 | typeset -p list
45 | sort_list 0 0
46 | typeset -p list
47 | list=('one' 'two' 'three')
48 | sort_list 0 2
49 | typeset -p list
50 | list=(4 3 2 1)
51 | sort_list 0 3
52 | typeset -p list
53 | fi
54 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/autolist.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set autolist" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set autolist \
22 | '**set autolist** [**on**|**off**]
23 |
24 | Run list command automatically every time the debugger enters
25 |
26 | See also:
27 | ---------
28 |
29 | **show autolist**' 1
30 |
31 | _Dbg_next_complete[set autolist]='_Dbg_complete_onoff'
32 |
33 | _Dbg_do_set_autolist() {
34 | typeset onoff=${1:-'off'}
35 | case $onoff in
36 | on | 1 )
37 | _Dbg_write_journal_eval "_Dbg_cmdloop_hooks[list]=_Dbg_do_list"
38 | ;;
39 | off | 0 )
40 | _Dbg_write_journal_eval "unset '_Dbg_cmdloop_hooks[list]'"
41 | unset '_Dbg_cmdloop_hooks[list]'
42 | ;;
43 | * )
44 | _Dbg_errmsg "\"on\" or \"off\" expected."
45 | return 1
46 | esac
47 | _Dbg_do_show 'autolist'
48 | return 0
49 | }
50 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/style.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show style" debugger command
3 | #
4 | # Copyright (C) 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY
12 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | # for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | # If run standalone, pull in other files we need
22 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
23 | dirname=${BASH_SOURCE[0]%/*}
24 | [[ $dirname == $0 ]] && top_dir='../..' || top_dir=${dirname}/../..
25 | [[ -z $_Dbg_libdir ]] && _Dbg_libdir=$top_dir
26 | for file in help alias ; do source $top_dir/lib/${file}.sh; done
27 | fi
28 |
29 | _Dbg_help_add_sub show style \
30 | "Show pygments terminal formatting style" 1
31 |
32 | _Dbg_do_show_style() {
33 | typeset label="$1"
34 | [[ -n $label ]] && label='style: '
35 | _Dbg_msg_nocr \
36 | "${label}Pygments terminal formatting style is "
37 | if [[ -n $_Dbg_set_style ]] ; then
38 | _Dbg_msg "${_Dbg_set_style}."
39 | else
40 | _Dbg_msg 'off.'
41 | fi
42 | return 0
43 | }
44 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/args.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set args" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set args \
22 | '**set args** *script-args*
23 |
24 | Set argument list to give program being debugged when it is started.
25 | Follow this command with any number of args, to be passed to the program.
26 | ' 1
27 |
28 | _Dbg_do_set_args() {
29 | # We use the loop below rather than _Dbg_set_args="(@)" because
30 | # we want to preserve embedded blanks in the arguments.
31 | _Dbg_script_args=()
32 | typeset -i i
33 | typeset -i n=$#
34 | typeset -i m=${#_Dbg_orig_script_args[@]}
35 | for (( i=0; i
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | # If run standalone, pull in other files we need
22 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
23 | dirname=${BASH_SOURCE[0]%/*}
24 | [[ $dirname == $0 ]] && top_dir='../..' || top_dir=${dirname}/../..
25 | [[ -z $_Dbg_libdir ]] && _Dbg_libdir=$top_dir
26 | for file in help alias ; do source $top_dir/lib/${file}.sh; done
27 | fi
28 |
29 | _Dbg_help_add_sub set width \
30 | '**set** **width** *width*
31 |
32 | Set maximum width of lines to *width*.
33 | ' 1
34 |
35 | typeset -i _Dbg_set_linewidth; _Dbg_set_linewidth=${COLUMNS:-80}
36 |
37 | _Dbg_do_set_width() {
38 | if [[ $1 == $int_pat ]] ; then
39 | _Dbg_write_journal_eval "_Dbg_set_linewidth=$1"
40 | else
41 | _Dbg_errmsg "Integer argument expected; got: $1"
42 | return 1
43 | fi
44 | return 0
45 | }
46 |
--------------------------------------------------------------------------------
/bashdb_dir/command/file.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "file" debugger command
3 | #
4 | # Copyright (C) 2002-2008, 2010, 2013
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add file \
23 | "file FILENAME
24 |
25 | Set FILENAME as the current source file."
26 |
27 | _Dbg_do_file() {
28 |
29 | typeset filename
30 | if (( $# < 1 )) ; then
31 | _Dbg_errmsg "Need to give a filename for the file command"
32 | return 1
33 | fi
34 | _Dbg_tilde_expand_filename "$1"
35 | if [[ ! -f "$filename" ]] && [[ ! -x "$filename" ]] ; then
36 | _Dbg_errmsg "Source file $filename does not exist as a readable regular file."
37 | return 1
38 | fi
39 | typeset filevar=$(_Dbg_file2var ${BASH_SOURCE[3]})
40 | _Dbg_set_assoc_scalar_entry "_Dbg_file_cmd_" $filevar "$filename"
41 | typeset source_file
42 | source_file=$(_Dbg_file_canonic "${BASH_SOURCE[3]}")
43 | _Dbg_msg "File $filename will be used when $source_file is referenced."
44 | return 0
45 | }
46 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/watchpoints.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "info breakpoints" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info watchpoints \
22 | "**info watchpoints** [*num* ...]
23 |
24 | Show status of watchpoints. If no watchpoint numbers are
25 | given, the show all watchpoints. Otherwise only those watchpoints
26 | listed are shown and the order given.
27 |
28 | The \"Disp\" column contains one of \"keep\", \"del\", the disposition of
29 | the breakpoint after it gets hit.
30 |
31 | The \"enb\" column indicates whether the breakpoint is enabled.
32 |
33 | The \"Where\" column indicates where the breakpoint is located.
34 | Info whether use short filenames
35 |
36 | See also:
37 | ---------
38 |
39 | **break**, **enable**, and **disable**." 1
40 |
41 | # list watchpoints
42 | # If $1 is given just list those associated for that line.
43 | _Dbg_do_info_watchpoints() {
44 | _Dbg_list_watch $*
45 | }
46 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/annotate.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set annotate" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set annotate \
22 | '**set annotate** {**0**|**1**}
23 |
24 | Set annotation level.
25 |
26 | 0 - normal
27 | 1 - fullname (for use when running under emacs).
28 |
29 | See also:
30 | ---------
31 |
32 | **show annotate**
33 | ''Set annotation level [N]
34 | ' 1
35 |
36 | _Dbg_do_set_annotate() {
37 | eval "$_seteglob"
38 | if (( $# != 1 )) ; then
39 | _Dbg_msg "A single argument is required (got $# arguments)."
40 | elif [[ $1 == $int_pat ]] ; then
41 | if (( $1 > 3 )) ; then
42 | _Dbg_msg "Annotation level must be between 0 and 3. Got: ${1}."
43 | else
44 | _Dbg_write_journal_eval "_Dbg_set_annotate=$1"
45 | fi
46 | else
47 | eval "$_resteglob"
48 | _Dbg_msg "Integer argument expected; got: $1"
49 | return 1
50 | fi
51 | eval "$_resteglob"
52 | return 0
53 | }
54 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/functions.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "info functions" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info functions \
22 | '**info functions** [*pattern*]
23 |
24 | Show functions matching regular expression PATTERN.
25 | If pattern is empty, list all functions.
26 |
27 | Examples:
28 | ---------
29 |
30 | info functions \# list of all functions
31 | info functions s \# functions containing an \"s\"
32 | info function \^s \# functions starting with an \"s\"
33 |
34 | See also:
35 | ---------
36 |
37 | **info variables**.' 1
38 |
39 | # list functions and break condition.
40 | # If $1 is given just list those associated for that line.
41 | _Dbg_do_info_functions() {
42 | typeset pat=$1
43 |
44 | typeset -a fns_a
45 | fns_a=($(_Dbg_get_functions 0 "$pat"))
46 | typeset -i i
47 | for (( i=0; i < ${#fns_a[@]}; i++ )) ; do
48 | _Dbg_msg ${fns_a[$i]}
49 | done
50 | return 0
51 | }
52 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/showcommand.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set showcommand" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set showcommand \
22 | 'Set showcommand [on|off]
23 |
24 | Set showing the command to execute.' 1
25 |
26 | # Sets whether or not to display command to be executed in debugger prompt.
27 | # If yes, always show. If auto, show only if the same line is to be run
28 | # but the command is different.
29 | typeset _Dbg_set_show_command="auto"
30 |
31 | _Dbg_next_complete[set showcommand]='_Dbg_complete_onoff'
32 |
33 | _Dbg_do_set_showcommand() {
34 | case $1 in
35 | 1 )
36 | _Dbg_write_journal_eval "_Dbg_set_show_command=on"
37 | ;;
38 | 0 )
39 | _Dbg_write_journal_eval "_Dbg_set_show_command=off"
40 | ;;
41 | on | off | auto )
42 | _Dbg_write_journal_eval "_Dbg_set_show_command=$1"
43 | ;;
44 | * )
45 | _Dbg_errmsg "\"on\", \"off\" or \"auto\" expected."
46 | esac
47 | return 0
48 | }
49 |
--------------------------------------------------------------------------------
/bashdb_dir/command/disable.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # disable.sh - gdb-like "disable" debugger command
3 | #
4 | # Copyright (C) 2002-2006, 2008, 2011, 2016-2017
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add disable \
23 | '**disable** *bpnum1* [*bpnum2* ...]
24 |
25 | Disables breakopints *bpnum1*, *bpnum2*. Breakpoints numbers are given
26 | as a space-separated list of breakpoint numbers.
27 |
28 | To disable all breakpoints, give no argument.
29 | A disabled breakpoint is not forgotten, but has no effect until re-enabled.
30 |
31 |
32 | See also:
33 | ---------
34 |
35 | **enable** and **info break**.
36 | ' 1 _Dbg_complete_brkpt_range
37 |
38 | # Disable breakpoint(s)/watchpoint(s) by entry number(s).
39 | _Dbg_do_disable() {
40 | _Dbg_enable_disable 0 'disabled' "$@"
41 | return $?
42 | }
43 |
44 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
45 | require ./help.sh ../lib/msg.sh ../lib/sort.sh ../lib/columnize.sh \
46 | ../lib/list.sh
47 | _Dbg_args='enable'
48 | _Dbg_do_help enable
49 | fi
50 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/breakpoints.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "info breakpoints" debugger command
3 | #
4 | # Copyright (C) 2010-2012, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info breakpoints \
22 | "**info breakpoints**
23 |
24 | Show status of user-settable breakpoints. If no breakpoint numbers are
25 | given, the show all breakpoints. Otherwise only those breakpoints
26 | listed are shown and the order given.
27 |
28 | The \"Disp\" column contains one of \"keep\", \"del\", the disposition of
29 | the breakpoint after it gets hit.
30 |
31 | The \"enb\" column indicates whether the breakpoint is enabled.
32 |
33 | The \"Where\" column indicates where the breakpoint is located.
34 | Info whether use short filenames
35 |
36 | See also:
37 | ---------
38 |
39 | **break**, **enable**, and **disable**." 1
40 |
41 | # list breakpoints and break condition.
42 | # If $1 is given just list those associated for that line.
43 | _Dbg_do_info_breakpoints() {
44 | _Dbg_do_list_brkpt $@
45 | return $?
46 | }
47 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/files.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info files" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info files \
22 | '**info files**
23 |
24 | show a list of files that have been read in and properties regarding them.
25 | ' 1
26 |
27 | _Dbg_do_info_files() {
28 | _Dbg_msg "Source files which we have recorded info about:"
29 | typeset -a list=()
30 | typeset -i i=0
31 | typeset key
32 | for key in "${!_Dbg_file2canonic[@]}"; do
33 | list[$i]="$key"
34 | ((i++))
35 | done
36 | sort_list 0 ${#list[@]}-1
37 | for file in "${list[@]}" ; do
38 | typeset -i lines=$(_Dbg_get_maxline "$file")
39 | typeset canonic_file
40 | canonic_file="${_Dbg_file2canonic[$file]}"
41 | if (( _Dbg_set_basename )) ; then
42 | # Do the same with canonic_file ?
43 | file="${file##*/}"
44 | canonic_file="${canonic_file##*/}"
45 | fi
46 | _Dbg_msg " ${file}: ${canonic_file}, $lines lines"
47 | done
48 | return 0
49 | }
50 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/stepping.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # stepping routines
3 | #
4 | # Copyright (C) 2010 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_next_skip_common() {
22 |
23 | _Dbg_inside_skip=$1
24 | _Dbg_last_next_step_cmd="$_Dbg_cmd"
25 | _Dbg_last_next_step_args=$2
26 | _Dbg_not_running && return 3
27 |
28 | typeset count=${2:-1}
29 |
30 | if [[ $count == [0-9]* ]] ; then
31 | let _Dbg_step_ignore=${count:-1}
32 | else
33 | _Dbg_errmsg "Argument ($count) should be a number or nothing."
34 | _Dbg_step_ignore=1
35 | return 1
36 | fi
37 | # Do we step debug into functions called or not?
38 | if (( _Dbg_inside_skip == 0 )) ; then
39 | _Dbg_old_set_opts="${_Dbg_old_set_opts%% *} +o functrace"
40 | else
41 | _Dbg_old_set_opts="${_Dbg_old_set_opts%% *} -o functrace"
42 | fi
43 | _Dbg_write_journal_eval "_Dbg_old_set_opts='$_Dbg_old_set_opts'"
44 |
45 | _Dbg_write_journal "_Dbg_step_ignore=$_Dbg_step_ignore"
46 | # set -x
47 | _Dbg_continue_rc=$_Dbg_inside_skip
48 | return 0
49 | }
50 |
--------------------------------------------------------------------------------
/bashdb_dir/command/display.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # display.sh - gdb-like "display" debugger command
3 | #
4 | # Copyright (C) 2002-2003, 200-2011, 2016
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this Program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add display \
23 | "**display** [*stmt*]
24 |
25 | Evalute *stmt* each time the debugger is stopped. If *stmt* is omitted, evaluate
26 | all of the display statements that are active. In contrast, **info display**
27 | shows the display statements without evaluating them.
28 |
29 | Examples:
30 | ---------
31 |
32 | display echo \$x # show the current value of x each time debugger stops
33 | display # evaluate all display statements
34 |
35 | See also:
36 | ---------
37 |
38 | **undisplay** and **info display**."
39 |
40 | # Set display command or list all current display expressions
41 | _Dbg_do_display() {
42 | if (( 0 == $# )); then
43 | _Dbg_eval_all_display
44 | else
45 | typeset -i n=_Dbg_disp_max++
46 | _Dbg_disp_exp[$n]="$@"
47 | _Dbg_disp_enable[$n]=1
48 | _Dbg_printf '%2d: %s' $n "${_Dbg_disp_exp[$n]}"
49 | fi
50 | return 0
51 | }
52 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/dbg-call.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # This program needs to be SOURCE'd and is not called as an executable
3 | # Copyright (C) 2006, 2007, 2008 Rocky Bernstein rocky@gnu.org
4 | #
5 | # bashdb is free software; you can redistribute it and/or modify it under
6 | # the terms of the GNU General Public License as published by the Free
7 | # Software Foundation; either version 2, or (at your option) any later
8 | # version.
9 | #
10 | # bashdb is distributed in the hope that it will be useful, but WITHOUT ANY
11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 | # for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License along
16 | # with bashdb; see the file COPYING. If not, write to the Free Software
17 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
18 | #
19 |
20 | # Enter the debugger at the calling stack frame. This is useful to
21 | # hard-code a breakpoint at a given point in a program, even if the code
22 | # is not otherwise being debugged.
23 | # Leaving this the debugger terminates the program.
24 |
25 | # Any parameters after the first one are exec'd. In this way you can
26 | # force specific options to get set.
27 | _Dbg_debugger() {
28 | set -o functrace
29 | if (( $# > 0 )) ; then
30 | step_ignore=$1
31 | shift
32 | else
33 | typeset step_ignore=${_Dbg_step_ignore:-''}
34 | fi
35 |
36 | while (( $# > 0 )) ; do
37 | eval $1
38 | shift
39 | done
40 |
41 | if [[ -z $_Dbg_set_trace_init ]] ; then
42 | _Dbg_set_trace_init=1
43 | _Dbg_step_ignore=${step_ignore:-0}
44 | _Dbg_write_journal "_Dbg_step_ignore=0"
45 | else
46 | _Dbg_step_ignore=${1:-1}
47 | fi
48 | trap '_Dbg_debug_trap_handler 0 "$BASH_COMMAND" "$@"' DEBUG
49 | }
50 |
--------------------------------------------------------------------------------
/bashdb_dir/command/next.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "next" (step through) commmand.
3 | #
4 | # Copyright (C) 2008, 2010, 2015, 2016 Rocky Bernstein rocky@gnu.org
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | # Sets whether or not to display command to be executed in debugger prompt.
22 | # If yes, always show. If auto, show only if the same line is to be run
23 | # but the command is different.
24 |
25 | _Dbg_help_add next \
26 | "**next** [*count*]
27 |
28 | Single step an statement skipping functions. This is sometimes called
29 | 'step over' or 'step through'.
30 |
31 | If *count* is given, stepping occurs that many times before
32 | stopping. Otherwise *count* is one. *count* an be an arithmetic
33 | expression.
34 |
35 | Functions and source'd files are not traced. This is in contrast to
36 | **step**.
37 |
38 | See also:
39 | ---------
40 |
41 | **skip**." 1
42 |
43 | # Next command
44 | # $1 is command next+, next-, or next
45 | # $2 is an optional additional count.
46 | _Dbg_do_next() {
47 | _Dbg_last_cmd='next'
48 | _Dbg_inside_skip=0
49 | _Dbg_next_skip_common 0 $@
50 | return $?
51 | }
52 |
53 | _Dbg_alias_add 'n' 'next'
54 |
--------------------------------------------------------------------------------
/bashdb_dir/command/source.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "source" command.
3 | #
4 | # Copyright (C) 2002-2008, 2010, 2013, 2016
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | # Handle command-file source. If the filename's okay we just increase the
23 | # input-file descriptor by one and redirect input which will
24 | # be picked up in next debugger command loop.
25 |
26 | _Dbg_help_add source \
27 | '**source** *file*
28 |
29 | Run debugger commands in *file*.'
30 |
31 | _Dbg_do_source() {
32 | if (( $# == 0 )) ; then
33 | _Dbg_errmsg 'Need to give a filename for the "source" command.'
34 | return 1
35 | fi
36 |
37 | typeset filename
38 | _Dbg_tilde_expand_filename "$1"
39 | if [[ -r "$filename" ]] || [[ "$filename" == '/dev/stdin' ]] ; then
40 | # Open new input file descriptor and save number in _Dbg_fd.
41 | exec {_Dbg_fdi}<"$filename"
42 | _Dbg_fd[++_Dbg_fd_last]=$_Dbg_fdi
43 | # We'll store the filename for good measure too.
44 | _Dbg_cmdfile+=("$filename")
45 | else
46 | _Dbg_errmsg "Source file \"$filename\" is not readable."
47 | return 3
48 | fi
49 | return 0
50 | }
51 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/editing.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set editing" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set editing \
22 | '**set editing** [**on**|**off**|**emacs**|**vi**]
23 |
24 | Readline editing of command lines
25 |
26 | See also:
27 | ---------
28 |
29 | **show editing**
30 | '
31 |
32 | _Dbg_next_complete[set editing]='_Dbg_complete_edit'
33 |
34 | _Dbg_complete_edit() {
35 | COMPREPLY=(on off vi emacs)
36 | }
37 |
38 | _Dbg_do_set_editing() {
39 | typeset onoff=${1:-'on'}
40 | case $onoff in
41 | e | em | ema | emac | emacs )
42 | _Dbg_edit='-e'
43 | _Dbg_edit_style='emacs'
44 | ;;
45 | on | 1 )
46 | _Dbg_edit='-e'
47 | _Dbg_edit_style='emacs'
48 | ;;
49 | off | 0 )
50 | _Dbg_edit=''
51 | return 0
52 | ;;
53 | v | vi )
54 | _Dbg_edit='-e'
55 | _Dbg_edit_style='vi'
56 | ;;
57 | * )
58 | _Dbg_errmsg '"on", "off", "vi", or "emacs" expected.'
59 | return 1
60 | esac
61 | set -o $_Dbg_edit_style
62 | _Dbg_do_show_editing
63 | return 0
64 | }
65 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/listsize.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set listsize" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | # If run standalone, pull in other files we need
22 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
23 | dirname=${BASH_SOURCE[0]%/*}
24 | [[ $dirname == $0 ]] && top_dir='../..' || top_dir=${dirname}/../..
25 | [[ -z $_Dbg_libdir ]] && _Dbg_libdir=$top_dir
26 | for file in help alias ; do source $top_dir/lib/${file}.sh; done
27 | fi
28 |
29 | _Dbg_help_add_sub set listsize \
30 | '**set listsize** *number-of-lines*
31 |
32 | Set the number of source lines debugger will list by default.
33 |
34 | See also:
35 | ---------
36 |
37 | **show listsize**
38 | '
39 |
40 | # How many lines in a "list" command?
41 | typeset -xi _Dbg_set_listsize=10
42 |
43 | _Dbg_do_set_listsize() {
44 | eval "$_seteglob"
45 | if [[ $1 == $int_pat ]] ; then
46 | _Dbg_write_journal_eval "_Dbg_set_listsize=$1"
47 | else
48 | eval "$_resteglob"
49 | _Dbg_errmsg "Integer argument expected; got: $1"
50 | return 1
51 | fi
52 | eval "$_resteglob"
53 | return 0
54 | }
55 |
--------------------------------------------------------------------------------
/bashdb_dir/command/skip.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "skip" (step over) commmand.
3 | #
4 | # Copyright (C) 2010, 2011, 2017 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add skip \
22 | "**skip** [*count*]
23 |
24 | Skip (don't run) the next *count* command(s).
25 |
26 | If *count* is given, stepping occurs that many times before
27 | stopping. Otherwise *count* is one. *count* can be an arithmetic
28 | expression.
29 |
30 | Note that skipping doesn't change the value of \$?. This has
31 | consequences in some compound statements that test on \$?. For example
32 | in:
33 |
34 | if grep foo bar.txt ; then
35 | echo not skipped
36 | fi
37 |
38 | skipping the *if* statement will in effect skip running the *grep*
39 | command. Since the return code is 0 when skipped, the *if* body is
40 | entered. Similarly the same thing can happen in a *while* statement
41 | test.
42 |
43 | See http://lists.gnu.org/archive/html/bug-bash/2017-04/msg00004.html
44 |
45 | See also:
46 | ---------
47 |
48 | **next** and **step**.
49 | "
50 |
51 | _Dbg_do_skip() {
52 | _Dbg_last_cmd='skip'
53 | _Dbg_next_skip_common 1 $*
54 | return $?
55 | }
56 |
--------------------------------------------------------------------------------
/bashdb_dir/command/undisplay.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "undisplay"
3 | #
4 | # Copyright (C) 2002-2010 2016
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this Program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add undisplay \
23 | "**undisplay** *display-number*...
24 |
25 | Cancel some expressions to be displayed when program stops. Arguments are the code numbers
26 | of the expressions to stop displaying.
27 |
28 | Examples:
29 | ---------
30 |
31 | undisplay 0 # Removes display statement 0
32 | undisplay 0 3 4 # Removes display statements 0, 3, and 4
33 |
34 | See also:
35 | ---------
36 |
37 | *display* and *info display*."
38 |
39 | _Dbg_do_undisplay() {
40 | typeset -i del
41 |
42 | if (( 0 == $# )) ; then
43 | _Dbg_errmsg 'You need to pass in some display numbers.'
44 | return 0
45 | fi
46 |
47 | for del in $@ ; do
48 | if [ -n "${_Dbg_disp_exp[$del]}" ] ; then
49 | _Dbg_write_journal_eval "unset _Dbg_disp_exp[$del]"
50 | _Dbg_write_journal_eval "unset _Dbg_disp_enable[$del]"
51 | _Dbg_msg "Display entry $del unset."
52 | else
53 | _Dbg_msg "Display entry $del doesn't exist, so nothing done."
54 | fi
55 | done
56 | return 0
57 | }
58 |
--------------------------------------------------------------------------------
/bashdb_dir/command/alias.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # alias.sh - gdb-like "alias" debugger command
3 | #
4 | # Copyright (C) 2008, 2016 Rocky Bernstein rocky@gnu.org
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License along
17 | # with this program; see the file COPYING. If not, write to the Free Software
18 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
19 |
20 | _Dbg_help_add alias \
21 | '**alias** *alias-name* *debugger-command*
22 |
23 | Make *alias-name* be an alias for *debugger-command*.
24 |
25 | Examples:
26 | ---------
27 |
28 | alias cat list # "cat prog.py" is the same as "list prog.py"
29 | alias s step # "s" is now an alias for "step".
30 | # The above example is done by default.
31 |
32 | See also:
33 | ---------
34 |
35 | **unalias** and **show alias**.
36 | '
37 |
38 | _Dbg_do_alias() {
39 | if (($# != 2)) ; then
40 | _Dbg_errmsg "Got $# parameters, but need 2."
41 | return 1
42 | fi
43 | _Dbg_alias_add $1 $2
44 | return $?
45 | }
46 |
47 | _Dbg_help_add unalias \
48 | '**unalias** *name*
49 |
50 | Remove debugger command alias *name*.
51 |
52 | Use **show aliases** to get a list the aliases in effect.
53 | ' 1
54 |
55 | _Dbg_do_unalias() {
56 | if (($# != 1)) ; then
57 | _Dbg_errmsg "Got $# parameters, but need 1."
58 | return 1
59 | fi
60 | _Dbg_alias_remove $1
61 | return 0
62 | }
63 |
--------------------------------------------------------------------------------
/bashdb_dir/command/export.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Copyright (C) 2011 Rocky Bernstein
3 | #
4 | # This program is free software; you can redistribute it and/or
5 | # modify it under the terms of the GNU General Public License as
6 | # published by the Free Software Foundation; either version 2, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program; see the file COPYING. If not, write to
16 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
17 | # MA 02111 USA.
18 |
19 | _Dbg_help_add export \
20 | '**export** *var1* [**var2** ...]
21 |
22 | Marks **var1**, **var2***, to get reassigned with their current values after on
23 | subshell exit. The values are set by the debugger only after it
24 | notices that the current shell is left.
25 |
26 | Nothing is done if you aren not in a subshell.
27 | '
28 |
29 | _Dbg_do_export() {
30 |
31 | if (( $# == 0 )) ; then
32 | _Dbg_errmsg "Expecting at least one variable name; got none."
33 | return 1
34 | fi
35 |
36 | if (( 0 == BASH_SUBSHELL )) ; then
37 | _Dbg_errmsg "You are not in a subshell, so no value(s) need saving."
38 | return 2
39 | fi
40 |
41 | typeset var_name
42 | for var_name in $@ ; do
43 | _Dbg_defined $var_name
44 | if (( $? == 0 )) ; then
45 | typeset val
46 | typeset val_cmd="val=\${$var_name}"
47 | eval "$val_cmd"
48 | _Dbg_write_journal "${var_name}=${val}"
49 | else
50 | _Dbg_errmsg "name: $var_name is not known to be a variable."
51 | fi
52 | done
53 | return 0
54 | }
55 |
--------------------------------------------------------------------------------
/bashdb_dir/command/untrace.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | #
3 | # Copyright (C) 2008, 2010, 2011 Rocky Bernstein
4 | #
5 | # This program is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU General Public License as
7 | # published by the Free Software Foundation; either version 2, or
8 | # (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | # General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program; see the file COPYING. If not, write to
17 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
18 | # MA 02111 USA.
19 |
20 | _Dbg_help_add untrace \
21 | 'untrace FUNCTION
22 |
23 | Untrace previously-traced function FUNCTION. See also "trace".'
24 |
25 | # Undo wrapping fn
26 | # $? is 0 if successful.
27 | function _Dbg_do_untrace {
28 | typeset fn=$1
29 | if [[ -z $fn ]] ; then
30 | _Dbg_errmsg "untrace: missing or invalid function name."
31 | return 2
32 | fi
33 | _Dbg_is_function "$fn" $_Dbg_set_debug || {
34 | _Dbg_errmsg "untrace: function \"$fn\" is not a function."
35 | return 3
36 | }
37 | _Dbg_is_function "old_$fn" || {
38 | _Dbg_errmsg "untrace: old function old_$fn not seen - nothing done."
39 | return 4
40 | }
41 | if cmd=$(declare -f -- "old_$fn") ; then
42 | if [[ $cmd =~ '^function old_' ]] ; then
43 | cmd="function ${cmd:13}"
44 | else
45 | cmd=${cmd#old_}
46 | fi
47 | ((_Dbg_debug_debugger)) && echo $cmd
48 | eval "$cmd" || return 6
49 | _Dbg_msg "\"$fn\" restored from \"old_${fn}\"."
50 | return 0
51 | else
52 | _Dbg_errmsg "Can't find function definition for \"$fn\"."
53 | return 5
54 | fi
55 | }
56 |
--------------------------------------------------------------------------------
/bashdb_dir/command/enable.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "enable" debugger command
3 | #
4 | # Copyright (C) 2002-2006, 2008, 2011, 2016-2017 Rocky Bernstein
5 | #
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
23 | source ../init/require.sh
24 | # FIXME: require loses scope for typeset -A...
25 | source ../lib/help.sh
26 | require ../lib/alias.sh
27 | fi
28 |
29 | _Dbg_help_add enable \
30 | '**enable** *bpnum1* [*bpnum2* ...]
31 |
32 | Enables breakpoints *bpnum1*, *bpnum2*... Breakpoints numbers are
33 | given as a space-separated list of numbers.
34 | With no subcommand, breakpoints are enabled until you command otherwise.
35 | This is used to cancel the effect of the "disable" command.
36 |
37 |
38 | See also:
39 | ---------
40 |
41 | **disable** and **info break**.'
42 |
43 | # Enable breakpoint(s)/watchpoint(s) by entry number(s).
44 | _Dbg_do_enable() {
45 | _Dbg_enable_disable 1 'enabled' "$@"
46 | return $?
47 | }
48 |
49 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
50 | require ./help.sh ../lib/msg.sh ../lib/sort.sh ../lib/columnize.sh \
51 | ../lib/list.sh
52 | _Dbg_args='enable'
53 | _Dbg_do_help enable
54 | fi
55 |
--------------------------------------------------------------------------------
/bashdb_dir/command/show_sub/commands.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show commands" debugger command
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
22 | source ${BASH_SOURCE[0]%/*}/../../lib/help.sh
23 | fi
24 |
25 | _Dbg_help_add_sub show commands \
26 | 'show commands [+NUM]
27 |
28 | Show the history of commands you typed.
29 | You can supply a command number to start with, or a "+" to start after
30 | the previous command number shown.' 1
31 |
32 | _Dbg_show_nolist[commands]=1
33 |
34 | _Dbg_do_show_commands() {
35 | typeset -i default_hi_start=_Dbg_hi-1
36 | if ((default_hi_start < 0)) ; then default_hi_start=0 ; fi
37 | typeset hi_start=${2:-$default_hi_start}
38 |
39 | eval "$_seteglob"
40 | case $hi_start in
41 | "+" )
42 | ((hi_start=_Dbg_hi_last_stop-1))
43 | ;;
44 | $int_pat | -$int_pat)
45 | :
46 | ;;
47 | * )
48 | _Dbg_msg "Invalid parameter $hi_start. Need an integer or '+'"
49 | esac
50 | eval "$_resteglob"
51 |
52 | typeset -i hi_stop=hi_start-10
53 | _Dbg_do_history_list $hi_start $hi_stop
54 | _Dbg_hi_last_stop=$hi_stop
55 | }
56 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "type": "extensionHost",
6 | "request": "launch",
7 | "name": "Extension",
8 | "preLaunchTask": "build",
9 | "runtimeExecutable": "${execPath}",
10 | "args": [
11 | "--extensionDevelopmentPath=${workspaceFolder}"
12 | ],
13 | "outFiles": [
14 | "${workspaceFolder}/out/**/*.js"
15 | ]
16 | },
17 | {
18 | "type": "node",
19 | "request": "launch",
20 | "name": "Server",
21 | "cwd": "${workspaceFolder}",
22 | "program": "${workspaceFolder}/src/bashDebug.ts",
23 | "args": [
24 | "--server=4711"
25 | ],
26 | "outFiles": [
27 | "${workspaceFolder}/out/**/*.js"
28 | ]
29 | },
30 | {
31 | "type": "node",
32 | "request": "launch",
33 | "name": "Jasmine Tests Current File",
34 | "program": "${workspaceFolder}/node_modules/jasmine/bin/jasmine.js",
35 | "runtimeExecutable": "node",
36 | "runtimeArgs": [
37 | "--nolazy",
38 | "-r",
39 | "ts-node/register/transpile-only"
40 | ],
41 | "args": [
42 | "--config=./jasmine.json",
43 | "${file}"
44 | ],
45 | "console": "integratedTerminal",
46 | "internalConsoleOptions": "neverOpen",
47 | "skipFiles": [
48 | "/**",
49 | "node_modules/**"
50 | ]
51 | }
52 | ],
53 | "compounds": [
54 | {
55 | "name": "Extension + Server",
56 | "configurations": [
57 | "Extension",
58 | "Server"
59 | ]
60 | }
61 | ]
62 | }
--------------------------------------------------------------------------------
/bashdb_dir/command/edit.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Debugger Edit command
3 |
4 | # Copyright (C) 2008, 2010, 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | #================ VARIABLE INITIALIZATIONS ====================#
22 |
23 | _Dbg_help_add edit \
24 | "**edit** [*line-number*]
25 |
26 | Edit specified file at *line-number*.
27 |
28 | If *line-number* is not given, use the current line number.
29 | Uses \"EDITOR\" environment variable contents as editor (or ex as default).
30 | Assumes the editor positions at a file using options \"+linenumber filename\"."
31 |
32 | _Dbg_do_edit() {
33 | if (($# > 2)) ; then
34 | _Dbg_errmsg "got $# parameters, but need 0 or 1."
35 | return 2
36 | fi
37 | typeset editor=${EDITOR:-ex}
38 | typeset -i line_number
39 | if (( $# == 0 )) ; then
40 | line_number=$_Dbg_frame_last_lineno
41 | full_filename="$_Dbg_frame_last_filename"
42 | else
43 | _Dbg_linespec_setup "$1"
44 | fi
45 | if [[ ! -r $full_filename ]] ; then
46 | _Dbg_errmsg "File $full_filename is not readable"
47 | return 2
48 | fi
49 | $editor +$line_number $full_filename
50 | rc=$?
51 | ((rc==0)) && _Dbg_last_cmd='edit'
52 | return $rc
53 | }
54 |
55 | _Dbg_alias_add 'ed' 'edit'
56 |
--------------------------------------------------------------------------------
/bashdb_dir/command/load.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Debugger load SCRIPT command.
3 | #
4 | # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008, 2010,
5 | # 2011, 2018 Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add load \
23 | '**load** SCRIPT
24 |
25 | Read in lines of a SCRIPT for use in listing.
26 |
27 | For paths with space characters please use octal escape, e.g.:
28 | load /some/path\\0400with\\0400spaces/script.sh'
29 |
30 | _Dbg_do_load() {
31 |
32 | if (( $# != 1 )) ; then
33 | _Dbg_errmsg "Expecting one filename parameter, Got $#."
34 | return 1
35 | fi
36 |
37 | typeset filename="$(_Dbg_unescape_arg "$1")"
38 | local full_filename=$(_Dbg_resolve_expand_filename "$filename")
39 | if [ -n "$full_filename" ] && [ -r "$full_filename" ] ; then
40 | # Have we already loaded in this file?
41 | for file in ${_Dbg_filenames[@]} ; do
42 | if [[ $file == $full_filename ]] ; then
43 | _Dbg_msg "File $full_filename already loaded."
44 | return 2
45 | fi
46 | done
47 |
48 | _Dbg_readin "$full_filename"
49 | _Dbg_msg "File $full_filename loaded."
50 | else
51 | _Dbg_errmsg "Couldn't resolve or read $filename"
52 | return 3
53 | fi
54 | return 0
55 | }
56 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/validate.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # validate.sh - some input validation routines
3 | #
4 | # Copyright (C) 2010, 2011
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | # _Dbg_is_function returns 0 if $1 is a defined function or nonzero otherwise.
23 | # if $2 is nonzero, system functions, i.e. those whose name starts with
24 | # an underscore (_), are included in the search.
25 | _Dbg_is_function() {
26 | (( 0 == $# )) && return 1
27 | typeset needed_fn=$1
28 | typeset -i include_system=${2:-0}
29 | [[ ${needed_fn:0:1} == '_' ]] && ((!include_system)) && {
30 | return 1
31 | }
32 | declare -F $needed_fn >/dev/null 2>&1
33 | return $?
34 | }
35 |
36 | # _Dbg_is_int returns 0 if $1 is an integer or nonzero otherwise.
37 | _Dbg_is_int() {
38 | (( 1 == $# )) || return 1
39 | typeset rc=1
40 | eval "$_seteglob"
41 | [[ $1 == $int_pat ]] && rc=0
42 | eval "$_resteglob"
43 | return $rc
44 | }
45 |
46 | # _Dbg_is_signed_int returns 0 if $1 is an integer or nonzero otherwise.
47 | _Dbg_is_signed_int() {
48 | (( 1 == $# )) || return 1
49 | typeset rc=1
50 | eval "$_seteglob"
51 | [[ $1 == $_Dbg_signed_int_pat ]] && rc=0
52 | eval "$_resteglob"
53 | return $rc
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/subcmd.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # subcmd.sh - Debugger Help Routines
3 | #
4 | # Copyright (C) 2011 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 | # Command completion for a subcommand
21 | typeset -A _Dbg_next_complete
22 |
23 | _Dbg_complete_subcmd() {
24 | # echo "level 0 called with comp_line: $COMP_LINE , comp_point: $COMP_POINT"
25 | typeset -a words;
26 | typeset subcmds
27 | IFS=' ' words=( $COMP_LINE )
28 | if (( ${#words[@]} == 1 )); then
29 | eval "subcmds=\${!_Dbg_debugger_$1_commands[@]}"
30 | COMPREPLY=( $subcmds )
31 | elif (( ${#words[@]} == 2 )) ; then
32 | eval "subcmds=\${!_Dbg_debugger_$1_commands[@]}"
33 | typeset commands="${!_Dbg_command_help[@]}"
34 | COMPREPLY=( $(compgen -W "$subcmds" "${words[1]}" ) )
35 | if (( ${#COMPREPLY[@]} == 1 )) && [[ ${COMPREPLY[0]} == ${words[1]} ]]
36 | then
37 | IFS=' ' typeset canon_line; canon_line="${words[@]}"
38 | if [[ -n ${_Dbg_next_complete[$canon_line]} && \
39 | $COMP_LINE =~ ' '$ ]] ; then
40 | ${_Dbg_next_complete[$canon_line]}
41 | fi
42 | fi
43 | elif [[ -n ${_Dbg_next_complete[$COMP_LINE]} ]] ; then
44 | ${_Dbg_next_complete[$COMP_LINE]}
45 | else
46 | COMPREPLY=()
47 | fi
48 | }
49 |
50 | _Dbg_complete_onoff() {
51 | COMPREPLY=(on off)
52 | }
53 |
--------------------------------------------------------------------------------
/bashdb_dir/command/frame.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "frame" debugger command
3 | #
4 | # Copyright (C) 2002-2006, 2008, 2010-2011, 2016
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | # Move default values down $1 or one in the stack.
23 |
24 | _Dbg_help_add frame \
25 | '**frame** [*frame-number*].
26 |
27 | Change the current frame to frame *frame-numbrer* if specified, or the
28 | most-recent frame, 0, if no frame number specified.
29 |
30 | A negative number indicates the position from the other or
31 | least-recently-entered end. So **frame -1** moves to the oldest frame.
32 |
33 | See also:
34 | ---------
35 |
36 | **up**, **down**' 1 _Dbg_complete_frame
37 |
38 | # Command completion for a debugger "frame" command.
39 | _Dbg_complete_frame() {
40 | typeset -i start; ((start=-_Dbg_stack_size+1))
41 | typeset -i end; ((end=_Dbg_stack_size-1))
42 | _Dbg_complete_num_range $start $end
43 | }
44 |
45 | _Dbg_do_frame() {
46 | _Dbg_not_running && return 3
47 | typeset count=${1:-1}
48 | _Dbg_is_signed_int $count
49 | if (( 0 == $? )) ; then
50 | _Dbg_frame_adjust $count 0
51 | typeset -i rc=$?
52 | else
53 | _Dbg_errmsg "Expecting an integer; got $count"
54 | typeset -i rc=2
55 | fi
56 | ((0 == rc)) && _Dbg_last_cmd='frame'
57 | return $rc
58 | }
59 |
--------------------------------------------------------------------------------
/src/handlePath.spec.ts:
--------------------------------------------------------------------------------
1 | import { expandPath, getWSLPath, reverseWSLPath, escapeCharactersInBashdbArg } from "./handlePath";
2 |
3 | describe("handlePath - expandPath", () => {
4 |
5 | it("stays undefined if path undefined", () => {
6 |
7 | expect(expandPath(undefined, "C:\\Users\\wsh\proj0"))
8 | .toEqual(undefined);
9 | });
10 |
11 | it("is not replaced if path absolute", () => {
12 |
13 | expect(expandPath("C:\\Users\\wsh\\proj0\\path\\to\\script.sh", "C:\\Users\\wsh\proj0"))
14 | .toEqual("C:/Users/wsh/proj0/path/to/script.sh");
15 | });
16 |
17 | it("is using {workspaceFolder}, on windows", () => {
18 |
19 | expect(expandPath("{workspaceFolder}\\path\\to\\script.sh", "C:\\Users\\wsh\\proj0"))
20 | .toEqual("C:/Users/wsh/proj0/path/to/script.sh");
21 | });
22 | });
23 |
24 | describe("handlePath - getWSLPath", () => {
25 |
26 | it("stays undefined if path undefined", () => {
27 |
28 | expect(getWSLPath(undefined))
29 | .toEqual(undefined);
30 | });
31 |
32 | it("does WSL path conversion if windows path", () => {
33 |
34 | expect(getWSLPath("C:\\Users\\wsh\\proj0\\path\\to\\script.sh"))
35 | .toEqual("/mnt/c/Users/wsh/proj0/path/to/script.sh");
36 | });
37 |
38 | it("does no WSL path conversion if path starts with '/'", () => {
39 |
40 | expect(getWSLPath("/mnt/c/Users/wsh/proj0/path/to/script.sh"))
41 | .toEqual("/mnt/c/Users/wsh/proj0/path/to/script.sh");
42 | });
43 | });
44 |
45 | describe("handlePath - reverseWSLPath", () => {
46 |
47 | it("reverses WSL path", () => {
48 |
49 | expect(reverseWSLPath("/mnt/c/Users/wsh/proj0/path/to/script.sh"))
50 | .toEqual("C:\\Users\\wsh\\proj0\\path\\to\\script.sh");
51 | });
52 | });
53 |
54 | describe("handlePath - escapeCharactersInBashdbArg", () => {
55 |
56 | it("escapes whitespace for setting bashdb arguments with spaces", () => {
57 |
58 | expect(escapeCharactersInBashdbArg("/pa th/to/script.sh"))
59 | .toEqual("/pa\\\\0040th/to/script.sh");
60 | });
61 | });
62 |
--------------------------------------------------------------------------------
/bashdb_dir/command/signal.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # signal.sh - gdb-like "signal" debugger command
3 | #
4 | # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Rocky Bernstein
5 | # rocky@gnu.org
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add signal \
23 | "signal SIGNAL
24 |
25 | Send a signal to the debugged program.
26 |
27 | SIGNAL can be a name like \"TERM\" (for SIGTERM) or a positive number like
28 | 15 (which in \*nix systems is the equivalent number. On \*nix systems the
29 | command \"kill -l\" sometimes will give a list of signal names and numbers.
30 |
31 | The signal is sent to process \$\$ (which is $$ right now).
32 |
33 | Also similar is the \"kill\" command."
34 |
35 | _Dbg_do_signal() {
36 | typeset sig=$1
37 | typeset -i signum
38 | if [[ -z $sig ]] ; then
39 | _Dbg_errmsg "Missing signal name or signal number."
40 | return 1
41 | fi
42 |
43 | eval "$_seteglob"
44 | if [[ $sig == $int_pat ]]; then
45 | eval "$_resteglob"
46 | signame=$(_Dbg_signum2name $sig)
47 | if (( $? != 0 )) ; then
48 | _Dbg_msg "Bad signal number: $sig"
49 | return 1
50 | fi
51 | signum=sig
52 | else
53 | eval "$_resteglob"
54 | typeset signum;
55 | signum=$(_Dbg_name2signum $sig)
56 | if (( $? != 0 )) ; then
57 | _Dbg_msg "Bad signal name: $sig"
58 | return 1
59 | fi
60 | fi
61 | kill -$signum $$
62 | return 0
63 | }
64 |
--------------------------------------------------------------------------------
/bashdb_dir/command/complete.sh:
--------------------------------------------------------------------------------
1 | # complete.sh - gdb-like 'complete' command
2 | #
3 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
4 | #
5 | # This program is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU General Public License as
7 | # published by the Free Software Foundation; either version 2, or
8 | # (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | # General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program; see the file COPYING. If not, write to
17 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
18 | # MA 02111 USA.
19 |
20 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
21 | dirname=${BASH_SOURCE[0]%/*}
22 | [[ $dirname == $0 ]] && top_dir='..' || top_dir=${dirname}/..
23 | for lib_file in help alias ; do source $top_dir/lib/${lib_file}.sh; done
24 | fi
25 |
26 | _Dbg_help_add complete \
27 | '**complete** *prefix-str*...
28 |
29 |
30 | Show command completion strings for *prefix-str*
31 | '
32 |
33 | _Dbg_do_complete() {
34 | typeset -a args; args=($@)
35 | _Dbg_matches=()
36 | if (( ${#args[@]} == 2 )) ; then
37 | _Dbg_subcmd_complete ${args[0]} ${args[1]}
38 | elif (( ${#args[@]} == 1 )) ; then
39 | # FIXME: add in aliases
40 | typeset list; list=("${!_Dbg_debugger_commands[@]}")
41 | sort_list 0 ${#list[@]}-1
42 | cmd="builtin compgen -W \"${list[@]}\" -- ${args[0]}"
43 | typeset -a _Dbg_matches=( $(eval $cmd) )
44 | fi
45 | typeset -i i
46 | for (( i=0; i < ${#_Dbg_matches[@]} ; i++ )) ; do
47 | _Dbg_msg ${_Dbg_matches[$i]}
48 | done
49 | }
50 |
51 | # Demo it.
52 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
53 | source ${top_dir}/lib/msg.sh
54 | for _Dbg_file in ${top_dir}/command/{c*,help}.sh ; do
55 | source $_Dbg_file
56 | done
57 |
58 | _Dbg_args='complete'
59 | _Dbg_do_help complete
60 | _Dbg_do_complete c
61 | fi
62 |
--------------------------------------------------------------------------------
/bashdb_dir/command/commands.sh:
--------------------------------------------------------------------------------
1 | # gdb-like "commands" debugger command.
2 | #
3 | # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Rocky Bernstein
4 | #
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add commands \
22 | 'commands [BKPT-NUM]
23 |
24 | Set commands to be executed when a breakpoint is hit.
25 |
26 | Without BKPT-NUM, the targeted breakpoint is the last one set. The
27 | commands themselves follow starting on the next line.
28 |
29 | Type a line containing "end" to indicate the end of them. Give
30 | "silent" as the first line to make the breakpoint silent; then no
31 | output is printed when it is hit, except what the commands print.'
32 |
33 | _Dbg_do_commands() {
34 | eval "$_seteglob"
35 | typeset num=$1
36 | typeset -i found=0
37 | case $num in
38 | $int_pat )
39 | if [[ -z "${_Dbg_brkpt_file[$num]}" ]] ; then
40 | _Dbg_errmsg "No breakpoint number $num."
41 | return 1
42 | fi
43 | ((found=1))
44 | ;;
45 | * )
46 | _Dbg_errmsg "Invalid entry number skipped: $num"
47 | esac
48 | eval "$_resteglob"
49 | if (( found )) ; then
50 | _Dbg_brkpt_commands_defining=1
51 | _Dbg_brkpt_commands_current=$num
52 | _Dbg_brkpt_commands_end[$num]=${#_Dbg_brkpt_commands[@]}
53 | _Dbg_brkpt_commands_start[$num]=${_Dbg_brkpt_commands_end[$num]}
54 | _Dbg_msg "Type commands for when breakpoint $found hit, one per line."
55 | _Dbg_prompt='>'
56 | return 0
57 | fi
58 | }
59 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/signals.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "info signals" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info signals \
22 | "**info signals**
23 |
24 | Show what debugger does when program gets various signals.
25 |
26 | See also:
27 | ---------
28 |
29 | \"signal\"." 1
30 |
31 | # List signal handlers in effect.
32 | function _Dbg_do_info_signals {
33 | typeset -i i=0
34 | typeset signal_name
35 | typeset handler
36 | typeset stop_flag
37 | typeset print_flag
38 |
39 | _Dbg_msg "Signal Stop Print Stack Value"
40 | _Dbg_printf_nocr "%-12s %-6s %-7s %-9s " EXIT \
41 | ${_Dbg_sig_stop[0]:-nostop} ${_Dbg_sig_print[0]:-noprint} \
42 | ${_Dbg_sig_show_stack[0]:-nostack}
43 |
44 | # This is a horrible hack, but I can't figure out how to get
45 | # trap -p 0 into a variable; handler=`trap -p 0` doesn't work.
46 | if [[ -n $_Dbg_tty ]] ; then
47 | builtin trap -p 0 >>$_Dbg_tty
48 | else
49 | builtin trap -p 0
50 | fi
51 |
52 | while (( 1 )) ; do
53 | signal_name=$(builtin kill -l $i 2>/dev/null) || break
54 | handler=$(builtin trap -p $i)
55 | if [[ -n $handler ]] ; then
56 | _Dbg_printf "%-12s %-6s %-7s %-9s %-6s" $signal_name \
57 | ${_Dbg_sig_stop[$i]:-nostop} ${_Dbg_sig_print[$i]:-noprint} \
58 | ${_Dbg_sig_show_stack[$i]:-nostack} "$handler"
59 | fi
60 | ((i++))
61 | done
62 | }
63 |
--------------------------------------------------------------------------------
/bashdb_dir/command/watch.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "watch" debugger command
3 | #
4 | # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Rocky Bernstein
5 | # rocky@gnu.org
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add watch \
23 | 'watch [ARITH?] EXP
24 |
25 | Set or clear a watch expression.'
26 |
27 | _Dbg_alias_add W watch
28 |
29 | _Dbg_do_watch() {
30 | typeset -a a
31 | a=($_Dbg_args)
32 | typeset first=${a[0]}
33 | if [[ $first == '' ]] ; then
34 | _Dbg_do_watch_internal 0
35 | elif ! _Dbg_defined "$first" ; then
36 | _Dbg_errmsg "Can't set watch: no such variable $first."
37 | else
38 | unset a first
39 | _Dbg_do_watch_internal 0 "\$$_Dbg_args"
40 | fi
41 | return $?
42 | }
43 |
44 | _Dbg_help_add watche \
45 | 'watche [EXP] -- Set or clear a watch expression.'
46 |
47 | _Dbg_alias_add We
48 |
49 | _Dbg_do_watche() {
50 | _Dbg_do_watch_internal 1 "$_Dbg_args"
51 | return $?
52 | }
53 |
54 | # Set or list watch command
55 | _Dbg_do_watch_internal() {
56 | if [ -z "$2" ]; then
57 | _Dbg_clear_watch
58 | else
59 | typeset -i n=_Dbg_watch_max++
60 | _Dbg_watch_arith[$n]="$1"
61 | shift
62 | _Dbg_watch_exp[$n]="$1"
63 | _Dbg_watch_val[$n]=$(_Dbg_get_watch_exp_eval $n)
64 | _Dbg_watch_enable[$n]=1
65 | _Dbg_watch_count[$n]=0
66 | _Dbg_printf '%2d: %s==%s arith: %d' $n \
67 | "(${_Dbg_watch_exp[$n]})" ${_Dbg_watch_val[$n]} \
68 | ${_Dbg_watch_arith[$n]}
69 | fi
70 | return 0
71 | }
72 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Microsoft's documentation for VS Code extensions is suprisingly good (https://code.visualstudio.com/docs/extensions/overview);
4 |
5 | ## On Linux
6 |
7 | Works at least on Kubuntu.
8 |
9 | 1. install VS Code, `npm`, `nodejs`, optionally `bashdb` (some time ago `nodejs-legacy` was required) + build essentials
10 | 1. clone project
11 | 1. disable auto carriage return `git config core.autocrlf false; git reset --hard`
12 | 1. open VS Code, select project's folder, open terminal and type `npm install` (this will download dependencies)
13 | 1. Run by clicking **Ctrl+F5**, new VS window will open
14 | 1. Create some folder with one script file, then try debugging it by **F5** (to debug bashDebug.ts, read [this](https://code.visualstudio.com/docs/extensions/example-debuggers#_development-setup-for-mock-debug) -> basically set `Extension + Server` in debug pane, then set `"debugServer": 4711` configuration in launch.json of bash project)
15 |
16 | ## On Windows 10
17 |
18 | All the pieces seem to be there, but for some reason bash support needs some kick off (https://github.com/Microsoft/BashOnWindows/issues/2#issuecomment-209118529).
19 |
20 | Currently, with some hacks, seems to be working on Windows 10. The scripts are executed in bash@linux realm,so all the paths inside scripts need to refer to linux filesystem (`/mnt/c/..`).
21 |
22 | ## On OS X
23 |
24 | Seeems to be working when path to `pkill` is changed. MacOS seems to have bash v.3 by default, this project aims to support bash versions >= 4.3.
25 |
26 | ## Build CI
27 |
28 | Using Travis CI (https://travis-ci.org/rogalmic/vscode-bash-debug)
29 |
30 | - Every push to master will create a release in github with `vsix` package for testing
31 | - Every tag pushed to master matching `v1.2.3` will trigger a deploy to VSCode extension repo with this version.
32 | - Remember to use [proper commit messages](https://github.com/conventional-changelog/standard-version#commit-message-convention-at-a-glance).
33 | - Keep version in project.json same as version in git tag, best to achieve by running `npm run release -- --release-as minor` to bump version and create commit with [proper tag](https://docs.npmjs.com/cli/version#git-tag-version) at the same time.
34 | - Push the tag `git push origin v1.2.3`, this will start the publish build in [TravisCI](https://travis-ci.org/rogalmic/vscode-bash-debug).
35 |
--------------------------------------------------------------------------------
/bashdb_dir/command/delete.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # delete.sh - gdb-like "delete" debugger command
3 | #
4 | # Copyright (C) 2002-2006, 2008, 2011, 2016-2017 Rocky Bernstein
5 |
6 | #
7 | #
8 | # This program is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 2, or
11 | # (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful,
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | #
18 | # You should have received a copy of the GNU General Public License
19 | # along with this program; see the file COPYING. If not, write to
20 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
21 | # MA 02111 USA.
22 |
23 | _Dbg_help_add delete \
24 | "**delete** {*brkpt-num*}...
25 |
26 | Delete some breakpoints.
27 |
28 | Arguments are breakpoint numbers with spaces in between. Without
29 | arguments, clear all breaks (but first ask for confirmation). " 1
30 | _Dbg_complete_brkpt_range
31 |
32 | # Routine to a delete breakpoint/watchpoint by entry numbers.
33 | _Dbg_do_delete() {
34 | typeset to_go; to_go=$@
35 | typeset -i i
36 | typeset -i tot_found=0
37 |
38 | if (( $# == 0 )) ; then
39 | _Dbg_confirm "Delete all breakpoints? (y/N): " 'N'
40 | if [[ $_Dbg_response == [yY] ]] ; then
41 | typeset indices=${!_Dbg_brkpt_line[@]}
42 | typeset tot_found=${#_Dbg_brkpt_line[@]}
43 | _Dbg_clear_all_brkpt
44 | _Dbg_msg "Deleted breakpoints: $indices"
45 | return $tot_found
46 | else
47 | return
48 | fi
49 | fi
50 |
51 | eval "$_seteglob"
52 | for del in $to_go ; do
53 | case $del in
54 | $_Dbg_watch_pat )
55 | _Dbg_delete_watch_entry ${del:0:${#del}-1}
56 | ;;
57 | $int_pat )
58 | if _Dbg_delete_brkpt_entry $del ; then
59 | _Dbg_msg "Deleted breakpoint ${del}"
60 | ((tot_found++))
61 | fi
62 | ;;
63 | * )
64 | _Dbg_errmsg "Invalid entry number skipped: $del"
65 | esac
66 | done
67 | eval "$_resteglob"
68 | return $tot_found
69 | }
70 |
71 | _Dbg_alias_add 'unset' 'delete'
72 |
--------------------------------------------------------------------------------
/bashdb_dir/init/require.sh:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2011 Rocky Bernstein
2 | #
3 | # This program is free software; you can redistribute it and/or
4 | # modify it under the terms of the GNU General Public License as
5 | # published by the Free Software Foundation; either version 2, or
6 | # (at your option) any later version.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | # General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program; see the file COPYING. If not, write to
15 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
16 | # MA 02111 USA.
17 | if [[ -z $_Dbg_requires ]] ; then
18 | function _Dbg_expand_filename {
19 | typeset -r filename="$1"
20 |
21 | # Break out basename and dirname
22 | typeset basename="${filename##*/}"
23 | typeset -x dirname="${filename%/*}"
24 |
25 | # No slash given in filename? Then use . for dirname
26 | [[ "$dirname" == "$basename" ]] && [[ "$filename" != '/' ]] && dirname='.'
27 |
28 | # Dirname is ''? Then use / for dirname
29 | dirname="${dirname:-/}"
30 |
31 | # Handle tilde expansion in dirname
32 | dirname="$(echo "$dirname")"
33 |
34 | typeset long_path
35 |
36 | if long_path=$( (cd "$dirname" ; pwd) 2>/dev/null ) ; then
37 | if [[ "$long_path" == '/' ]] ; then
38 | echo "/$basename"
39 | else
40 | echo "$long_path/$basename"
41 | fi
42 | return 0
43 | else
44 | echo "$filename"
45 | return 1
46 | fi
47 | }
48 |
49 | typeset -A _Dbg_requires
50 | require() {
51 | typeset file
52 | typeset expanded_file
53 | typeset source_dir
54 | typeset orig_dir
55 | orig_dir="$(pwd)"
56 | source_dir="${BASH_SOURCE[1]%/*}"
57 | if [[ "$source_dir" != "${BASH_SOURCE[1]}" ]] ; then
58 | builtin cd "$source_dir"
59 | fi
60 | for file in "$@" ; do
61 | expanded_file=$(_Dbg_expand_filename "$file")
62 | if [[ -z "${_Dbg_requires[$file]}" \
63 | && -z "${_Dbg_requires[$expanded_file]}" ]] ; then
64 | source "$expanded_file"
65 | _Dbg_requires["$file"]="$expanded_file"
66 | _Dbg_requires["$expanded_file"]="$expanded_file"
67 | fi
68 | done
69 | [[ -n "$orig_dir" ]] && builtin cd "$orig_dir"
70 | }
71 | fi
72 |
--------------------------------------------------------------------------------
/bashdb_dir/command/continue.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # continue.sh - gdb-like "continue" debugger command
3 | #
4 | # Copyright (C) 2002-2006, 2008, 2010, 2016 Rocky Bernstein
5 | #
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add continue \
23 | '**continue** [*loc* | **-** ]
24 |
25 | Continue script execution.
26 |
27 | If *loc* or *-* is not given, continue until the next breakpoint or
28 | the end of program is reached. If **-** is given, then debugging will
29 | be turned off after continuing causing your program to run at full
30 | speed.
31 |
32 | If **loc* is given, a temporary breakpoint is set at the location.'
33 |
34 | function _Dbg_do_continue {
35 |
36 | _Dbg_not_running && return 3
37 |
38 | if (( $# == 0 )) ; then
39 | _Dbg_continue_rc=0
40 | return 0
41 | fi
42 | typeset filename
43 | typeset -i line_number
44 | typeset full_filename
45 |
46 | if [[ $1 == '-' ]] ; then
47 | _Dbg_restore_debug_trap=0
48 | _Dbg_continue_rc=0
49 | return 0
50 | fi
51 |
52 | _Dbg_linespec_setup "$1"
53 |
54 | _Dbg_last_cmd='continue'
55 | if [[ -n "$full_filename" ]] ; then
56 | if (( line_number == 0 )) ; then
57 | _Dbg_errmsg 'There is no line 0 to continue at.'
58 | return 1
59 | else
60 | _Dbg_check_line $line_number "$full_filename"
61 | (( $? == 0 )) && \
62 | _Dbg_set_brkpt "$full_filename" "$line_number" 1 1
63 | _Dbg_continue_rc=0
64 | return 0
65 | fi
66 | else
67 | _Dbg_file_not_read_in "$filename"
68 | return 2
69 | fi
70 | }
71 |
72 | _Dbg_alias_add 'c' 'continue'
73 | _Dbg_alias_add 'cont' 'continue'
74 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/alias.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Copyright (C) 2008, 2010, 2011 Rocky Bernstein
3 | #
4 | # This program is free software; you can redistribute it and/or
5 | # modify it under the terms of the GNU General Public License as
6 | # published by the Free Software Foundation; either version 2, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License along
15 | # with this program; see the file COPYING. If not, write to the Free Software
16 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
17 |
18 | # Command aliases are stored here.
19 | typeset -A _Dbg_aliases
20 |
21 | # Add an new alias in the alias table
22 | _Dbg_alias_add() {
23 | (( $# != 2 )) && return 1
24 | _Dbg_aliases[$1]="$2"
25 | return 0
26 | }
27 |
28 | # Remove alias $1 from our list of command aliases.
29 | _Dbg_alias_remove() {
30 | (( $# != 1 )) && return 1
31 | unset "_Dbg_aliases[$1]"
32 | return 0
33 | }
34 |
35 | # Expand alias $1. The result is set in variable expanded_alias which
36 | # could be declared local in the caller.
37 | _Dbg_alias_expand() {
38 | (( $# != 1 )) && return 1
39 | expanded_alias="$1"
40 | [[ -z "$1" ]] && return 0
41 | [[ -n ${_Dbg_aliases[$1]} ]] && expanded_alias=${_Dbg_aliases[$1]}
42 | return 0
43 | }
44 |
45 | # Echo the index in _Dbg_command_names if found. Return
46 | # 0 if found and 1 if not there.
47 | _Dbg_alias_find_index() {
48 | typeset find_name=$1
49 | typeset -i i
50 | for ((i=0; i <= _Dbg_alias_max_index; i++)) ; do
51 | [[ ${_Dbg_alias_names[i]} == "$find_name" ]] && echo $i && return 0
52 | done
53 | return 1
54 | }
55 |
56 | # Return in help_aliases an array of strings that are aliases
57 | # of $1
58 | _Dbg_alias_find_aliased() {
59 | (($# != 1)) && return 255
60 | typeset find_name=$1
61 | aliases_found=''
62 | typeset -i i
63 | for alias in ${!_Dbg_aliases[@]} ; do
64 | if [[ ${_Dbg_aliases[$alias]} == "$find_name" ]] ; then
65 | [[ -n $aliases_found ]] && aliases_found+=', '
66 | aliases_found+="$alias"
67 | fi
68 | done
69 | return 0
70 | }
71 |
--------------------------------------------------------------------------------
/bashdb_dir/command/condition.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # condition.sh - gdb-like "condition" debugger command
3 | #
4 | # Copyright (C) 2002-2006, 2008, 2009, 2011, 2016
5 | # Rocky Bernstein rocky@gnu.org
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add condition \
23 | "**condition** *bp_number* *zsh-cond*
24 |
25 | +Break only if *bassh-cond* is true in breakpoint number *bp_number*.
26 |
27 | *bp_number* is an integer and *cond* is an zsh expression to be evaluated whenever
28 | breakpoint *bp_number* is reached.
29 |
30 | Examples:
31 | ---------
32 |
33 | condition 5 x > 10 # Breakpoint 5 now has condition x > 10
34 | condition 5 # Remove above condition
35 |
36 | See also:
37 | ---------
38 |
39 | *break*, *tbreak*.
40 | " 1 _Dbg_complete_brkpt_range
41 |
42 | # Set a condition for a given breakpoint $1 is a breakpoint number
43 | # $2 is a condition. If not given, set "unconditional" or 1.
44 | # returns 0 if success or 1 if fail.
45 | function _Dbg_do_condition {
46 |
47 | if (( $# < 1 )) ; then
48 | _Dbg_errmsg 'condition: Argument required (breakpoint number).'
49 | return 1
50 | fi
51 |
52 | typeset -r n=$1
53 | shift
54 |
55 | eval "$_seteglob"
56 | if [[ $n != $int_pat ]]; then
57 | eval "$_resteglob"
58 | _Dbg_errmsg "condition: Bad breakpoint number: $n"
59 | return 2
60 | fi
61 | eval "$_resteglob"
62 |
63 | if [[ -z "${_Dbg_brkpt_file[$n]}" ]] ; then
64 | _Dbg_msg "condition: Breakpoint entry $n is not set. Condition not changed."
65 | return 3
66 | fi
67 |
68 | if [[ -z $condition ]] ; then
69 | condition=1
70 | _Dbg_msg "Breakpoint $n now unconditional."
71 | fi
72 | _Dbg_brkpt_cond[$n]="$condition"
73 | return 0
74 | }
75 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info_sub/warranty.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info warranty" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub info warranty \
22 | '**info warranty**
23 |
24 | Lack of warranty of this debugger.' 1
25 |
26 | _Dbg_do_info_warranty() {
27 | _Dbg_msg "
28 | NO WARRANTY
29 |
30 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
31 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
32 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
33 | PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
34 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
35 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
36 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
37 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
38 | REPAIR OR CORRECTION.
39 |
40 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
41 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
42 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
43 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
44 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
45 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
46 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
47 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
48 | POSSIBILITY OF SUCH DAMAGES.
49 | "
50 | return 0
51 | }
52 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/tty.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set tty" debugger command
3 | #
4 | # Copyright (C) 2012 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | # -*- shell-script -*-
22 | # tty command.
23 | #
24 | # Copyright (C) 2002, 2003, 2004, 2006, 2008, 2012 Rocky Bernstein
25 | # rocky@gnu.org
26 | #
27 | # bashdb is free software; you can redistribute it and/or modify it under
28 | # the terms of the GNU General Public License as published by the Free
29 | # Software Foundation; either version 2, or (at your option) any later
30 | # version.
31 | #
32 | # bashdb is distributed in the hope that it will be useful, but WITHOUT ANY
33 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or
34 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
35 | # for more details.
36 | #
37 | # You should have received a copy of the GNU General Public License along
38 | # with bashdb; see the file COPYING. If not, write to the Free Software
39 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
40 |
41 | _Dbg_help_add_sub set tty \
42 | 'set tty {pseudo-device|&1}
43 |
44 | Set the output device for debugger output. Use "\&1" if you want debugger
45 | output to go to STDOUT.
46 | ' 1
47 |
48 | # Set output tty
49 | _Dbg_do_set_tty() {
50 | _Dbg_do_tty $@
51 | return $?
52 | }
53 |
54 | _Dbg_do_set_help_tty() {
55 | typeset label
56 |
57 | [[ -n $1 ]] && label=$(builtin printf '%-16s-- ' 'set tty') || label=''
58 | _Dbg_msg_nocr \
59 | "${label}Debugger output goes to "
60 | if [[ -n $_Dbg_tty ]] ; then
61 | _Dbg_msg $(tty)
62 | else
63 | _Dbg_msg $_Dbg_tty
64 | fi
65 | return 0
66 | }
67 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/linetrace.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set linetrace" debugger command
3 | #
4 | # Copyright (C) 2010, 2016 Rocky Bernstein rocky@gnu.org
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set linetrace \
22 | 'set linetrace [on|off]
23 |
24 | Set shell-like \"set -x\" line tracing' 1
25 |
26 | typeset -i _Dbg_linetrace_expand=0 # expand variables in linetrace output
27 | typeset -i _Dbg_linetrace_delay=0 # sleep after linetrace
28 |
29 | _Dbg_help_add_sub set linetrace \
30 | '**set linetrace** [**on**|**off**]
31 |
32 | Set xtrace-style line tracing
33 |
34 | See also:
35 | ---------
36 |
37 | **show linetrace**
38 | '
39 |
40 | _Dbg_do_set_linetrace() {
41 | typeset onoff=${1:-'off'}
42 | case $onoff in
43 | on | 1 )
44 | _Dbg_write_journal_eval "_Dbg_set_linetrace=1"
45 | ;;
46 | off | 0 )
47 | _Dbg_write_journal_eval "_Dbg_set_linetrace=0"
48 | ;;
49 | d | de | del | dela | delay )
50 | eval "$_seteglob"
51 | if [[ $2 != $int_pat ]] ; then
52 | _Dbg_msg "Bad int parameter: $2"
53 | eval "$_resteglob"
54 | return 1
55 | fi
56 | eval "$_resteglob"
57 | _Dbg_write_journal_eval "_Dbg_linetrace_delay=$2"
58 | ;;
59 | e | ex | exp | expa | expan | expand )
60 | typeset onoff=${2:-'on'}
61 | case $onoff in
62 | on | 1 )
63 | _Dbg_write_journal_eval "_Dbg_linetrace_expand=1"
64 | ;;
65 | off | 0 )
66 | _Dbg_write_journal_eval "_Dbg_linetrace_expand=0"
67 | ;;
68 | * )
69 | _Dbg_errmsg "\"expand\", \"on\" or \"off\" expected."
70 | ;;
71 | esac
72 | ;;
73 |
74 | * )
75 | _Dbg_errmsg "\"expand\", \"on\" or \"off\" expected."
76 | return 1
77 | esac
78 | return 0
79 | }
80 |
--------------------------------------------------------------------------------
/bashdb_dir/command/down.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "down" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
22 | dirname=${BASH_SOURCE[0]%/*}
23 | [[ $dirname == $0 ]] && top_dir='..' || top_dir=${dirname}/..
24 | for lib_file in help alias ; do source $top_dir/lib/${lib_file}.sh; done
25 | fi
26 |
27 | # Move default values down $1 or one in the stack.
28 | _Dbg_help_add down \
29 | '**down** [*count*]
30 |
31 | Move the current frame down in the stack trace (to an newer frame). 0 is
32 | the most recent frame.
33 |
34 | If *count* is omitted, use 1.
35 |
36 | See also:
37 | ---------
38 |
39 | **down** and **frame**.' 1 _Dbg_complete_down
40 |
41 | # Command completion for a frame command
42 | _Dbg_complete_down() {
43 | typeset -i start; ((start=-_Dbg_stack_size+2+_Dbg_stack_pos))
44 | typeset -i end; ((end=_Dbg_stack_size-3-_Dbg_stack_pos))
45 | _Dbg_complete_num_range $start $end
46 | }
47 |
48 | function _Dbg_do_down {
49 | _Dbg_not_running && return 3
50 | typeset count=${1:-1}
51 | _Dbg_is_signed_int $count
52 | if (( 0 == $? )) ; then
53 | _Dbg_frame_adjust $count -1
54 | typeset -i rc=$?
55 | else
56 | _Dbg_errmsg "Expecting an integer; got $count"
57 | typeset -i rc=2
58 | fi
59 | ((0 == rc)) && _Dbg_last_cmd='down'
60 | return $rc
61 | }
62 |
63 | # Demo it
64 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
65 | for _Dbg_file in help msg sort columnize ; do
66 | source ${top_dir}/lib/${_Dbg_file}.sh
67 | done
68 | source ${top_dir}/command/help.sh
69 | _Dbg_args='down'
70 | _Dbg_do_help down
71 | fi
72 |
--------------------------------------------------------------------------------
/bashdb_dir/command/up.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "up" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
23 | dirname=${BASH_SOURCE[0]%/*}
24 | [[ $dirname == $0 ]] && top_dir='..' || top_dir=${dirname}/..
25 | for lib_file in help alias ; do source $top_dir/lib/${lib_file}.sh; done
26 | fi
27 |
28 | # Move default values up $1 or one in the stack.
29 | _Dbg_help_add up \
30 | '**up** [*count*]
31 |
32 | Move the current frame up in the stack trace (to an older frame). 0 is
33 | the most recent frame.
34 |
35 | If **count** is omitted, use 1. **count* can be any arithmetic expression.
36 |
37 | See also:
38 | ---------
39 |
40 | **down** and **frame**.
41 | ' 1 _Dbg_complete_up
42 |
43 | # Command completion for a frame command
44 | _Dbg_complete_up() {
45 | typeset -i start; ((start=-_Dbg_stack_size+3+_Dbg_stack_pos))
46 | typeset -i end; ((end=_Dbg_stack_size-2-_Dbg_stack_pos))
47 | _Dbg_complete_num_range $start $end
48 | }
49 |
50 | function _Dbg_do_up {
51 | _Dbg_not_running && return 3
52 | typeset count=${1:-1}
53 | _Dbg_is_signed_int $count
54 | if (( 0 == $? )) ; then
55 | _Dbg_frame_adjust $count +1
56 | typeset -i rc=$?
57 | else
58 | _Dbg_errmsg "Expecting an integer; got $count"
59 | typeset -i rc=2
60 | fi
61 | ((0 == rc)) && _Dbg_last_cmd='up'
62 | return $rc
63 | }
64 |
65 | # Demo it
66 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
67 | for _Dbg_file in help msg sort columnize ; do
68 | source ${top_dir}/lib/${_Dbg_file}.sh
69 | done
70 | source ${top_dir}/command/help.sh
71 | _Dbg_args='up'
72 | _Dbg_do_help up
73 | fi
74 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/setshow.sh:
--------------------------------------------------------------------------------
1 | # setshow.sh - Helper routines for help/set/show
2 | #
3 | # Copyright (C) 2010, 2011 Rocky Bernstein
4 | #
5 | # This program is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU General Public License as
7 | # published by the Free Software Foundation; either version 2, or
8 | # (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | # General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program; see the file COPYING. If not, write to
17 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
18 | # MA 02111 USA.
19 |
20 | # Sets variable _Dbg_$2 to value $1 and then runs _Dbg_do_show $2.
21 | _Dbg_set_onoff() {
22 | typeset onoff=${1:-'off'}
23 | typeset cmdname=$2
24 | case $onoff in
25 | on | 1 )
26 | _Dbg_write_journal_eval "_Dbg_set_${cmdname}=1"
27 | ;;
28 | off | 0 )
29 | _Dbg_write_journal_eval "_Dbg_set_${cmdname}=0"
30 | ;;
31 | * )
32 | _Dbg_msg "\"on\" or \"off\" expected."
33 | return 1
34 | esac
35 | _Dbg_do_show $cmdname
36 | return 0
37 | }
38 |
39 | _Dbg_show_onoff() {
40 | typeset cmd="$1"
41 | typeset msg="$2"
42 | typeset label="$3"
43 | [[ -n $label ]] && label=$(printf "%-12s: " $subcmd)
44 | typeset onoff='off.'
45 | typeset value
46 | eval "value=\$_Dbg_set_${cmd}"
47 | (( value )) && onoff='on.'
48 | _Dbg_msg \
49 | "${label}$msg is" $onoff
50 | return 0
51 |
52 | }
53 |
54 | _Dbg_help_set_onoff() {
55 | typeset subcmd="$1"
56 | typeset label="$2"
57 | typeset msg="$3"
58 | typeset -i variable_value
59 | eval_cmd="variable_value=\${_Dbg_set_$subcmd}"
60 | eval $eval_cmd
61 | [[ -n $label ]] && label=$(builtin printf "set %-12s-- " $subcmd)
62 | typeset onoff="off."
63 | (( variable_value != 0 )) && onoff='on.'
64 | _Dbg_msg \
65 | "${label}${msg} is" $onoff
66 | return 0
67 | }
68 |
69 | # Demo it
70 | if [[ "${BASH_SOURCE[0]}" == "$0" ]] ; then
71 | _Dbg_msg() {
72 | echo "$*"
73 | }
74 |
75 | typeset -i _Dbg_foo
76 | for i in 0 1 ; do
77 | _Dbg_foo=$i
78 | _Dbg_help_set_onoff "foo" "foo" "Set short xx"
79 | typeset -p _Dbg_set_foo
80 | done
81 | fi
82 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # set.sh - debugger settings
3 | #
4 | # Copyright (C) 2002,2003,2006,2007,2008,2010,2011 Rocky Bernstein
5 | #
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | # Sets whether or not to display command to be executed in debugger prompt.
23 | # If yes, always show. If auto, show only if the same line is to be run
24 | # but the command is different.
25 |
26 | typeset -A _Dbg_debugger_set_commands
27 | typeset -A _Dbg_command_help_set
28 |
29 | typeset -i _Dbg_set_autoeval=0 # Evaluate unrecognized commands?
30 |
31 | # Help routine is elsewhere which is why we have '' below.
32 | _Dbg_help_add set '' 1 _Dbg_complete_set
33 |
34 | # Load in "set" subcommands
35 | for _Dbg_file in "${_Dbg_libdir}/command/set_sub/"*.sh ; do
36 | source "$_Dbg_file"
37 | done
38 |
39 | # Command completion for a condition command
40 | _Dbg_complete_set() {
41 | _Dbg_complete_subcmd set
42 | }
43 |
44 | _Dbg_do_set() {
45 |
46 | if (($# == 0)) ; then
47 | _Dbg_errmsg "Argument required (expression to compute)."
48 | return 1;
49 | fi
50 | typeset subcmd=$1
51 | typeset rc
52 | shift
53 |
54 | if [[ -n "${_Dbg_debugger_set_commands[$subcmd]}" ]] ; then
55 | "${_Dbg_debugger_set_commands[$subcmd]}" $label "$@"
56 | return $?
57 | fi
58 |
59 | case $subcmd in
60 | force )
61 | _Dbg_set_onoff "$1" 'different'
62 | return $?
63 | ;;
64 | lo | log | logg | loggi | loggin | logging )
65 | _Dbg_cmd_set_logging $@
66 | ;;
67 | t|tr|tra|trac|trace|trace-|trace-c|trace-co|trace-com|trace-comm|trace-comma|trace-comman|trace-command|trace-commands )
68 | _Dbg_do_set_trace_commands $@
69 | ;;
70 | *)
71 | _Dbg_undefined_cmd "set" "$subcmd"
72 | return 1
73 | esac
74 | return $?
75 | }
76 |
--------------------------------------------------------------------------------
/bashdb_dir/bashdb-main.inc:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Copyright (C) 2008, 2010 Rocky Bernstein
3 | #
4 | # This program is free software; you can redistribute it and/or
5 | # modify it under the terms of the GNU General Public License as
6 | # published by the Free Software Foundation; either version 2, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program; see the file COPYING. If not, write to
16 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
17 | # MA 02111 USA.
18 |
19 | # Name we refer to ourselves by
20 | typeset _Dbg_debugger_name='bashdb'
21 |
22 | # The shell we are configured to run under.
23 | typeset _Dbg_shell='/bin/bash'
24 |
25 | # The release name we are configured to run under.
26 | typeset _Dbg_release='4.4-0.94'
27 |
28 | # Wrapper for debugger called from within bash via bash --debugger
29 | typeset _Dbg_bashdb_main='/usr/share/bashdb/bashdb-main.inc'
30 |
31 | # The short shell name. Helps keep code common in bash, zsh, and ksh debuggers.
32 | typeset _Dbg_shell_name=${_Dbg_shell##*/} # Equivalent to basename(_Dbg_shell)
33 |
34 | # Original $0. Note we can't set this in an include.
35 | typeset _Dbg_orig_0=$0
36 |
37 | # Equivalent to basename $0; the short program name
38 | typeset _Dbg_pname=${0##*/}
39 |
40 | ## Stuff set by autoconf/configure ###
41 | typeset prefix=/usr # ${prefix}/share/bashdb often uses $prefix
42 | typeset _Dbg_libdir=${prefix}/share/bashdb
43 | ###
44 |
45 | # We agonize a bit over _Dbg_libdir: the root directory for where
46 | # debugger code is stored.
47 | [[ -d $_Dbg_libdir ]] || _Dbg_libdir=${_Dbg_bashdb_main%/*} # dirname(_Dbg_bashdb_main)
48 | [[ -d $_Dbg_libdir ]] || _Dbg_libdir='.'
49 |
50 | typeset _Dbg_main="$_Dbg_libdir/dbg-main.sh"
51 | if [[ ! -r $_Dbg_main ]] ; then
52 | echo "${_Dbg_pname}: Can't read debugger library file '${_Dbg_main}'."
53 | echo "${_Dbg_pname}: Perhaps bashdb is installed wrong (if its installed)." >&2
54 | echo "${_Dbg_pname}: Try running bashdb using -L (with a different directory)." >&2
55 | echo "${_Dbg_pname}: Run bashdb --help for a list and explanation of options." >&2
56 | exit 1
57 | fi
58 |
59 | # Pull in the rest of the debugger code.
60 | . $_Dbg_main
61 |
62 | trap '_Dbg_debug_trap_handler 0 "$BASH_COMMAND" "$@"' DEBUG
63 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/shell.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # shell.sh - helper routines for 'shell' debugger command
3 | #
4 | # Copyright (C) 2011, 2017 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_shell_temp_profile=$(_Dbg_tempname profile)
22 |
23 | _Dbg_shell_append_typesets() {
24 | typeset -a words
25 | typeset -p | while read -a words ; do
26 | [[ declare != ${words[0]} ]] && continue
27 | var_name=${words[2]%%=*}
28 | ((0 == _Dbg_set_debug)) && [[ $var_name =~ ^_Dbg_ ]] && continue
29 | flags=${words[1]}
30 | if [[ $flags =~ ^-.*x ]]; then
31 | # Skip exported variables
32 | continue
33 | elif [[ $flags =~ -.*r ]]; then
34 | # handle read-only variables
35 | echo "typeset -p ${var_name} &>/dev/null || $(typeset -p ${var_name})"
36 | elif [[ ${flags:0:1} == '-' ]] ; then
37 | echo $(typeset -p ${var_name} 2>/dev/null)
38 | fi
39 | done >>$_Dbg_shell_temp_profile
40 | }
41 |
42 | _Dbg_shell_append_fn_typesets() {
43 | typeset -a words
44 | typeset -pf | while read -a words ; do
45 | [[ declare != ${words[0]} ]] && continue
46 | fn_name=${words[2]%%=*}
47 | ((0 == _Dbg_set_debug)) && [[ $fn_name =~ ^_Dbg_ ]] && continue
48 | flags=${words[1]}
49 | echo $(typeset -pf ${fn_name} 2>/dev/null)
50 | done >>$_Dbg_shell_temp_profile
51 | }
52 |
53 | _Dbg_shell_new_shell_profile() {
54 | typeset -i _Dbg_o_vars; _Dbg_o_vars=${1:-1}
55 | typeset -i _Dbg_o_fns; _Dbg_o_fns=${2:-1}
56 |
57 | echo '# debugger shell profile' > $_Dbg_shell_temp_profile
58 |
59 | ((_Dbg_o_vars)) && _Dbg_shell_append_typesets
60 |
61 | # Add where file to allow us to restore info and
62 | # Routine use can call to mark which variables should persist
63 | typeset -p _Dbg_restore_info >> $_Dbg_shell_temp_profile
64 | echo "source ${_Dbg_libdir}/data/shell.sh" >> $_Dbg_shell_temp_profile
65 |
66 | ((_Dbg_o_fns)) && _Dbg_shell_append_fn_typesets
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/bashdb_dir/command/info.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # info.sh - gdb-like "info" debugger commands
3 | #
4 | # Copyright (C) 2002-2011 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | typeset -A _Dbg_debugger_info_commands
22 | typeset -A _Dbg_command_help_info
23 |
24 | _Dbg_help_add info '' 1 _Dbg_complete_info
25 |
26 | # Load in "info" subcommands
27 | for _Dbg_file in "${_Dbg_libdir}/command/info_sub/"*.sh ; do
28 | source $_Dbg_file
29 | done
30 |
31 | # Command completion
32 | _Dbg_complete_info() {
33 | _Dbg_complete_subcmd info
34 | }
35 |
36 | _Dbg_do_info() {
37 |
38 | if (($# > 0)) ; then
39 | typeset subcmd=$1
40 | shift
41 |
42 | if [[ -n ${_Dbg_debugger_info_commands[$subcmd]} ]] ; then
43 | ${_Dbg_debugger_info_commands[$subcmd]} "$@"
44 | return $?
45 | else
46 | # Look for a unique abbreviation
47 | typeset -i count=0
48 | typeset list; list="${!_Dbg_debugger_info_commands[@]}"
49 | for try in $list ; do
50 | if [[ $try =~ ^$subcmd ]] ; then
51 | subcmd=$try
52 | ((count++))
53 | fi
54 | done
55 | ((found=(count==1)))
56 | fi
57 | if ((found)); then
58 | ${_Dbg_debugger_info_commands[$subcmd]} "$@"
59 | return $?
60 | fi
61 |
62 | _Dbg_errmsg "Unknown info subcommand: $subcmd"
63 | msg=_Dbg_errmsg
64 | else
65 | msg=_Dbg_msg
66 | fi
67 | typeset -a list
68 | list=(${!_Dbg_debugger_info_commands[@]})
69 | sort_list 0 ${#list[@]}-1
70 | typeset columnized=''
71 | typeset -i width; ((width=_Dbg_set_linewidth-5))
72 | typeset -a columnized; columnize $width
73 | typeset -i i
74 | $msg "Info subcommands are:"
75 | for ((i=0; i<${#columnized[@]}; i++)) ; do
76 | $msg " ${columnized[i]}"
77 | done
78 | return 1
79 | }
80 |
81 | _Dbg_alias_add i info
82 |
--------------------------------------------------------------------------------
/bashdb_dir/command/history.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # hist.sh - history routines
3 | #
4 | # Copyright (C) 2002, 2003, 2006, 2007, 2008, 2009, 2011 Rocky Bernstein
5 | #
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with bashdb; see the file COPYING. If not, write to the Free Software
19 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
20 |
21 | _Dbg_help_add history \
22 | "history [N]
23 |
24 | Rerun a debugger command from the debugger history.
25 |
26 | See also H to list the history. If N is negative you are you going
27 | back that many items from the end rather specifying an absolute history number."
28 |
29 | _Dbg_do_history() {
30 | typeset -i history_num
31 | _Dbg_history_parse $@
32 | _Dbg_history_remove_item
33 | if (( history_num >= 0 )) ; then
34 | if (( history_num < ${#_Dbg_history[@]} )) ; then
35 | set ${_Dbg_history[$history_num]}
36 | _Dbg_cmd=$1
37 | shift
38 | _Dbg_args="$@"
39 | _Dbg_redo=1;
40 | else
41 | _Dbg_errmsg \
42 | "Number $1 ($history_num) should be less than ${#_Dbg_history[@]}"
43 | return 1
44 | fi
45 | fi
46 | return 0
47 | }
48 |
49 | # Print debugger history $1 is where to start or highest number if not given.
50 | # If $1 is negative, it is how many history items.
51 | # $2 is where to stop or 0 if not given.
52 | _Dbg_do_history_list() {
53 |
54 | eval "$_seteglob"
55 | if [[ $1 != $int_pat ]] && [[ $1 != -$int_pat ]] && [[ -n $1 ]] ; then
56 | _Dbg_msg "Invalid history number: $1"
57 | eval "$_resteglob"
58 | return 1
59 | fi
60 | eval "$_resteglob"
61 |
62 | _Dbg_hi=${#_Dbg_history[@]}
63 | local -i n=${1:-$_Dbg_hi-1}
64 | local -i stop=${2:0}
65 | local -i i
66 |
67 | # Were we given a count rather than a starting history number?
68 | if (( n<0 )) ; then
69 | ((stop=_Dbg_hi+n))
70 | ((n=_Dbg_hi-1))
71 | elif (( n > _Dbg_hi-1 )) ; then
72 | ((n=_Dbg_hi-1))
73 | fi
74 |
75 | for (( i=n ; i >= stop && i >= 0; i-- )) ; do
76 | _Dbg_msg "${i}: ${_Dbg_history[$i]}"
77 | done
78 | return 0
79 | }
80 |
81 | _Dbg_alias_add '!' 'history'
82 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/history.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set history" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | _Dbg_help_add_sub set history \
22 | '**set history save** [**on**|**off**]
23 |
24 | **set history size** *num*
25 |
26 | **set history filename** *path*
27 |
28 | In the first form, set whether to save history.
29 |
30 | In the second form, how many history lines to save is indicated.
31 |
32 | In the third form, the place to store the history file is given.
33 | '
34 |
35 | _Dbg_next_complete[set history]='_Dbg_complete_history'
36 |
37 | _Dbg_complete_history() {
38 | COMPREPLY=(save size)
39 | }
40 |
41 | _Dbg_do_set_history() {
42 | case "$1" in
43 | sa | sav | save )
44 | typeset onoff=${2:-'on'}
45 | case $onoff in
46 | on | 1 )
47 | _Dbg_write_journal_eval "_Dbg_set_history=1"
48 | ;;
49 | off | 0 )
50 | _Dbg_write_journal_eval "_Dbg_set_history=0"
51 | ;;
52 | * )
53 | _Dbg_errmsg "\"on\" or \"off\" expected."
54 | return 1
55 | ;;
56 | esac
57 | ;;
58 | si | siz | size )
59 | eval "$_seteglob"
60 | if [[ -z $2 ]] ; then
61 | _Dbg_errmsg "Argument required (integer to set it to.)."
62 | elif [[ $2 != $int_pat ]] ; then
63 | _Dbg_errmsg "Integer argument expected; got: $2"
64 | eval "$_resteglob"
65 | return 1
66 | fi
67 | eval "$_resteglob"
68 | _Dbg_write_journal_eval "_Dbg_history_length=$2"
69 | ;;
70 | *)
71 | _Dbg_errmsg "\"save\", or \"size\" expected."
72 | return 1
73 | ;;
74 | esac
75 | return 0
76 | }
77 |
--------------------------------------------------------------------------------
/bashdb_dir/command/kill.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "kill" debugger command
3 | #
4 | # Copyright (C) 2002-2006, 2008, 2009, 2010-2011, 2016
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add kill \
23 | "**kill** [*signal-number*]
24 |
25 | Send this process a POSIX signal ('9' for 'SIGKILL' or 'kill -SIGKILL')
26 |
27 | 9 is a non-maskable interrupt that terminates the program. If program is threaded it may
28 | be expedient to use this command to terminate the program.
29 |
30 | However other signals, such as those that allow for the debugged to handle them can be
31 | sent.
32 |
33 | Giving a negative number is the same as using its positive value.
34 |
35 | Examples:
36 | ---------
37 |
38 | kill # non-interuptable, nonmaskable kill
39 | kill 9 # same as above
40 | kill -9 # same as above
41 | kill 15 # nicer, maskable TERM signal
42 | kill! 15 # same as above, but no confirmation
43 |
44 | See also:
45 | ---------
46 |
47 | **quit** for less a forceful termination command.
48 | **run** is a way to restart the debugged program.
49 | Also similar is the **signal** command."
50 |
51 | _Dbg_do_kill() {
52 | if (($# > 1)); then
53 | _Dbg_errmsg "Got $# parameters, but need 0 or 1."
54 | return 1
55 | fi
56 | typeset _Dbg_prompt_output=${_Dbg_tty:-/dev/null}
57 | typeset signal='-9'
58 | (($# == 1)) && signal="$1"
59 |
60 | if [[ ${signal:0:1} != '-' ]] ; then
61 | _Dbg_errmsg "Kill signal ($signal) should start with a '-'"
62 | return 2
63 | fi
64 |
65 | _Dbg_confirm "Send kill signal ${signal} which may terminate the debugger? (y/N): " 'N'
66 |
67 | if [[ $_Dbg_response == [yY] ]] ; then
68 | case $signal in
69 | -9 | -SEGV )
70 | _Dbg_cleanup2
71 | ;;
72 | esac
73 | kill $signal $$
74 | else
75 | _Dbg_msg "Kill not done - not confirmed."
76 | return 3
77 | fi
78 | return 0
79 | }
80 |
--------------------------------------------------------------------------------
/bashdb_dir/command/debug.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Set up to Debug into another script...
3 | #
4 | # Copyright (C) 2002, 2003, 2004, 2006, 2008, 2009, 2010, 2011
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add debug \
23 | "debug [SCRIPT]
24 |
25 | Set up SCRIPT for debugging.
26 |
27 | If SCRIPT is not given, take the script name from the command that is
28 | about to be executed."
29 |
30 | # TODO: would work better if instead of using $source_line below
31 | # which might have several statements, we could just pick up the next
32 | # single statement.
33 | _Dbg_do_debug() {
34 |
35 | _Dbg_shell_new_shell_profile
36 |
37 | typeset script_cmd=${@:-$_Dbg_bash_command}
38 |
39 | # We need to expand variables that might be in $script_cmd.
40 | # set_Dbg_nested_debug_cmd is set up to to be eval'd below.
41 | typeset set_Dbg_debug_cmd="typeset _Dbg_debug_cmd=\"$script_cmd\"";
42 |
43 | [[ -z $BASH ]] && BASH='bash'
44 |
45 | eval "$_seteglob"
46 | # Add appropriate bash debugging options
47 | if (( ! _Dbg_script )) ; then
48 | # Running "bash --debugger", so prepend "bash --debugger"
49 | set_Dbg_debug_cmd="typeset _Dbg_debug_cmd=\"$BASH --init-file ${_Dbg_shell_temp_profile} --debugger $script_cmd\"";
50 | elif [[ $_Dbg_orig_0/// == *bashdb/// ]] ; then
51 | # Running "bashdb", so prepend "bash bashdb .."
52 | set_Dbg_debug_cmd="typeset _Dbg_debug_cmd=\"$BASH $_Dbg_orig_0 -q -L $_Dbg_libdir $script_cmd\"";
53 | fi
54 | eval "$_resteglob"
55 | eval $set_Dbg_debug_cmd
56 |
57 | if (( _Dbg_set_basename )) ; then
58 | _Dbg_msg "Debugging new script with $script_cmd"
59 | else
60 | _Dbg_msg "Debugging new script with $_Dbg_debug_cmd"
61 | fi
62 | typeset -r old_quit_on_quit=$_Dbg_QUIT_ON_QUIT
63 | export _Dbg_QUIT_ON_QUIT=1
64 | export BASHDB_BASENAME_ONLY="$_Dbg_set_basename"
65 | ((_Dbg_DEBUGGER_LEVEL++))
66 | $_Dbg_debug_cmd
67 | ((_Dbg_DEBUGGER_LEVEL--))
68 | _Dbg_restore_from_nested_shell
69 | export _Dbg_QUIT_ON_QUIT=$old_quit_on_quit
70 | }
71 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/journal.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Things related to variable journaling.
3 | #
4 | # Copyright (C) 2002, 2003, 2004, 2006, 2008, 2009,
5 | # 2010, 2011 Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | # We use a journal file to save variable state so that we can pass
23 | # values set in a subshell or nested shell back. This typically
24 | # includes debugger information, e.g. breakpoints and state. This file
25 | # is just code (usually assignment statements) that get eval'd.
26 |
27 | # The file to save the journal information.
28 | typeset _Dbg_journal=$(_Dbg_tempname journal)
29 |
30 | # append a command into journal file and then run the command.
31 | _Dbg_write_journal_eval() {
32 | _Dbg_write_journal "$@"
33 | eval "$@"
34 | }
35 |
36 | # append a command into journal file and then run the command.
37 | _Dbg_write_journal_var() {
38 | typeset var_name="$1"
39 | typeset val
40 | typeset val_cmd="val='\${$var_name}'"
41 | eval "$val_cmd"
42 | _Dbg_write_journal "${var_name}='${val}'"
43 | }
44 |
45 | _Dbg_write_journal_avar() {
46 | typeset decl_str; decl_str=$(declare -p $1)
47 | typeset -a decl_a
48 | decl_a=($decl_str)
49 | typeset -a decl_a2
50 | decl_a2=${decl_a[@]:2}
51 | _Dbg_write_journal ${decl_a2[@]}
52 | }
53 |
54 | # Append a command into journal file. But we only need to do
55 | # if we are in a subshell.
56 | _Dbg_write_journal() {
57 | if (( BASH_SUBSHELL != 0 )) ; then
58 | echo "$@" >> ${_Dbg_journal} 2>/dev/null
59 | fi
60 | # return $?
61 | }
62 |
63 | # Remove all journal files.
64 | _Dbg_erase_journals() {
65 | [[ -f $_Dbg_journal ]] && rm ${_Dbg_journal} 2>/dev/null
66 | return $?
67 | }
68 |
69 | # read in or "source" in journal file which will set variables.
70 | _Dbg_source_journal() {
71 |
72 | if [ -r $_Dbg_journal ] ; then
73 | . $_Dbg_journal
74 | (( BASH_SUBSHELL == 0 )) && _Dbg_erase_journals
75 | fi
76 | }
77 |
78 | if [ ! -f _Dbg_journal ] ; then
79 | typeset -i _Dbg_QUIT_LEVELS=0
80 | _Dbg_write_journal "_Dbg_QUIT_LEVELS=0"
81 | fi
82 |
--------------------------------------------------------------------------------
/bashdb_dir/lib/commands.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | #
3 | # Copyright (C) 2006, 2008, 2010, 2016 Rocky Bernstein
4 | #
5 | # This program is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU General Public License as
7 | # published by the Free Software Foundation; either version 2, or
8 | # (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | # General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program; see the file COPYING. If not, write to
17 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
18 | # MA 02111 USA.
19 |
20 | # Code adapted from my pydb code to do the same thing.
21 | #================ VARIABLE INITIALIZATIONS ====================#
22 |
23 | # associates a command list to breakpoint numbers
24 | typeset -ai _Dbg_brkpt_commands_start=()
25 | typeset -ai _Dbg_brkpt_commands_end=()
26 |
27 | # The text strings for the *all* breakpoints. To get breakpoints for
28 | # breakpoint i, this goies from _Dbg_brkpt_commands_start[i] to
29 | # _Dbg_brkpt_commands_end[i]
30 | #
31 | typeset -a _Dbg_brkpt_commands=()
32 |
33 | # For each breakpoint number, tells if the prompt must be displayed after
34 | # execing the command list
35 |
36 | typeset -ai _Dbg_brkpt_commands_doprompt=()
37 |
38 | # For each breakpoint number, tells if the stack trace must be
39 | # displayed after execing the cmd list
40 |
41 | typeset -ai _Dbg_brkpt_commands_silent=()
42 |
43 | typeset -i _Dbg_brkpt_commands_current=-1
44 |
45 | # True while in the process of defining a command list
46 | _Dbg_brkpt_commands_defining=0
47 |
48 | # The breakpoint number for which we are defining a list
49 | _Dbg_brkpt_commands_bnum=0
50 |
51 | # Call every command that was set for the current active breakpoint
52 | # (if there is one) Returns True if the normal interaction function
53 | # must be called, False otherwise
54 |
55 | _Dbg_bp_commands() {
56 | local currentbp=$1
57 | local lastcmd_back=$_Dbg_brkpt_lastcmd
58 | ## _Dbg_brkpt_setup(frame, None) ??? FIXME Probably not needed
59 | local -i i
60 | local -i start=${_Dbg_brkpt_commands_start[$currentbp]}
61 | local -i end=${_Dbg_brkpt_commands_end[$currentbp]}
62 | for (( i=start ; (( i < end )) ; i++ )) ; do
63 | local -a line=(${_Dbg_brkpt_commands[$i]})
64 | _Dbg_onecmd ${line[*]}
65 | _Dbg_brkpt_lastcmd=$lastcmd_back
66 | if (( _Dbg_brkpt_commands_doprompt[$currentbp] )) ; then
67 | ###??? What's this
68 | _Dbg_process_commands
69 | return 0
70 | fi
71 | done
72 | return 1
73 | }
74 |
--------------------------------------------------------------------------------
/bashdb_dir/command/trace.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | #
3 | # Copyright (C) 2008, 2010-2011, 2016 Rocky Bernstein
4 | #
5 | # This program is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU General Public License as
7 | # published by the Free Software Foundation; either version 2, or
8 | # (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | # General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program; see the file COPYING. If not, write to
17 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
18 | # MA 02111 USA.
19 |
20 | _Dbg_help_add trace \
21 | '**trace** *function*
22 |
23 | trace alias *alias*
24 |
25 | Set "xtrace" (set -x) tracing when *function is called.
26 |
27 | See also "untrace" and "debug".'
28 |
29 | # Wrap "set -x .. set +x" around a call to function $1.
30 | # Normally we also save and restrore any trap DEBUG functions. However
31 | # If $2 is 0 we will won't.
32 | # The wrapped function becomes the new function and the original
33 | # function is called old_$1.
34 | # $? is 0 if successful.
35 | function _Dbg_do_trace {
36 | if (($# == 0)) ; then
37 | _Dbg_errmsg "trace: missing function name."
38 | return 2
39 | fi
40 | typeset -r fn=$1
41 | typeset -ri clear_debug_trap=${2:-1}
42 | _Dbg_is_function "$fn" $_Dbg_set_debug || {
43 | _Dbg_errmsg "trace: function \"$fn\" is not a function."
44 | return 3
45 | }
46 | cmd=$(typeset -f -- "$fn") || {
47 | _Dbg_errmsg "Can't find function definition for definition \"$fn\"."
48 | return 4
49 | }
50 | if [[ $cmd =~ '^function ' ]] ; then
51 | cmd="function old_${cmd:9}"
52 | else
53 | cmd="old_${cmd}"
54 | fi
55 | ((_Dbg_set_debug)) && echo "$cmd"
56 | typeset save_clear_debug_trap_cmd=''
57 | typeset restore_trap_cmd=''
58 | if (( clear_debug_trap )) ; then
59 | save_clear_trap_cmd='local old_handler=$(trap -p DEBUG); trap - DEBUG'
60 | restore_trap_cmd='eval $old_handler'
61 | fi
62 | eval "$cmd" || {
63 | _Dbg_errmsg "Error in renaming function \"$fn\" to \"old_${fn}\"."
64 | return 5
65 | }
66 | cmd="${fn}() {
67 | $save_clear_trap_cmd
68 | typeset -ri old_set_x=is_traced
69 | set -x
70 | old_$fn \"\$@\"
71 | typeset -ri rc=\$?
72 | (( old_set_x == 0 )) && set +x # still messes up of fn did: set -x
73 | $restore_trap_cmd
74 | return \$rc
75 | }
76 | "
77 | ((_Dbg_set_debug)) && echo "$cmd"
78 | eval "$cmd" || return 6
79 | _Dbg_msg "\"$fn\" renamed \"old_${fn}\" and traced by \"${fn}\"."
80 | return 0
81 | }
82 |
--------------------------------------------------------------------------------
/bashdb_dir/command/run.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "run" debugger command
3 | #
4 | # Copyright (C) 2002-2004, 2006, 2008-2010, 2016 Rocky Bernstein
5 | #
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | # Restart script in same way with saved arguments (probably the same
23 | # ones as we were given before).
24 |
25 | _Dbg_help_add run \
26 | '**run** [*args*]
27 |
28 | Attempt to restart the program via an exec call.
29 |
30 | See also:
31 | ---------
32 |
33 | **set args**, **kill** and **quit**'
34 |
35 | _Dbg_do_run() {
36 | typeset script_args
37 | # We need to escape any embedded blanks in script_args and such.
38 | if (( $# == 0 )) ; then
39 | printf -v script_args "%q " "${_Dbg_orig_script_args[@]}"
40 | else
41 | printf -v script_args "%q " "$@"
42 | fi
43 |
44 | typeset exec_cmd_prefix="$_Dbg_orig_0"
45 | if (( _Dbg_script )) ; then
46 | [ -z "$BASH" ] && BASH='bash'
47 | typeset bash_opt=''
48 | # case $_Dbg_orig_0 in
49 | # bashdb | */bashdb )
50 | # bash_opt='--debugger ' ;;
51 | # esac
52 | if [[ $_Dbg_frame_last_filename == $_Dbg_bogus_file ]] ; then
53 | script_args="${bash_opt}-c \"$_Dbg_EXECUTION_STRING\""
54 | else
55 | script_args="${bash_opt}$_Dbg_orig_0 $script_args";
56 | fi
57 | exec_cmd_prefix="$BASH"
58 | elif [[ -n "$BASH" ]] ; then
59 | local exec_cmd_prefix="$BASH $_Dbg_orig_0"
60 | fi
61 |
62 | _Dbg_msg "Restarting with: $script_args"
63 |
64 | # If we are in a subshell we need to get out of those levels
65 | # first before we restart. The strategy is to write into persistent
66 | # storage the restart command, and issue a "quit." The quit should
67 | # discover the restart at the last minute and issue the restart.
68 | if (( BASH_SUBSHELL > 0 )) ; then
69 | _Dbg_msg "Note you are in a subshell. We will need to leave that first."
70 | _Dbg_write_journal "_Dbg_RESTART_COMMAND=\"$exec_cmd_prefix $script_args\""
71 | _Dbg_do_quit 0
72 | fi
73 | _Dbg_cleanup
74 | _Dbg_save_state
75 | builtin cd $_Dbg_init_cwd
76 |
77 | eval "exec $exec_cmd_prefix $script_args"
78 | }
79 |
80 | _Dbg_alias_add R run
81 | _Dbg_alias_add restart run
82 |
--------------------------------------------------------------------------------
/bashdb_dir/command/set_sub/highlight.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set highlight" debugger command
3 | #
4 | # Copyright (C) 2011, 2014-2016 Rocky Bernstein
5 | #
6 | # This program is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU General Public License as
8 | # published by the Free Software Foundation; either version 2, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; see the file COPYING. If not, write to
18 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
19 | # MA 02111 USA.
20 |
21 | # If run standalone, pull in other files we need
22 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
23 | dirname=${BASH_SOURCE[0]%/*}
24 | [[ $dirname == $0 ]] && top_dir='../..' || top_dir=${dirname}/../..
25 | [[ -z $_Dbg_libdir ]] && _Dbg_libdir=$top_dir
26 | for file in help alias ; do source $top_dir/lib/${file}.sh; done
27 | fi
28 |
29 | _Dbg_help_add_sub set highlight \
30 | '**set** **highlight** [**dark**|**light**|**off**|**reset**]
31 |
32 | Set using terminal highlight.
33 |
34 | Use **reset** to set highlighting on and force a redo of syntax
35 | highlighting of already cached files. This may be needed if the
36 | debugger was started without syntax highlighting initially.
37 |
38 | **dark** sets sets for highlighting for a terminal with a dark background and
39 | **light** set for highlighting for a terminal with a light background.
40 |
41 | See also:
42 | ---------
43 |
44 | **show highlight**.
45 | '
46 |
47 | _Dbg_next_complete[set highlight]='_Dbg_complete_highlight'
48 |
49 | _Dbg_complete_highlight() {
50 | COMPREPLY=(dark light off reset)
51 | }
52 |
53 | _Dbg_do_set_highlight() {
54 | if (( ! _Dbg_working_term_highlight )) ; then
55 | _Dbg_errmsg "Can't run term-highlight. Setting forced off"
56 | return 1
57 | fi
58 | typeset onoff=${1:-'light'}
59 | case $onoff in
60 | on | light )
61 | _Dbg_set_highlight='light'
62 | _Dbg_filecache_reset
63 | _Dbg_readin $_Dbg_frame_last_filename
64 | ;;
65 | dark )
66 | _Dbg_set_highlight='dark'
67 | _Dbg_filecache_reset
68 | _Dbg_readin $_Dbg_frame_last_filename
69 | ;;
70 | off | 0 )
71 | _Dbg_set_highlight=''
72 | _Dbg_filecache_reset
73 | _Dbg_readin $_Dbg_frame_last_filename
74 | ;;
75 | reset )
76 | [[ -z $_Dbg_set_highlight ]] && _Dbg_set_highlight='light'
77 | _Dbg_filecache_reset
78 | _Dbg_readin $_Dbg_frame_last_filename
79 | ;;
80 | * )
81 | _Dbg_errmsg '"dark", "light", "off", or "reset" expected.'
82 | return 1
83 | esac
84 | _Dbg_do_show highlight
85 | return 0
86 | }
87 |
--------------------------------------------------------------------------------
/bashdb_dir/init/io.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # io.sh - Bourne Again Shell Debugger Input/Output routines
3 | #
4 | # Copyright (C) 2002, 2003, 2004, 2006, 2008, 2009, 2011 Rocky Bernstein
5 | #
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with bashdb; see the file COPYING. If not, write to the Free Software
19 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
20 |
21 | # ==================== VARIABLES =======================================
22 |
23 | # _Dbg_source_mungedfilename is an array which contains source_lines for
24 | # filename
25 | # _Dbg_read_mungedfilename is array which contains the value '1' if the
26 | # filename has been read in.
27 |
28 | typeset -a _Dbg_override_filenames # name translations given via the debugger
29 | # "file" command.
30 |
31 | # ===================== FUNCTIONS =======================================
32 |
33 | # _Dbg_progess_show --- print the progress bar
34 | # $1: prefix string
35 | # $2: max value
36 | # $3: current value
37 | function _Dbg_progess_show {
38 | typeset title=$1
39 | typeset -i max_value=$2
40 | typeset -i current_value=$3
41 | typeset -i max_length=40
42 | typeset -i current_length
43 |
44 |
45 | if (( max_value == 0 )) ; then
46 | # Avoid dividing by 0.
47 | current_length=${max_length}
48 | else
49 | current_length=$(( ${max_length} * ${current_value} / ${max_value} ))
50 | fi
51 |
52 | _Dbg_progess_show_internal "$1" ${max_length} ${current_length}
53 | _Dbg_printf_nocr ' %3d%%' "$(( 100 * ${current_value} / ${max_value} ))"
54 | }
55 | # _Dbg_progess_show_internal --- internal function for _Dbg_progess_show
56 | # $1: prefix string
57 | # $2: max length
58 | # $3: current length
59 | function _Dbg_progess_show_internal {
60 | typeset -i i=0
61 |
62 | # Erase line
63 | if [[ t == $EMACS ]]; then
64 | _Dbg_msg_nocr "\r\b\n"
65 | else
66 | _Dbg_msg_nocr "\r\b"
67 | fi
68 |
69 | _Dbg_msg_nocr "$1: ["
70 | for (( i=0; i < $3 ; i++ )); do
71 | _Dbg_msg_nocr "="
72 | done
73 | _Dbg_msg_nocr '>'
74 |
75 | for (( i=0; i < $2 - $3 ; i++ )); do
76 | _Dbg_msg_nocr ' '
77 | done
78 | _Dbg_msg_nocr ']'
79 | }
80 |
81 | # clean up progress bar
82 | function _Dbg_progess_done {
83 | # Erase line
84 | if test "x$EMACS" = xt; then
85 | _Dbg_msg_nocr "\r\b\n"
86 | else
87 | _Dbg_msg_nocr "\r\b"
88 | fi
89 | _Dbg_msg "$1"
90 | }
91 |
--------------------------------------------------------------------------------
/bashdb_dir/command/quit.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # quit.sh - The real way to leave this program.
3 | #
4 | # Copyright (C) 2002-2008, 2010-2011, 2016
5 | # Rocky Bernstein
6 | #
7 | # This program is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 2, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; see the file COPYING. If not, write to
19 | # the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
20 | # MA 02111 USA.
21 |
22 | _Dbg_help_add quit \
23 | '**quit** [*exit-code* [*shell-levels*]]
24 |
25 | Quit the debugger.
26 |
27 | The program being debugged is aborted. If EXIT-CODE is given that
28 | will be the exit return code. If SHELL-LEVELS then up to that many
29 | nested shells are quit. However to be effective, the last of those
30 | shells should have been run under the debugger.
31 |
32 | See also:
33 | ---------
34 |
35 | **finish**, **return** and **run**.'
36 |
37 | _Dbg_do_quit() {
38 | typeset -i return_code=${1:-$_Dbg_program_exit_code}
39 |
40 | typeset -i desired_quit_levels=${2:-0}
41 |
42 | if (( desired_quit_levels == 0 \
43 | || desired_quit_levels > BASH_SUBSHELL+1)) ; then
44 | ((desired_quit_levels=BASH_SUBSHELL+1))
45 | fi
46 |
47 | ((_Dbg_QUIT_LEVELS+=desired_quit_levels))
48 |
49 | # Reduce the number of recorded levels that we need to leave by
50 | # if _Dbg_QUIT_LEVELS is greater than 0.
51 | ((_Dbg_QUIT_LEVELS--))
52 |
53 | ## write this to the next level up can read it.
54 | _Dbg_write_journal "_Dbg_QUIT_LEVELS=$_Dbg_QUIT_LEVELS"
55 | _Dbg_write_journal "_Dbg_step_ignore=$_Dbg_step_ignore"
56 |
57 | # Reset signal handlers to their default but only if
58 | # we are not in a subshell.
59 | if (( BASH_SUBSHELL == 0 )) ; then
60 |
61 | # If we were told to restart from deep down, restart instead of quit.
62 | if [ -n "$_Dbg_RESTART_COMMAND" ] ; then
63 | _Dbg_erase_journals
64 | _Dbg_save_state
65 | exec $_Dbg_RESTART_COMMAND
66 | fi
67 |
68 | _Dbg_msg "${_Dbg_debugger_name}: That's all, folks..."
69 | _Dbg_cleanup
70 | # Save history file
71 | (( _Dbg_set_history )) && history -w $_Dbg_histfile
72 | fi
73 |
74 | trap - DEBUG
75 | # This is a hack we need. I am not sure why.
76 | trap "_Dbg_cleanup2" EXIT
77 |
78 | # And just when you thought we'd never get around to it...
79 | exit $return_code
80 | }
81 | _Dbg_alias_add q quit
82 | _Dbg_alias_add q! quit
83 | _Dbg_alias_add exit quit
84 |
--------------------------------------------------------------------------------