Escape whitespace for setting zshdb arguments with spaces
82 | * escapeCharactersInZshdbArg("/pa th/to/script.sh");
83 | * // => "/pa\\\\040th/to/script.sh"
84 | */
85 | export function escapeCharactersInZshdbArg(path: string): string {
86 | return path.replace(/\s/g, (m) => "\\\\" + ("0000" + m.charCodeAt(0).toString(8)).slice(-4));
87 | }
88 |
89 |
--------------------------------------------------------------------------------
/src/spawnZsh.ts:
--------------------------------------------------------------------------------
1 | import { ChildProcess, SpawnSyncReturns, spawnSync, spawn } from 'child_process';
2 | import { getWSLLauncherPath } from './handlePath';
3 |
4 | export function spawnZshScript(scriptCode: string, pathZsh: string, outputHandler?: (output: string, category?: string ) => void): ChildProcess{
5 | const currentShell = (process.platform === "win32") ? getWSLLauncherPath(false) : pathZsh;
6 | const optionalZshPathArgument = (currentShell !== pathZsh) ? pathZsh : "";
7 |
8 | let spawnedProcess = spawn(currentShell, [optionalZshPathArgument, "-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 spawnZshScriptSync(scriptCode: string, pathZsh: string, spawnTimeout: number): SpawnSyncReturns{
28 | const currentShell = (process.platform === "win32") ? getWSLLauncherPath(false) : pathZsh;
29 | const optionalZshPathArgument = (currentShell !== pathZsh) ? pathZsh : "";
30 |
31 | return spawnSync(currentShell, [optionalZshPathArgument, "-c", scriptCode].filter(arg => arg !== ""), { timeout: spawnTimeout, shell: false });
32 | }
--------------------------------------------------------------------------------
/src/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es2018",
5 |
6 | "noImplicitAny": false,
7 | "removeComments": true,
8 | "noUnusedLocals": true,
9 | "noImplicitThis": true,
10 | "inlineSourceMap": false,
11 | "sourceMap": true,
12 | "outDir": "../out",
13 | "preserveConstEnums": true,
14 | "strictNullChecks": true,
15 | "noUnusedParameters": true
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "no-unused-expression": true,
4 | "no-duplicate-variable": true,
5 | "curly": true,
6 | "class-name": true,
7 | "semicolon": true,
8 | "triple-equals": true,
9 | "no-var-keyword": true,
10 | "no-bitwise": true
11 | }
12 | }
--------------------------------------------------------------------------------
/zsh-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 | }
--------------------------------------------------------------------------------
/zshdb_dir/command/.gitignore:
--------------------------------------------------------------------------------
1 | /*~
2 | Makefile
3 | Makefile.in
4 |
--------------------------------------------------------------------------------
/zshdb_dir/command/Makefile.am:
--------------------------------------------------------------------------------
1 | SUBDIRS = info_sub set_sub show_sub
2 | pkgdatadir = ${datadir}/@PACKAGE@/command
3 | pkgdata_DATA = $(wildcard *.sh)
4 |
5 | EXTRA_DIST = $(pkgdata_DATA)
6 |
7 | MOSTLYCLEANFILES = *.orig *.rej
8 |
--------------------------------------------------------------------------------
/zshdb_dir/command/alias.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # alias.sh - gdb-like "alias" debugger command
3 | #
4 | # Copyright (C) 2008, 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 alias \
22 | '**alias** *alias-name* *debugger-command*
23 |
24 | Make *alias-name* be an alias for *debugger-command*.
25 |
26 | Examples:
27 | ---------
28 |
29 | alias cat list # "cat prog.py" is the same as "list prog.py"
30 | alias s step # "s" is now an alias for "step".
31 | # The above example is done by default.
32 |
33 | See also:
34 | ---------
35 |
36 | **unalias** and **show alias**.
37 | '
38 |
39 | _Dbg_do_alias() {
40 | if (($# != 2)) ; then
41 | _Dbg_errmsg "Got $# parameter(s), but need 2."
42 | return 1
43 | fi
44 | _Dbg_alias_add $1 $2
45 | return 0
46 | }
47 |
48 | _Dbg_help_add unalias \
49 | '**unalias** *name*
50 |
51 | Remove debugger command alias *name*.
52 |
53 | Use **show aliases** to get a list the aliases in effect.
54 | ' 1
55 |
56 | _Dbg_do_unalias() {
57 | if (($# != 1)) ; then
58 | _Dbg_errmsg "Got $# parameters, but need 1."
59 | fi
60 | _Dbg_alias_remove $1
61 | }
62 |
--------------------------------------------------------------------------------
/zshdb_dir/command/backtrace.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "backtrace" debugger command
3 | #
4 | # Copyright (C) 2008, 2016, 2018 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 | # This code assumes the version of zsh where functrace has file names
22 | # and absolute line positions, not function names and offset.
23 |
24 | _Dbg_help_add backtrace \
25 | '**backtrace** [*opts*] [*count*]
26 |
27 | Print backtrace of all stack frames, or innermost *count* frames.
28 |
29 | With a negative argument, print outermost -*count* frames.
30 |
31 | An arrow indicates the "current frame". The current frame determines
32 | the context used for many debugger commands such as expression
33 | evaluation or source-line listing.
34 |
35 | *opts* are:
36 |
37 | -s | --source - show source code line
38 | -h | --help - give this help
39 |
40 | Examples:
41 | ---------
42 |
43 | backtrace # Print a full stack trace
44 | backtrace 2 # Print only the top two entries
45 | backtrace -1 # Print a stack trace except the initial (least recent) call.
46 | backtrace -s # show source lines in listing
47 | backtrace --source # same as above
48 |
49 | See also:
50 | ---------
51 |
52 | **frame** and **list**
53 | '
54 |
55 | # Print a stack backtrace. $1 after processing options is the maximum
56 | # number of entries to include.
57 | _Dbg_do_backtrace() {
58 |
59 | _Dbg_not_running && return 1
60 |
61 | local -A shortopts
62 | typeset -i show_source=0
63 | emulate -L sh
64 | setopt kshglob noshglob braceexpand nokshautoload
65 | shortopts=(s source)
66 |
67 | while getopts "hs" name; do
68 | case $name in
69 | [s]) OPTARG="${shortopts[$name]}" ;&
70 | s)
71 | show_source=1
72 | shift
73 | ;;
74 | h)
75 | _Dbg_do_help backtrace
76 | return
77 | ;;
78 | esac
79 | done
80 |
81 | typeset prefix='##'
82 | typeset -i at_most=${#_Dbg_frame_stack[@]}
83 | typeset -i count=${1:-$at_most}
84 | typeset -i i=0
85 |
86 | if (( count < 0 )) ; then
87 | (( i = at_most + count ))
88 | (( count = at_most ))
89 | fi
90 |
91 | # Loop which dumps out stack trace.
92 | for (( ; (( i < at_most && count > 0 )) ; i++ )) ; do
93 | _Dbg_print_frame $i $show_source
94 | ((count--))
95 | done
96 | return 0
97 | }
98 |
99 | _Dbg_alias_add bt backtrace
100 | _Dbg_alias_add T backtrace
101 | _Dbg_alias_add where backtrace
102 |
--------------------------------------------------------------------------------
/zshdb_dir/command/break.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | #
3 | # Copyright (C) 2008-2011, 2016, 2018 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 break \
22 | '**break** [*loc-spec*]
23 |
24 | Set a breakpoint at *loc-spec*.
25 |
26 | If no location specification is given, use the current line.
27 |
28 | Multiple breakpoints at one place are permitted, and useful if conditional.
29 |
30 | See also:
31 | ---------
32 |
33 | "tbreak" and "continue"'
34 |
35 | _Dbg_help_add tbreak \
36 | '**tbreak* [*loc-spec*]
37 |
38 | Set a one-time breakpoint at *loc-spec*.
39 |
40 | Like "break" except the breakpoint is only temporary,
41 | so it will be deleted when hit. Equivalent to "break" followed
42 | by using "delete" on the breakpoint number.
43 |
44 | If no location specification is given, use the current line.'
45 |
46 | _Dbg_do_tbreak() {
47 | _Dbg_do_break_common 1 $@
48 | return $?
49 | }
50 |
51 | _Dbg_do_break() {
52 | _Dbg_do_break_common 0 $@
53 | return $?
54 | }
55 |
56 | # Add breakpoint(s) at given line number of the current file. $1 is
57 | # the line number or _Dbg_frame_lineno if omitted. $2 is a condition
58 | # to test for whether to stop.
59 | _Dbg_do_break_common() {
60 |
61 | typeset -i is_temp=$1
62 | (( $# > 0 )) && shift
63 |
64 | typeset linespec
65 | if (( $# > 0 )) ; then
66 | linespec="$1"
67 | else
68 | _Dbg_frame_lineno; linespec=$_Dbg_frame_lineno
69 | fi
70 | (( $# > 0 )) && shift
71 |
72 | typeset condition=${1:-''}
73 | if [[ "$linespec" == 'if' ]]; then
74 | _Dbg_frame_lineno; linespec=$_Dbg_frame_lineno
75 | elif [[ -z $condition ]] ; then
76 | condition=1
77 | elif [[ $condition == 'if' ]] ; then
78 | shift
79 | condition="$@"
80 | fi
81 | [[ -z $condition ]] && condition=1
82 |
83 | typeset filename
84 | typeset -i line_number
85 | typeset full_filename
86 |
87 | _Dbg_linespec_setup "$linespec"
88 |
89 | if [[ -n "$full_filename" ]] ; then
90 | if (( line_number == 0 )) ; then
91 | _Dbg_errmsg 'There is no line 0 to break at.'
92 | return
93 | else
94 | _Dbg_check_line $line_number "$full_filename"
95 | (( $? == 0 )) && \
96 | _Dbg_set_brkpt "$full_filename" "$line_number" $is_temp "$condition"
97 | fi
98 | else
99 | _Dbg_file_not_read_in "$filename"
100 | fi
101 | _Dbg_last_cmd="break"
102 | }
103 |
104 | # delete brkpt(s) at given file:line numbers. If no file is given
105 | # use the current file.
106 | _Dbg_do_clear_brkpt() {
107 | typeset -r n=${1:-$_Dbg_frame_last_lineno}
108 |
109 | typeset filename
110 | typeset -i line_number
111 | typeset full_filename
112 |
113 | if [[ -n $full_filename ]] ; then
114 | if (( line_number == 0 )) ; then
115 | _Dbg_msg "There is no line 0 to clear."
116 | else
117 | _Dbg_check_line $line_number "$full_filename"
118 | if (( $? == 0 )) ; then
119 | _Dbg_unset_brkpt "$full_filename" "$line_number"
120 | typeset -r found=$?
121 | if [[ $found != 0 ]] ; then
122 | _Dbg_msg "Removed $found breakpoint(s)."
123 | else
124 | _Dbg_msg "Didn't find any breakpoints to remove at $n."
125 | fi
126 | fi
127 | fi
128 | else
129 | _Dbg_file_not_read_in "$filename"
130 | fi
131 | }
132 |
133 | _Dbg_alias_add b break
134 |
--------------------------------------------------------------------------------
/zshdb_dir/command/condition.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # condition.sh - gdb-like "condition" debugger command
3 | #
4 | # Copyright (C) 2009, 2016, 2017 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; 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 condition \
21 | "**condition** *bp_number* *condition*
22 |
23 | Break only if *condition* is true in breakpoint number *bp_number*.
24 |
25 | *bp_number* is a breakpoint number. *condition* is a zsh expression
26 | which must evaluate to *True* before the breakpoint is honored. If
27 | *condition* is absent, any existing condition is removed; i.e., the
28 | breakpoint is made unconditional.
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 | "
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 0
50 | fi
51 |
52 | typeset -r n=$1
53 | shift
54 | typeset condition="$@"
55 | if [[ $n != [0-9]* ]]; then
56 | _Dbg_errmsg "condition: Bad breakpoint number: $n"
57 | return 0
58 | fi
59 |
60 | if [[ -z ${_Dbg_brkpt_file[$n]} ]] ; then
61 | _Dbg_errmsg "condition: Breakpoint entry $n is not set. Condition not changed."
62 | return 0
63 | fi
64 |
65 | if [[ -z $condition ]] ; then
66 | condition=1
67 | _Dbg_msg "Breakpoint $n now unconditional."
68 | fi
69 | _Dbg_brkpt_cond[$n]="$condition"
70 | _Dbg_last_cmd='condition'
71 | return 1
72 | }
73 |
--------------------------------------------------------------------------------
/zshdb_dir/command/continue.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # continue.sh - gdb-like "continue" debugger command
3 | #
4 | # Copyright (C) 2008, 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 | _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 |
--------------------------------------------------------------------------------
/zshdb_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 | # 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 delete \
22 | "**delete** {*brkpt-num*}...
23 |
24 | Delete some breakpoints.
25 |
26 | Arguments are breakpoint numbers with spaces in between. Without
27 | arguments, clear all breaks (but first ask for confirmation). "
28 |
29 | # Routine to a delete breakpoint/watchpoint by entry numbers.
30 | _Dbg_do_delete() {
31 | _Dbg_do_delete_internal $@
32 | return 0
33 | }
34 |
35 | _Dbg_do_delete_internal() {
36 | typeset to_go; to_go=$@
37 | typeset -i i
38 | typeset -i tot_found=0
39 |
40 | if (( $# == 0 )) ; then
41 | _Dbg_confirm "Delete all breakpoints? (y/N): " 'N'
42 | if [[ $_Dbg_response == [yY] ]] ; then
43 | typeset to_go=$(_Dbg_breakpoint_list)
44 | else
45 | return
46 | fi
47 | fi
48 |
49 | _Dbg_last_cmd='delete'
50 | for del in $to_go ; do
51 | case $del in
52 | # $_watch_pat )
53 | # _Dbg_delete_watch_entry ${del:0:${#del}-1}
54 | # ;;
55 | [0-9]* )
56 | if _Dbg_delete_brkpt_entry $del ; then
57 | _Dbg_msg "Deleted breakpoint ${del}"
58 | ((tot_found++))
59 | fi
60 | ;;
61 | * )
62 | _Dbg_errmsg "Invalid entry number skipped: $del"
63 | esac
64 | done
65 | return $tot_found
66 | }
67 |
68 | _Dbg_alias_add 'd' delete
69 |
70 | _Dbg_alias_add 'unset' 'delete'
71 |
--------------------------------------------------------------------------------
/zshdb_dir/command/disable.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # disable.sh - gdb-like "disable" debugger command
3 | #
4 | # Copyright (C) 2008-2009, 2011, 2016-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 disable \
22 | '**disable** *bpnum1* [*bpnum2* ...]
23 |
24 | Disables breakopints *bpnum1*, *bpnum2*. Breakpoints numbers are given
25 | as a space-separated list of breakpoint numbers.
26 |
27 | To disable all breakpoints, give no argument.
28 | A disabled breakpoint is not forgotten, but has no effect until re-enabled.
29 |
30 | See also:
31 | ---------
32 |
33 | **enable** and **info break**.'
34 |
35 | # Disable breakpoint(s)/watchpoint(s) by entry number(s).
36 | _Dbg_do_disable() {
37 | _Dbg_enable_disable 0 'disabled' "$@"
38 | return 0
39 | }
40 |
--------------------------------------------------------------------------------
/zshdb_dir/command/display.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # display.sh - gdb-like "(un)display" and list display debugger commands
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 |
--------------------------------------------------------------------------------
/zshdb_dir/command/down.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "down" debugger command
3 | #
4 | # Copyright (C) 2010-2012, 2014, 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 == ${#funcfiletrace[@]} ]] ; then
23 | dirname=${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 down $1 or one in the stack.
29 | _Dbg_help_add down \
30 | '**down** [*count*]
31 |
32 | Move the current frame down in the stack trace (to an newer frame). 0 is
33 | the most recent frame.
34 |
35 | If *count* is omitted, use 1.
36 |
37 | See also:
38 | ---------
39 |
40 | **down** and **frame**.'
41 |
42 | typeset -A _Dbg_complete_level_1_data
43 | _Dbg_complete_level_1_data[down]='-f_Dbg_frame_complete -1'
44 |
45 | function _Dbg_do_down {
46 | _Dbg_not_running && return 1
47 | typeset count=${1:-1}
48 | _Dbg_is_signed_int $count
49 | if (( 0 == $? )) ; then
50 | _Dbg_frame_adjust $count -1
51 | typeset -i rc=$?
52 | else
53 | _Dbg_errmsg "Expecting an integer; got $count"
54 | typeset -i rc=2
55 | fi
56 | return 0
57 | }
58 |
59 | # Demo it
60 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
61 | for _Dbg_file in help msg sort columnize ; do
62 | source ${top_dir}/lib/${_Dbg_file}.sh
63 | done
64 | source ${top_dir}/command/help.sh
65 | _Dbg_args='down'
66 | _Dbg_do_help down
67 | fi
68 |
--------------------------------------------------------------------------------
/zshdb_dir/command/edit.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # edit.sh - Debugger edit command - enter $EDITOR
3 |
4 | # Copyright (C) 2008, 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 | #================ 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 0
36 | fi
37 | typeset editor=${EDITOR:-ex}
38 | typeset -i line_number
39 | if (( $# == 0 )) ; then
40 | _Dbg_frame_lineno
41 | line_number=$?
42 | _Dbg_frame_file
43 | ((0 != $?)) && return 0
44 | ((line_number<=0)) && return 0
45 | full_filename="$_Dbg_frame_filename"
46 | else
47 | _Dbg_linespec_setup "$1"
48 | fi
49 | if [[ ! -r $full_filename ]] ; then
50 | _Dbg_errmsg "File $full_filename is not readable"
51 | fi
52 | $editor +$line_number $full_filename
53 | _Dbg_last_cmd='edit'
54 | return 0
55 | }
56 |
57 | _Dbg_alias_add 'ed' 'edit'
58 |
--------------------------------------------------------------------------------
/zshdb_dir/command/enable.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "enable" debugger command
3 | #
4 | # Copyright (C) 2008-2009, 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 | _Dbg_help_add enable \
23 | '**enable** *bpnum1* [*bpnum2* ...]
24 |
25 | Enables breakpoints *bpnum1*, *bpnum2*... Breakpoints numbers are
26 | given as a space-separated list of numbers.
27 |
28 | With no subcommand, breakpoints are enabled until you command otherwise.
29 | This is used to cancel the effect of the "disable" command.
30 |
31 | See also:
32 | ---------
33 |
34 | **disable** and **info break**.'
35 |
36 | # Enable breakpoint(s)/watchpoint(s) by entry number(s).
37 | _Dbg_do_enable() {
38 | _Dbg_enable_disable 1 'enabled' "$@"
39 | return 0
40 | }
41 |
--------------------------------------------------------------------------------
/zshdb_dir/command/examine.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "Examine" debugger command.
3 | #
4 | # Copyright (C) 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 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
23 | dirname=${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 | _Dbg_help_add 'examine' \
29 | "**examine** *expr*
30 |
31 | Print value of an expression via typeset, let, and failing these, eval.
32 |
33 | Single variables and arithmetic expressions do not need leading $ for
34 | their value is to be substituted. However if neither these, variables
35 | need $ to have their value substituted.
36 |
37 | See also:
38 | ---------
39 |
40 | **eval** and **pr**."
41 |
42 | function _Dbg_do_examine {
43 | typeset _Dbg_expr; _Dbg_expr=${@:-"$_Dbg_last_x_args"}
44 | typeset _Dbg_result
45 | if [[ -z $_Dbg_expr ]] then
46 | _Dbg_msg "$_Dbg_expr"
47 | elif _Dbg_defined $_Dbg_expr ; then
48 | _Dbg_result=$(typeset -p $_Dbg_expr)
49 | _Dbg_msg "$_Dbg_result"
50 | elif _Dbg_is_function "$_Dbg_expr" $_Dbg_set_debug; then
51 | _Dbg_result=$(typeset -f $_Dbg_expr)
52 | _Dbg_msg "$_Dbg_result"
53 | else
54 | typeset -i _Dbg_rc
55 | . ${_Dbg_libdir}/lib/set-d-vars.sh
56 | eval let _Dbg_result=$_Dbg_expr 2>/dev/null; _Dbg_rc=$?
57 | _Dbg_set_debugger_internal
58 | if (( _Dbg_rc != 0 )) ; then
59 | _Dbg_do_print "$_Dbg_expr"
60 | else
61 | _Dbg_msg "$_Dbg_result"
62 | fi
63 | fi
64 | _Dbg_last_x_args="$_Dbg_x_args"
65 | }
66 |
67 | _Dbg_alias_add 'x' 'examine'
68 |
69 | # Demo it.
70 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
71 | for _Dbg_file in fns msg ; do
72 | source $top_dir/lib/${_Dbg_file}.sh
73 | done
74 | source $top_dir/command/help.sh
75 | _Dbg_args='examine'
76 | _Dbg_do_help x
77 | _Dbg_do_examine top_dir
78 | fi
79 |
--------------------------------------------------------------------------------
/zshdb_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 0
34 | # return 1
35 | fi
36 |
37 | if (( 0 == $ZSH_SUBSHELL )) ; then
38 | _Dbg_errmsg "You are not in a subshell, so no value(s) need saving."
39 | return 0
40 | # return 2
41 | fi
42 |
43 | typeset var_name
44 | for var_name in $@ ; do
45 | _Dbg_defined $var_name
46 | if (( $? == 0 )) ; then
47 | typeset val
48 | typeset val_cmd="val=\${$var_name}"
49 | eval "$val_cmd"
50 | _Dbg_write_journal "${var_name}=${val}"
51 | else
52 | _Dbg_errmsg "name: $var_name is not known to be a variable."
53 | fi
54 | done
55 | return 0
56 | }
57 |
--------------------------------------------------------------------------------
/zshdb_dir/command/frame.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # frame.sh - gdb-like "frame" debugger commands
3 | #
4 | # Copyright (C) 2008, 2010-2011, 2014, 2016, 2018 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 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
23 | dirname=${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 | _Dbg_help_add frame \
29 | '**frame** [*frame-number*].
30 |
31 | Change the current frame to frame *frame-number* if specified, or the
32 | most-recent frame, 0, if no frame number specified.
33 |
34 | A negative number indicates the position from the other or
35 | least-recently-entered end. So **frame -1** moves to the oldest frame.
36 |
37 | See also:
38 | ---------
39 |
40 | **up**, **down**
41 | '
42 |
43 | typeset -A _Dbg_complete_level_1_data
44 | _Dbg_complete_level_1_data[frame]='-f_Dbg_frame_complete 0'
45 |
46 | _Dbg_do_frame() {
47 | _Dbg_not_running && return 1
48 | typeset count=${1:-1}
49 | _Dbg_is_signed_int $count
50 | if (( 0 == $? )) ; then
51 | _Dbg_frame_adjust $count 0
52 | typeset -i rc=$?
53 | else
54 | _Dbg_errmsg "Expecting an integer; got $count"
55 | typeset -i rc=2
56 |
57 | fi
58 | ((0 == rc)) && _Dbg_last_cmd='frame'
59 | return $rc
60 | }
61 |
--------------------------------------------------------------------------------
/zshdb_dir/command/handle.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # handle.sh - gdb-like "handle" debugger command
3 | #
4 | # Copyright (C) 2002-2006, 2008, 2010-2011,
5 | # 2016 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 |
23 | # Process debugger "handle" command.
24 |
25 | ## Punt on for now...
26 | # _Dbg_help_add handle \
27 | # "handle SIGNAL ACTION -- Specify how to handle SIGNAL.
28 |
29 | # SIGNAL is a signal name like SIGSEGV, but numeric signals like 11
30 | # (which is usually equivalent on \*nix systems) is okay too.
31 |
32 | # ACTION is one of \"stop\", \"nostop\", \"print\", and
33 | # \"noprint\". \"Stop\" indicates entering debugger if this signal
34 | # happens. \"Print\" indicates printing a message if this signal is
35 | # encountered. \"Stack\" is like \"print\" but except the entire call
36 | # stack is printed. Prefacing these actions with \"no\" indicates not to
37 | # do the indicated action."
38 |
39 | _Dbg_help_add handle \
40 | "**handle** *signal* *action*
41 |
42 | Specify how to handle *signal*.
43 |
44 | *signal* is a signal name like SIGSEGV, but numeric signals like 11
45 | (which is usually equivalent on \*nix systems) is okay too.
46 |
47 | *action* is one of \"stop\", \"nostop\", \"print\", and
48 | \"noprint\". \"Stop\" indicates entering debugger if this signal
49 | happens. \"Print\" indicates printing a message if this signal is
50 | encountered. \"Stack\" is like \"print\" but except the entire call
51 | stack is printed. Prefacing these actions with \"no\" indicates not to
52 | do the indicated action."
53 |
54 | _Dbg_do_handle() {
55 | typeset sig=$1
56 | typeset cmd=$2
57 | typeset -i signum
58 | if [[ -z $sig ]] ; then
59 | _Dbg_errmsg "Missing signal name or signal number."
60 | # return 1
61 | return 0
62 | fi
63 |
64 | if [[ $sig == [0-9]*([0-9]) ]]; then
65 | signame=$(_Dbg_signum2name $sig)
66 | typeset -i rc=$?
67 | if (( rc == 0 )) ; then
68 | typeset -i check_num
69 | check_num=$(builtin kill -l $signame)
70 | rc=$?
71 | if ((rc == 0)) ; then
72 | (( check_num != sig )) && rc=1
73 | fi
74 | fi
75 |
76 | if (( rc != 0 )) ; then
77 | _Dbg_errmsg "Bad signal number: $sig"
78 | # return 2
79 | return 0
80 | fi
81 | signum=sig
82 | else
83 | signum=$(_Dbg_name2signum $sig)
84 | if (( $? != 0 )) ; then
85 | _Dbg_errmsg "Bad signal name: $sig"
86 | # return 3
87 | return 0
88 | fi
89 | fi
90 |
91 | [[ -n ${Dbg_sig_print[$signum]} ]] || _Dbg_init_trap $signame $signum
92 | case $cmd in
93 | nop | nopr | nopri | noprin | noprint )
94 | _Dbg_sig_print[signum]='noprint'
95 | # noprint implies nostop
96 | _Dbg_sig_stop[signum]='stop'
97 | ;;
98 |
99 | nosta | nostac | nostack )
100 | _Dbg_sig_show_stack[signum]='nostack'
101 | ;;
102 |
103 | nosto | nostop )
104 | _Dbg_sig_stop[signum]='nostop'
105 | ;;
106 |
107 | p | pr | pri | prin | print )
108 | _Dbg_sig_print[signum]='print'
109 | ;;
110 |
111 | sta | stac | stack )
112 | _Dbg_sig_show_stack[signum]='showstack'
113 | ;;
114 |
115 | sto | stop )
116 | _Dbg_sig_stop[signum]='stop'
117 | # stop keyword implies print
118 | _Dbg_sig_print[signum]='print'
119 | ;;
120 | * )
121 | if (( !cmd )) ; then
122 | _Dbg_errmsg \
123 | "Need to give a command: stop, nostop, stack, nostack, print, noprint"
124 | # return 4
125 | return 0
126 | else
127 | _Dbg_errmsg "Invalid handler command $cmd"
128 | # return 5
129 | return 0
130 | fi
131 | ;;
132 | esac
133 |
134 | return 0
135 | }
136 |
--------------------------------------------------------------------------------
/zshdb_dir/command/help.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # help.sh - gdb-like "help" debugger command
3 | #
4 | # Copyright (C) 2008, 2010, 2013, 2014 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 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${0%/*}
23 | [[ $dirname == $0 ]] && top_dir='..' || top_dir=${dirname}/..
24 | for file in help alias ; do source $top_dir/lib/${file}.sh; done
25 | fi
26 |
27 | _Dbg_help_command_complete() {
28 | unsetopt ksharrays
29 | echo "${(ki)_Dbg_debugger_commands[@]} ${(ki)_Dbg_aliases[@]} *"
30 | setopt ksharrays
31 | }
32 |
33 | _Dbg_help_add help \
34 | '**help** [*command* [*subcommand* ..]]
35 |
36 | If no arguments are given, print a list of command names.
37 | With a command name give help for that command. For many commands
38 | you can get further detailed help by listing the subcommand name.
39 |
40 | Examples:
41 | ---------
42 |
43 | help
44 | help up
45 | help set
46 | help set args
47 | '
48 |
49 | _Dbg_complete_level_1_data[help]='-A_Dbg_help_command_complete'
50 |
51 | typeset -i _Dbg_help_cols=8
52 | _Dbg_do_help() {
53 |
54 | # Treat "help *" the same as help
55 | ((1 == $#)) && [[ "$1" == '*' ]] && shift
56 | if ((0 == $#)) ; then
57 | _Dbg_section 'Available commands:'
58 | typeset -a commands
59 | unsetopt ksharrays
60 | commands=(${(ki)_Dbg_command_help})
61 | typeset -a list
62 | list=(${commands[@]})
63 | setopt ksharrays
64 | _Dbg_list_columns
65 | _Dbg_msg ''
66 | _Dbg_msg 'Readline command line editing (emacs/vi mode) is available.'
67 | _Dbg_msg 'Type "help" followed by command name for full documentation.'
68 | return 0
69 | else
70 | typeset dbg_cmd="$1"
71 | if [[ -n ${_Dbg_command_help[$dbg_cmd]} ]] ; then
72 | _Dbg_msg_rst "${_Dbg_command_help[$dbg_cmd]}"
73 | else
74 | typeset expanded_alias; _Dbg_alias_expand $dbg_cmd
75 | dbg_cmd="$expanded_alias"
76 | if [[ -n ${_Dbg_command_help[$dbg_cmd]} ]] ; then
77 | _Dbg_msg_rst "${_Dbg_command_help[$dbg_cmd]}"
78 | else
79 | case $dbg_cmd in
80 | i | in | inf | info )
81 | _Dbg_help_info $2
82 | return 0
83 | ;;
84 | sh | sho | show )
85 | _Dbg_help_show $2
86 | return 0
87 | ;;
88 | se | set )
89 | _Dbg_help_set $2
90 | return 0
91 | ;;
92 | * )
93 | _Dbg_errmsg "Undefined command: \"$dbg_cmd\". Try \"help\"."
94 | return 0
95 | ;;
96 | esac
97 | fi
98 | fi
99 | aliases_found=''
100 | _Dbg_alias_find_aliased "$dbg_cmd"
101 | if [[ -n $aliases_found ]] ; then
102 | _Dbg_msg ''
103 | _Dbg_msg "Aliases for $dbg_cmd: $aliases_found"
104 | fi
105 | return 0
106 | fi
107 | }
108 |
109 | _Dbg_alias_add '?' help
110 | _Dbg_alias_add 'h' help
111 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # info.sh - gdb-like "info" debugger commands
3 | #
4 | # Copyright (C) 2002-2006, 2008-2009, 2010-2011, 2014
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 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
23 | dirname=${0%/*}
24 | [[ $dirname == $0 ]] && _Dbg_libdir='..' || _Dbg_libdir=${dirname}/..
25 | for lib_file in help alias ; do source $_Dbg_libdir/lib/${lib_file}.sh; done
26 | typeset -A _Dbg_complete_level_1_data
27 | fi
28 |
29 | typeset -A _Dbg_debugger_info_commands
30 | typeset -A _Dbg_command_help_info
31 |
32 | _Dbg_help_add info '' # Help routine is elsewhere
33 |
34 | typeset -a _Dbg_info_subcmds
35 | _Dbg_info_subcmds=( breakpoints display files line program source stack variables )
36 |
37 | # Load in "info" subcommands
38 | for _Dbg_file in ${_Dbg_libdir}/command/info_sub/*.sh ; do
39 | source $_Dbg_file
40 | done
41 | _Dbg_complete_level_1_data[info]=$(echo ${(kM)_Dbg_debugger_info_commands})
42 |
43 | _Dbg_do_info() {
44 | _Dbg_do_info_internal "$@"
45 | return $?
46 | }
47 |
48 | _Dbg_do_info_internal() {
49 | typeset info_cmd="$1"
50 | typeset label=$2
51 |
52 | # Warranty is omitted below.
53 | typeset subcmds='breakpoints display files line source stack variables'
54 |
55 | if [[ -z $info_cmd ]] ; then
56 | typeset thing
57 | for thing in $subcmds ; do
58 | _Dbg_do_info $thing 1
59 | done
60 | return 0
61 | elif [[ -n ${_Dbg_debugger_info_commands[$info_cmd]} ]] ; then
62 | ${_Dbg_debugger_info_commands[$info_cmd]} $label "$@"
63 | return $?
64 | fi
65 |
66 | case $info_cmd in
67 | # a | ar | arg | args )
68 | # _Dbg_do_info_args 3
69 | # return 0
70 | # ;;
71 | # h | ha | han | hand | handl | handle | \
72 | # si | sig | sign | signa | signal | signals )
73 | # _Dbg_info_signals
74 | # return
75 | # ;;
76 |
77 | st | sta | stac | stack )
78 | _Dbg_do_backtrace 1 $@
79 | return 0
80 | ;;
81 |
82 | # te | ter | term | termi | termin | termina | terminal | tt | tty )
83 | # _Dbg_msg "tty: $_Dbg_tty"
84 | # return;
85 | # ;;
86 |
87 | *)
88 | _Dbg_errmsg "Unknown info subcommand: $info_cmd"
89 | _Dbg_errmsg "Info subcommands are:"
90 | typeset -a list; list=(${subcmds[@]})
91 | _Dbg_list_columns ' ' _Dbg_errmsg
92 | return -1
93 | esac
94 | }
95 |
96 | _Dbg_alias_add i info
97 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info_sub/.gitignore:
--------------------------------------------------------------------------------
1 | /*~
2 | /Makefile
3 | /Makefile.in
4 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info_sub/Makefile.am:
--------------------------------------------------------------------------------
1 | MOSTLYCLEANFILES = *.orig *.rej
2 |
3 | pkgdatadir = ${datadir}/@PACKAGE@/command/info_sub
4 | pkgdata_DATA = \
5 | breakpoints.sh \
6 | files.sh \
7 | program.sh \
8 | variables.sh \
9 | warranty.sh
10 |
11 | EXTRA_DIST = $(pkgdata_DATA)
12 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info_sub/breakpoints.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info breakpoints" debugger command
3 | #
4 | # Copyright (C) 2010, 2013-2017 Rocky Bernstein
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; see the file COPYING. If not, write to the Free Software
18 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
19 |
20 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
21 | dirname=${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 | typeset -A _Dbg_command_help_info
25 | typeset -A _Dbg_debugger_info_commands
26 | fi
27 |
28 | _Dbg_help_add_sub info breakpoints \
29 | "**info breakpoints**
30 |
31 | Show status of user-settable breakpoints. If no breakpoint numbers are
32 | given, the show all breakpoints. Otherwise only those breakpoints
33 | listed are shown and the order given.
34 |
35 | The \"Disp\" column contains one of \"keep\", \"del\", the disposition of
36 | the breakpoint after it gets hit.
37 |
38 | The \"enb\" column indicates whether the breakpoint is enabled.
39 |
40 | The \"Where\" column indicates where the breakpoint is located.
41 | Info whether use short filenames
42 |
43 | See also:
44 | ---------
45 |
46 | **break**, **enable**, and **disable**." 1
47 |
48 | _Dbg_info_breakpoints_complete() {
49 | _Dbg_breakpoint_list
50 | }
51 |
52 | typeset -A _Dbg_complete_level_2_data
53 | _Dbg_complete_level_2_data[info_breakpoints]='-a_Dbg_info_breakpoints_complete'
54 |
55 | # list breakpoints and break condition.
56 | # If $1 is given just list those associated for that line.
57 |
58 | _Dbg_do_info_breakpoints() {
59 |
60 | if (( $# >= 3 )) ; then
61 | typeset brkpt_num=$3
62 | if [[ $brkpt_num != [0-9]* ]] ; then
63 | _Dbg_errmsg "Bad breakpoint number $brkpt_num."
64 | elif [[ -z ${_Dbg_brkpt_file[$brkpt_num]} ]] ; then
65 | _Dbg_errmsg "Breakpoint entry $brkpt_num is not set."
66 | else
67 | typeset -r -i i=$brkpt_num
68 | typeset source_file=${_Dbg_brkpt_file[$i]}
69 | source_file=$(_Dbg_adjust_filename "$source_file")
70 | _Dbg_section "Num Type Disp Enb What"
71 | _Dbg_printf "%-3d breakpoint %-4s %-3s %s:%s" $i \
72 | ${_Dbg_keep[${_Dbg_brkpt_onetime[$i]}]} \
73 | ${_Dbg_yn[${_Dbg_brkpt_enable[$i]}]} \
74 | "$source_file" ${_Dbg_brkpt_line[$i]}
75 | if [[ ${_Dbg_brkpt_cond[$i]} != '1' ]] ; then
76 | _Dbg_printf "\tstop only if %s" "${_Dbg_brkpt_cond[$i]}"
77 | fi
78 | _Dbg_print_brkpt_count $i
79 | return 0
80 | fi
81 | return 1
82 | fi
83 |
84 | if (( _Dbg_brkpt_count > 0 )); then
85 | typeset -i i
86 |
87 | _Dbg_section "Num Type Disp Enb What"
88 | for (( i=1; i <= _Dbg_brkpt_max ; i++ )) ; do
89 | source_file="${_Dbg_brkpt_file[$i]}"
90 | if [[ -n ${_Dbg_brkpt_line[$i]} ]] ; then
91 | source_file=$(_Dbg_adjust_filename "$source_file")
92 | _Dbg_printf "%-3d breakpoint %-4s %-3s %s:%d" $i \
93 | ${_Dbg_keep[${_Dbg_brkpt_onetime[$i]}]} \
94 | ${_Dbg_yn[${_Dbg_brkpt_enable[$i]}]} \
95 | "$source_file" ${_Dbg_brkpt_line[$i]}
96 | if [[ ${_Dbg_brkpt_cond[$i]} != '1' ]] ; then
97 | _Dbg_printf "\tstop only if %s" "${_Dbg_brkpt_cond[$i]}"
98 | fi
99 | _Dbg_print_brkpt_count $i
100 | fi
101 | done
102 | else
103 | _Dbg_msg 'No breakpoints have been set.'
104 | fi
105 | }
106 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info_sub/display.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info display" debugger command
3 | #
4 | # Copyright (C) 2010-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 | _Dbg_help_add_sub info display '
22 | **info display**
23 |
24 | Show all display expressions
25 | ' 1
26 |
27 | # List display command(s)
28 | _Dbg_do_info_display() {
29 | if [ ${#_Dbg_disp_exp[@]} != 0 ]; then
30 | typeset i=0
31 | _Dbg_msg "Auto-display statements now in effect:"
32 | _Dbg_msg "Num Enb Expression "
33 | for (( i=0; i < _Dbg_disp_max; i++ )) ; do
34 | if [ -n "${_Dbg_disp_exp[$i]}" ] ;then
35 | _Dbg_printf '%-3d %3d %s' \
36 | $i ${_Dbg_disp_enable[$i]} "${_Dbg_disp_exp[$i]}"
37 | fi
38 | done
39 | else
40 | _Dbg_msg "No display expressions have been set."
41 | fi
42 | return 0
43 | }
44 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info_sub/files.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info files" debugger command
3 | #
4 | # Copyright (C) 2010, 2014 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; 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_sub info files \
21 | 'info files
22 |
23 | show a list of files that have been read in and properties regarding them.
24 | ' 1
25 |
26 | _Dbg_do_info_files() {
27 | _Dbg_msg "Source files which we have recorded info about:"
28 | unsetopt ksharrays
29 | for file in "${(ki)_Dbg_file2canonic}" ; do
30 | typeset -i lines=$(_Dbg_get_maxline "$file")
31 | typeset canonic_file
32 | canonic_file="${_Dbg_file2canonic[$file]}"
33 | if (( _Dbg_set_basename )) ; then
34 | # Do the same with canonic_file ?
35 | file="${file##*/}"
36 | canonic_file="${canonic_file##*/}"
37 | fi
38 | _Dbg_msg " ${file}: ${canonic_file}, $lines lines"
39 | done
40 | setopt ksharrays
41 | return 0
42 | }
43 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info_sub/line.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info line" debugger command
3 | #
4 | # Copyright (C) 2010, 2014, 2016 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; 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_sub info line \
21 | '**info line**
22 |
23 | Show line and filename for stopped position in program.
24 |
25 | See also:
26 | ---------
27 |
28 | **info program**.' 1
29 |
30 | _Dbg_do_info_line() {
31 | if (( ! _Dbg_running )) ; then
32 | _Dbg_errmsg 'No line number information available.'
33 | return 1
34 | fi
35 |
36 | _Dbg_msg "Line $_Dbg_frame_last_lineno of \"$_Dbg_frame_last_filename\""
37 | return 0
38 | }
39 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info_sub/program.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info program" debugger command
3 | #
4 | # Copyright (C) 2010, 2014, 2016 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; 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_sub info program '
21 | **info program**
22 |
23 | Information about debugged program stopping point.
24 |
25 | See also:
26 | ---------
27 |
28 | \"info line\".' 1
29 |
30 | _Dbg_do_info_program() {
31 | if (( _Dbg_running )) ; then
32 | _Dbg_msg 'Program stopped.'
33 | if [[ -n $_Dbg_stop_reason ]] ; then
34 | _Dbg_msg "It stopped ${_Dbg_stop_reason}."
35 | fi
36 | _Dbg_msg "Next statement to be run is:"
37 | _Dbg_print_command
38 | else
39 | _Dbg_errmsg 'The program being debugged is not being run.'
40 | return 1
41 | fi
42 | return 0
43 | }
44 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info_sub/source.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info source" debugger command
3 | #
4 | # Copyright (C) 2010, 2014, 2016 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; 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_sub info source \
21 | '**info source**
22 |
23 | Information about the current source file.
24 |
25 | See also:
26 | ---------
27 |
28 | **info program**, **info file** and **info line**.' 1
29 |
30 | _Dbg_do_info_source() {
31 | if (( ! _Dbg_running )) ; then
32 | _Dbg_errmsg 'No program not running.'
33 | return 1
34 | fi
35 | _Dbg_msg "Current script file is $_Dbg_frame_last_filename"
36 | _Dbg_msg "Located in ${_Dbg_file2canonic[$_Dbg_frame_last_filename]}"
37 | typeset -i max_line
38 | max_line=$(_Dbg_get_maxline $_Dbg_frame_last_filename)
39 | _Dbg_msg "Contains $max_line lines."
40 | return 0
41 | }
42 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info_sub/variables.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "info variables" debugger command
3 | #
4 | # Copyright (C) 2010, 2014, 2016 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; 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_sub info program '
21 | **info variables** [*property*]
22 |
23 | list global and static variable names.
24 |
25 | Variable lists by property.
26 | *property* is one of:
27 |
28 | array, export, fixed, float, function, hash, integer, or readonly
29 |
30 | ' 1
31 |
32 | typeset _Dbg_info_var_attrs="array, export, fixed, float, function, hash, integer, or readonly"
33 | _Dbg_do_info_variables() {
34 | if (($# > 0)) ; then
35 | typeset kind="$1"
36 | shift
37 | case "$kind" in
38 | a | ar | arr | arra | array )
39 | _Dbg_do_list_typeset_attr '+a' $*
40 | return 0
41 | ;;
42 | e | ex | exp | expor | export )
43 | _Dbg_do_list_typeset_attr '+x' $*
44 | return 0
45 | ;;
46 | fu|fun|func|funct|functi|functio|function )
47 | _Dbg_do_list_typeset_attr '+f' $*
48 | return 0
49 | ;;
50 | fi|fix|fixe|fixed )
51 | _Dbg_do_list_typeset_attr '+F' $*
52 | return 0
53 | ;;
54 | fl|flo|floa|float )
55 | _Dbg_do_list_typeset_attr '+E' $*
56 | return 0
57 | ;;
58 | # g | gl | glo | glob | globa | global )
59 | # _Dbg_do_list_globals
60 | # return 0
61 | # ;;
62 | h | ha | has | hash )
63 | _Dbg_do_list_typeset_attr '+A' $*
64 | return 0
65 | ;;
66 | i | in | int| inte | integ | intege | integer )
67 | _Dbg_do_list_typeset_attr '+i' $*
68 | return 0
69 | ;;
70 | # l | lo | loc | loca | local | locals )
71 | # _Dbg_do_list_locals
72 | # return 0
73 | # ;;
74 | r | re | rea| read | reado | readon | readonl | readonly )
75 | _Dbg_do_list_typeset_attr '+r' $*
76 | return 0
77 | ;;
78 | * )
79 | _Dbg_errmsg "Don't know how to list variable type: $kind"
80 | esac
81 | fi
82 | _Dbg_errmsg "Need to specify a variable class which is one of: "
83 | _Dbg_errmsg "$_Dbg_info_var_attrs"
84 | return 1
85 | }
86 |
--------------------------------------------------------------------------------
/zshdb_dir/command/info_sub/warranty.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "info warranty" debugger command
3 | #
4 | # Copyright (C) 2010, 2014, 2016 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; 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_sub info warranty \
21 | '**info warranty**
22 |
23 | Lack of warranty of this debugger.' 1
24 |
25 | _Dbg_do_info_warranty() {
26 | _Dbg_msg "
27 | NO WARRANTY
28 |
29 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
30 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
31 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
32 | PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
33 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
35 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
36 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
37 | REPAIR OR CORRECTION.
38 |
39 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
40 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
41 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
42 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
43 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
44 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
45 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
46 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
47 | POSSIBILITY OF SUCH DAMAGES.
48 | "
49 | return 0
50 | }
51 |
--------------------------------------------------------------------------------
/zshdb_dir/command/kill.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "kill" debugger command
3 | #
4 | # Copyright (C) 2002-2006, 2008-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 kill \
22 | "**kill** [*signal-number*]
23 |
24 | Send this process a POSIX signal ('9' for 'SIGKILL' or 'kill -SIGKILL')
25 |
26 | 9 is a non-maskable interrupt that terminates the program. If program is threaded it may
27 | be expedient to use this command to terminate the program.
28 |
29 | However other signals, such as those that allow for the debugged to handle them can be
30 | sent.
31 |
32 | Giving a negative number is the same as using its positive value.
33 |
34 | Examples:
35 | ---------
36 |
37 | kill # non-interuptable, nonmaskable kill
38 | kill 9 # same as above
39 | kill -9 # same as above
40 | kill 15 # nicer, maskable TERM signal
41 | kill! 15 # same as above, but no confirmation
42 |
43 | See also:
44 | ---------
45 |
46 | **quit** for less a forceful termination command.
47 | **run** is a way to restart the debugged program."
48 |
49 | _Dbg_do_kill() {
50 | if (($# > 1)); then
51 | _Dbg_errmsg "Got $# parameters, but need 0 or 1."
52 | return 0
53 | # return 1
54 | fi
55 | typeset _Dbg_prompt_output=${_Dbg_tty:-/dev/null}
56 | typeset signal='-9'
57 | (($# == 1)) && signal="$1"
58 |
59 | if [[ ${signal[0,0]} != '-' ]] ; then
60 | _Dbg_errmsg "Kill signal ($signal) should start with a '-'"
61 | return 0
62 | # return 2
63 | fi
64 |
65 | typeset _Dbg_response
66 | _Dbg_confirm "Send kill signal ${signal} which may terminate the debugger? (y/N): " 'N'
67 |
68 | if [[ $_Dbg_response == [yY] ]] ; then
69 | case $signal in
70 | -9 | -SEGV )
71 | _Dbg_cleanup2
72 | ;;
73 | esac
74 | kill $signal $$
75 | else
76 | _Dbg_msg "Kill not done - not confirmed."
77 | return 0
78 | # return 3
79 | fi
80 | return 0
81 | }
82 |
--------------------------------------------------------------------------------
/zshdb_dir/command/next.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "next" (step through) commmand.
3 | #
4 | # Copyright (C) 2008, 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 | # 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.
29 |
30 | If *count* is given, stepping occurs that many times before
31 | stopping. Otherwise *count* is one. *count* an be an arithmetic
32 | expression.
33 |
34 | Functions and source'd files are not traced. This is in contrast to
35 | **step**.
36 |
37 | See also:
38 | ---------
39 |
40 | **skip**." 1
41 |
42 | # Next command
43 | # $1 is command next+, next-, or next
44 | # $2 is an optional additional count.
45 | _Dbg_do_next() {
46 |
47 | _Dbg_not_running && return 1
48 |
49 | _Dbg_last_cmd="$_Dbg_cmd"
50 | _Dbg_last_next_step_cmd="$_Dbg_cmd"
51 | _Dbg_last_next_step_args="$@"
52 |
53 | typeset count=${1:-1}
54 |
55 | case "${_Dbg_last_next_step_cmd[-1,-1]}" in
56 | '+' ) _Dbg_step_force=1 ;;
57 | '-' ) _Dbg_step_force=0 ;;
58 | '' ) _Dbg_step_force=$_Dbg_set_different ;;
59 | * ) ;;
60 | esac
61 |
62 | if [[ $count == [0-9]* ]] ; then
63 | _Dbg_step_ignore=${count:-1}
64 | else
65 | _Dbg_errmsg "Argument ($count) should be a number or nothing."
66 | _Dbg_step_ignore=1
67 | return 0
68 | fi
69 |
70 | _Dbg_write_journal_eval "_Dbg_return_level=${#_Dbg_frame_stack[@]}"
71 | _Dbg_write_journal "_Dbg_step_ignore=$_Dbg_step_ignore"
72 | _Dbg_write_journal "_Dbg_step_force=$_Dbg_step_force"
73 | _Dbg_continue_rc=0
74 | return 0
75 | }
76 |
77 | _Dbg_alias_add 'n' 'next'
78 |
--------------------------------------------------------------------------------
/zshdb_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 |
--------------------------------------------------------------------------------
/zshdb_dir/command/quit.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # quit.sh - gdb-like "quit" debugger command
3 | #
4 | # Copyright (C) 2008, 2010-2011, 2014, 2018 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 quit \
22 | '**quit** [*exit-code* [*shell-levels*]]
23 |
24 | Quit the debugger.
25 |
26 | The program being debugged is aborted. If *exit-code* is given, then
27 | that will be the exit return code. If *shell-levels* is given, then up
28 | to that many nested shells are quit. However to be effective, the last
29 | of those shells should have been run under the debugger.
30 |
31 | See also:
32 | ---------
33 |
34 | **finish**, **return** and **run**.'
35 |
36 | _Dbg_do_quit() {
37 | typeset -i return_code=${1:-$_Dbg_program_exit_code}
38 |
39 | typeset -i desired_quit_levels=${2:-0}
40 |
41 | if [[ $desired_quit_levels != [0-9]* ]] ; then
42 | _Dbg_errmsg "Argument ($desired_quit_levels) should be a number or nothing."
43 | return 0
44 | fi
45 |
46 | if (( desired_quit_levels == 0 \
47 | || desired_quit_levels > ZSH_SUBSHELL+1)) ; then
48 | ((desired_quit_levels=ZSH_SUBSHELL+1))
49 | fi
50 |
51 | ((_Dbg_QUIT_LEVELS+=desired_quit_levels))
52 |
53 | # Reduce the number of recorded levels that we need to leave by
54 | # if _Dbg_QUIT_LEVELS is greater than 0.
55 | ((_Dbg_QUIT_LEVELS--))
56 |
57 | ## write this to the next level up can read it.
58 | _Dbg_write_journal "_Dbg_QUIT_LEVELS=$_Dbg_QUIT_LEVELS"
59 | _Dbg_write_journal "_Dbg_step_ignore=$_Dbg_step_ignore"
60 |
61 | # Reset signal handlers to their default but only if
62 | # we are not in a subshell.
63 | if (( ZSH_SUBSHELL == 0 )) ; then
64 |
65 | # If we were told to restart from deep down, restart instead of quit.
66 | if [ -n "$_Dbg_RESTART_COMMAND" ] ; then
67 | _Dbg_erase_journals
68 | _Dbg_save_state
69 | exec $_Dbg_RESTART_COMMAND
70 | fi
71 |
72 | _Dbg_msg "${_Dbg_debugger_name}: That's all, folks..."
73 | # Get the last command into the history
74 | # set -o incappendhistory
75 | print -s -- $_Dbg_orig_cmd >/dev/null
76 | _Dbg_cleanup
77 | fi
78 |
79 | # And just when you thought we'd never get around to it...
80 | exit $return_code
81 | }
82 | _Dbg_alias_add q quit
83 | _Dbg_alias_add q! quit
84 | _Dbg_alias_add exit quit
85 |
--------------------------------------------------------------------------------
/zshdb_dir/command/return.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # return command.
3 | #
4 | # Copyright (C) 2008, 2010, 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 return \
22 | '**return** [*return-value*]
23 |
24 | Force an immediate return from a function.
25 |
26 | The remainder of function will not be executed. If *return-value* is given,
27 | it should be an integer and will be the return value passed back as
28 | $?.
29 |
30 | See also:
31 | ---------
32 |
33 | **finish**, **quit**, and **run**.
34 | '
35 |
36 | # Return value when a return is taken.
37 | typeset -i _Dbg_return_rc=0
38 |
39 | _Dbg_do_return() {
40 | rc=${1:-0}
41 |
42 | if [[ $_Dbg_return_rc == [0-9]* ]] ; then
43 | _Dbg_return_rc=$rc
44 | else
45 | _Dbg_errmsg "Argument ($rc) should be a number or nothing."
46 | _Dbg_skip_ignore=0
47 | return 0
48 | fi
49 |
50 | _Dbg_write_journal_eval "_Dbg_step_ignore=1"
51 | _Dbg_last_cmd='return'
52 | _Dbg_continue_rc 255
53 | return 0
54 | }
55 |
--------------------------------------------------------------------------------
/zshdb_dir/command/run.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # run command.
3 | #
4 | # Copyright (C) 2008-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 | # Restart script in same way with saved arguments (probably the same
22 | # ones as we were given before).
23 |
24 | _Dbg_help_add run \
25 | '**run** [*args*]
26 |
27 | Attempt to restart the program.
28 |
29 | See also:
30 | ---------
31 |
32 | **set args**, **kill** and **quit**'
33 |
34 | _Dbg_do_run() {
35 |
36 | typeset script_args
37 | typeset exec_cmd
38 | if (( $# == 0 )) ; then
39 | script_args=${_Dbg_script_args[@]}
40 | typeset SH_RUN_CMDLINE; _Dbg_run_cmdline
41 | if [[ -n $SH_RUN_CMDLINE ]] ; then
42 | exec_cmd="$SH_RUN_CMDLINE";
43 | else
44 | exec_cmd="$_Dbg_script_file"
45 | [[ -n $script_args ]] && exec_cmd+=" $script_args"
46 | fi
47 | else
48 | exec_cmd="$_Dbg_script_file"
49 | script_args=$@
50 | [[ -n $script_args ]] && exec_cmd+=" $script_args"
51 | fi
52 |
53 | if (( !_Dbg_script )); then
54 | # if [[ $_cur_source_file == $_Dbg_bogus_file ]] ; then
55 | # script_args="--debugger -c \"$SH_EXECUTION_STRING\""
56 | # exec_cmd="$SH_RUN_CMDLINE --debugger -c \"$SH_EXECUTION_STRING\"";
57 | # else
58 | # exec_cmd="$SH_RUN_CMDLINE --debugger $_Dbg_orig_0 $script_args";
59 | # fi
60 | :
61 | fi
62 |
63 | if (( _Dbg_set_basename )) ; then
64 | _Dbg_msg "Restarting with: $script_args"
65 | else
66 | _Dbg_msg "Restarting with: $exec_cmd"
67 | fi
68 |
69 | # If we are in a subshell we need to get out of those levels
70 | # first before we restart. The strategy is to write into persistent
71 | # storage the restart command, and issue a "quit." The quit should
72 | # discover the restart at the last minute and issue the restart.
73 | if (( ZSH_SUBSHELL > 0 )) ; then
74 | _Dbg_msg "Note you are in a subshell. We will need to leave that first."
75 | _Dbg_write_journal "_Dbg_RESTART_COMMAND=\"$exec_cmd\""
76 | _Dbg_do_quit 0
77 | fi
78 | _Dbg_save_state
79 |
80 | builtin cd $_Dbg_init_cwd
81 |
82 | _Dbg_cleanup
83 | eval "exec $exec_cmd"
84 | }
85 |
86 | _Dbg_alias_add R run
87 | _Dbg_alias_add restart run
88 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # set.sh - debugger settings
3 | #
4 | # Copyright (C) 2008, 2010-2011, 2014 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 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 | # Sets whether or not to display command to be executed in debugger prompt.
21 | # If yes, always show. If auto, show only if the same line is to be run
22 | # but the command is different.
23 |
24 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
25 | dirname=${0%/*}
26 | [[ $dirname == $0 ]] && _Dbg_libdir='..' || _Dbg_libdir=${dirname}/..
27 | for lib_file in help alias ; do source $_Dbg_libdir/lib/${lib_file}.sh; done
28 | typeset -A _Dbg_complete_level_1_data
29 | fi
30 |
31 | typeset -A _Dbg_debugger_info_commands
32 | typeset -i _Dbg_set_linewidth; _Dbg_set_linewidth=${COLUMNS:-80}
33 | typeset -i _Dbg_linetrace_expand=0 # expand variables in linetrace output
34 | typeset _Dbg_linetrace_delay=1 # sleep after linetrace
35 |
36 | typeset -A _Dbg_debugger_set_commands
37 | typeset -A _Dbg_command_help_set
38 |
39 | typeset -i _Dbg_set_autoeval=0 # Evaluate unrecognized commands?
40 | typeset -i _Dbg_set_listsize=10 # How many lines in a listing?
41 |
42 | _Dbg_help_add set '' # Help routine is elsewhere
43 |
44 | # Load in "set" subcommands
45 | for _Dbg_file in ${_Dbg_libdir}/command/set_sub/*.sh ; do
46 | source "$_Dbg_file"
47 | done
48 | _Dbg_complete_level_1_data[set]=$(echo ${(kM)_Dbg_debugger_set_commands})
49 |
50 | _Dbg_do_set() {
51 | _Dbg_do_set_internal "$@"
52 | return $?
53 | }
54 |
55 | _Dbg_do_set_internal() {
56 | typeset set_cmd="$1"
57 | typeset rc
58 | if [[ $set_cmd == '' ]] ; then
59 | _Dbg_msg "Argument required (expression to compute)."
60 | return;
61 | fi
62 | _Dbg_last_cmd='set'
63 | shift
64 |
65 | if [[ -n ${_Dbg_debugger_set_commands[$set_cmd]} ]] ; then
66 | ${_Dbg_debugger_set_commands[$set_cmd]} $label "$@"
67 | return $?
68 | fi
69 |
70 | case $set_cmd in
71 | force | dif | diff | differ | different )
72 | _Dbg_set_onoff "$1" 'different'
73 | ;;
74 | inferior-tty )
75 | _Dbg_set_tty "$@"
76 | ;;
77 | lo | log | logg | loggi | loggin | logging )
78 | _Dbg_cmd_set_logging $@
79 | ;;
80 | t|tr|tra|trac|trace|trace-|trace-c|trace-co|trace-com|trace-comm|trace-comma|trace-comman|trace-command|trace-commands )
81 | _Dbg_do_set_trace_commands $@
82 | ;;
83 | *)
84 | _Dbg_undefined_cmd "set" "$set_cmd"
85 | return -1
86 | esac
87 | return $?
88 | }
89 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/.gitignore:
--------------------------------------------------------------------------------
1 | /*~
2 | /Makefile
3 | /Makefile.in
4 |
5 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/Makefile.am:
--------------------------------------------------------------------------------
1 | MOSTLYCLEANFILES = *.orig *.rej
2 |
3 | pkgdatadir = ${datadir}/@PACKAGE@/command/set_sub
4 | pkgdata_DATA = $(wildcard *.sh)
5 |
6 | EXTRA_DIST = $(pkgdata_DATA)
7 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/annotate.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set annotate" debugger command
3 | #
4 | # Copyright (C) 2010-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 [[ 0 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[set_annotate]='0 1'
31 |
32 | _Dbg_help_add_sub set annotate \
33 | '**set annotate** {**0**|**1**}
34 |
35 | Set annotation level.
36 |
37 | 0 - normal
38 | 1 - fullname (for use when running under emacs).
39 |
40 | See also:
41 | ---------
42 |
43 | **show annotate**
44 | '
45 |
46 | _Dbg_do_set_annotate() {
47 | if (( $# == 0 )) ; then
48 | _Dbg_msg "Argument required (an integer to set 'annotate' to.)."
49 | elif [[ "$1" == [0-9]* ]] ; then
50 | if (( $1 > 3 || $1 < 0)); then
51 | _Dbg_msg "Annotation level must be between 0 and 3. Got: ${1}."
52 | else
53 | _Dbg_write_journal_eval "_Dbg_set_annotate=$1"
54 | fi
55 | else
56 | _Dbg_errmsg "Integer argument expected; got: $1"
57 | return -1
58 | fi
59 | return 0
60 | }
61 |
--------------------------------------------------------------------------------
/zshdb_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 |
27 | _Dbg_do_set_args() {
28 | # We use the loop below rather than _Dbg_set_args="(@)" because
29 | # we want to preserve embedded blanks in the arguments.
30 | _Dbg_script_args=()
31 | typeset -i i
32 | typeset -i n=$#
33 | 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 [[ 0 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[set_autoeval]='on off'
31 |
32 | _Dbg_help_add_sub set autoeval \
33 | '**set autoeval** [**on**|**off**]
34 |
35 | Evaluate unrecognized debugger commands.
36 |
37 | Often inside the debugger, one would like to be able to run arbitrary
38 | Python commands without having to preface Python expressions with
39 | ``print`` or ``eval``. Setting *autoeval* on will cause unrecognized
40 | debugger commands to be *eval* as a Python expression.
41 |
42 | Note that if this is set, on error the message shown on type a bad
43 | debugger command changes from:
44 |
45 | Undefined command: "fdafds". Try "help".
46 |
47 | to something more zsh-eval-specific such as:
48 |
49 | /tmp/zshdb_eval_26397:2: command not found: fdafds
50 |
51 |
52 | See also:
53 | ---------
54 |
55 | **show autoeval**
56 | '
57 |
58 |
59 | _Dbg_do_set_autoeval() {
60 | _Dbg_set_onoff "$1" 'autoeval'
61 | return $?
62 | }
63 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/autolist.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set autolist" debugger command
3 | #
4 | # Copyright (C) 2010-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 [[ 0 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[set_autolist]='on off'
31 |
32 | _Dbg_help_add_sub set autolist \
33 | '**set autolist** [**on**|**off**]
34 |
35 | Run list command automatically every time the debugger enters
36 |
37 | See also:
38 | ---------
39 |
40 | **show autolist**
41 | '
42 |
43 | _Dbg_do_set_autolist() {
44 | typeset onoff=${1:-'off'}
45 | case $onoff in
46 | on | 1 )
47 | _Dbg_write_journal_eval "_Dbg_cmdloop_hooks[\"list\"]=_Dbg_do_list"
48 | ;;
49 | off | 0 )
50 | _Dbg_write_journal_eval "unset '_Dbg_cmdloop_hooks[\"list\"]'"
51 | unset '_Dbg_cmdloop_hooks[\"list\"]'
52 | ;;
53 | * )
54 | _Dbg_errmsg "\"on\" or \"off\" expected."
55 | return 1
56 | esac
57 | _Dbg_do_show 'autolist'
58 | return 0
59 | }
60 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/basename.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set basename" 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 [[ 0 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[set_basename]='on off'
31 |
32 | _Dbg_help_add_sub set basename \
33 | '**set basename** [**on**|**off**]
34 |
35 | Set short filenames (the basename) in debug output
36 |
37 | See also:
38 | ---------
39 |
40 | **show basename**
41 | '
42 |
43 | _Dbg_do_set_basename() {
44 | _Dbg_set_onoff "$1" 'basename'
45 | return $?
46 | }
47 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/debug.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set debug" debugger command
3 | #
4 | # Copyright (C) 2011, 2014 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 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[set_debug]='on off'
31 |
32 | _Dbg_help_add_sub set debug \
33 | 'Set debug the debugger' 1
34 |
35 | _Dbg_do_set_debug() {
36 | _Dbg_set_onoff "$1" 'debug'
37 | return $?
38 | }
39 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/different.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set different" 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 [[ 0 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[set_different]='on off'
31 |
32 | _Dbg_help_add_sub set different \
33 | '**set different** [**off**|**on**]
34 |
35 | Set to stop at a different line
36 |
37 | See also:
38 | ---------
39 |
40 | **show different**'
41 |
42 | _Dbg_do_set_different() {
43 | _Dbg_set_onoff "$1" 'different'
44 | return $?
45 | }
46 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/editing.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set editing" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2014 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 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[set_editing]='emacs on off vi'
31 |
32 | _Dbg_help_add_sub set editing \
33 | '**set editing** [**on**|**off**]
34 |
35 | Readline editing of command lines
36 |
37 | See also:
38 | ---------
39 |
40 | **show editing**
41 | '
42 |
43 | _Dbg_do_set_editing() {
44 | typeset onoff=${1:-'on'}
45 | case $onoff in
46 | e | em | ema | emac | emacs )
47 | _Dbg_edit='-e'
48 | _Dbg_edit_style='emacs'
49 | builtin bindkey -e
50 | ;;
51 | on | 1 )
52 | _Dbg_edit='-e'
53 | _Dbg_edit_style='emacs'
54 | builtin bindkey -e
55 | ;;
56 | off | 0 )
57 | _Dbg_edit=''
58 | return 0
59 | ;;
60 | v | vi )
61 | _Dbg_edit='-e'
62 | _Dbg_edit_style='vi'
63 | builtin bindkey -v
64 | ;;
65 | * )
66 | _Dbg_errmsg '"on", "off", "vi", or "emacs" expected.'
67 | return 1
68 | esac
69 | return 0
70 | }
71 |
--------------------------------------------------------------------------------
/zshdb_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 [[ 0 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[set_highlight]='dark light off reset'
31 |
32 | _Dbg_help_add_sub set highlight \
33 | '
34 | **set** **highlight** [**dark**|**light**|**off**|**reset**]
35 |
36 | Set using terminal highlight.
37 |
38 | Use **reset** to set highlighting on and force a redo of syntax
39 | highlighting of already cached files. This may be needed if the
40 | debugger was started without syntax highlighting initially.
41 |
42 | **dark** sets sets for highlighting for a terminal with a dark background and
43 | **light** set for highlighting for a terminal with a light background.
44 |
45 | See also:
46 | ---------
47 |
48 | **show highlight**.
49 | '
50 |
51 | _Dbg_do_set_highlight() {
52 | if ( pygmentize --version || pygmentize -V ) 2>/dev/null 1>/dev/null ; then
53 | :
54 | else
55 | _Dbg_errmsg "Can't run pygmentize. 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 | ;;
73 | reset )
74 | [[ -z $_Dbg_set_highlight ]] && _Dbg_set_highlight='light'
75 | _Dbg_filecache_reset
76 | _Dbg_readin $_Dbg_frame_last_filename
77 | ;;
78 | * )
79 | _Dbg_errmsg '"dark", "light", "off", or "reset" expected.'
80 | return 1
81 | esac
82 | _Dbg_do_show highlight
83 | return 0
84 | }
85 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/history.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set history" debugger command
3 | #
4 | # Copyright (C) 2010-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 [[ 0 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[set_history]='filename save size'
31 |
32 | _Dbg_help_add_sub set history \
33 | '**set history save** [**on**|**off**]
34 |
35 | **set history size** *num*
36 |
37 | **set history filename** *path*
38 |
39 | In the first form, set whether to save history.
40 | This only works if the debugger or zsh was started in interactive
41 | mode, option --interactive or -i
42 |
43 | In the second form, how many history lines to save is indicated.
44 |
45 | In the third form, the place to store the history file is given.
46 | '
47 |
48 | _Dbg_do_set_history() {
49 | case "$1" in
50 | sa | sav | save )
51 | typeset onoff=${2:-'on'}
52 | if [[ onoff == 'on' ]] && ! setopt | grep interactive 2>&1 >/dev/null; then
53 | _Dbg_errmsg "zsh was not started interactively, can't save history"
54 | _Dbg_set_history=0
55 | return -1
56 | fi
57 | _Dbg_set_onoff $onoff 'history'
58 |
59 | ;;
60 | si | siz | size )
61 | if [[ -z $2 ]] ; then
62 | _Dbg_errmsg "Argument required (integer to set it to.)."
63 | elif [[ $2 != [0-9]* ]] ; then
64 | _Dbg_errmsg "Integer argument expected; got: $2"
65 | return -1
66 | fi
67 | _Dbg_write_journal_eval "_Dbg_history_size=$2"
68 | ;;
69 | file | filename )
70 | # TODO: check validity of filename
71 | _Dbg_write_journal_eval "_Dbg_histfile=$2"
72 | ;;
73 | *)
74 | _Dbg_errmsg "\"filename\", \"save\", or \"size\" expected."
75 | return -1
76 | ;;
77 | esac
78 | return 0
79 | }
80 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/linetrace.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set linetrace" debugger command
3 | #
4 | # Copyright (C) 2010, 2014, 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 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[set_linetrace]='on off delay expand'
31 |
32 | _Dbg_help_add_sub set linetrace \
33 | '**set linetrace** [**on**|**off**]
34 |
35 | Set xtrace-style line tracing
36 |
37 | See also:
38 | ---------
39 |
40 | **show linetrace**
41 | '
42 |
43 | _Dbg_do_set_linetrace() {
44 | typeset onoff=${1:-'off'}
45 | case $onoff in
46 | on | 1 )
47 | _Dbg_write_journal_eval "_Dbg_set_linetrace=1"
48 | ;;
49 | off | 0 )
50 | _Dbg_write_journal_eval "_Dbg_set_linetrace=0"
51 | ;;
52 | d | de | del | dela | delay )
53 | if [[ $2 != [0-9]* ]] ; then
54 | _Dbg_errmsg "Bad integer parameter: $2"
55 | return 1
56 | fi
57 | eval "$_resteglob"
58 | _Dbg_write_journal_eval "_Dbg_linetrace_delay=$2"
59 | ;;
60 | e | ex | exp | expa | expan | expand )
61 | typeset onoff=${2:-'on'}
62 | case $onoff in
63 | on | 1 )
64 | _Dbg_write_journal_eval "_Dbg_linetrace_expand=1"
65 | ;;
66 | off | 0 )
67 | _Dbg_write_journal_eval "_Dbg_linetrace_expand=0"
68 | ;;
69 | * )
70 | _Dbg_errmsg "\"expand\", \"on\" or \"off\" expected."
71 | return 1
72 | ;;
73 | esac
74 | ;;
75 |
76 | * )
77 | _Dbg_msg "\"expand\", \"on\" or \"off\" expected."
78 | return 1
79 | esac
80 | return 0
81 | }
82 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/listsize.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set listsize" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2014 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 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 |
30 | _Dbg_help_add_sub set listsize \
31 | '**set listsize** *number-of-lines*
32 |
33 | Set the number of source lines debugger will list by default.
34 |
35 | See also:
36 | ---------
37 |
38 | **show listsize**
39 | '
40 |
41 | _Dbg_do_set_listsize() {
42 | if [[ $1 == [0-9]* ]] ; then
43 | _Dbg_write_journal_eval "_Dbg_set_listsize=$1"
44 | else
45 | _Dbg_errmsg "Integer argument expected; got: $1"
46 | return -1
47 | fi
48 | return 0
49 | }
50 |
--------------------------------------------------------------------------------
/zshdb_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-template*]
23 |
24 | Set debugger prompt string' 1
25 |
26 | _Dbg_do_set_prompt() {
27 | _Dbg_prompt_str="$1"
28 | return $?
29 | }
30 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/showcommand.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set showcommand" debugger command
3 | #
4 | # Copyright (C) 2010, 2014 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 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | typeset -A _Dbg_complete_level_2_data
28 | fi
29 |
30 | _Dbg_help_add_sub set showcommand \
31 | 'Set showing the command to execute' 1
32 |
33 | # Sets whether or not to display command to be executed in debugger prompt.
34 | # If yes, always show. If auto, show only if the same line is to be run
35 | # but the command is different.
36 | typeset _Dbg_set_show_command="auto"
37 |
38 | _Dbg_complete_level_2_data[set_showcommand]='on off auto'
39 |
40 | _Dbg_do_set_showcommand() {
41 | case "$1" in
42 | 1 )
43 | _Dbg_write_journal_eval "_Dbg_set_show_command=on"
44 | ;;
45 | 0 )
46 | _Dbg_write_journal_eval "_Dbg_set_show_command=off"
47 | ;;
48 | on | off | auto )
49 | _Dbg_write_journal_eval "_Dbg_set_show_command=$1"
50 | ;;
51 | * )
52 | _Dbg_errmsg "\"on\", \"off\" or \"auto\" expected."
53 | esac
54 | return 0
55 | }
56 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/style.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set style" debugger command
3 | #
4 | # Copyright (C) 2016-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 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -x _Dbg_pygments_styles=''
30 |
31 | if (( _Dbg_working_term_highlight )) ; then
32 | _Dbg_pygments_styles=$(${_Dbg_libdir}/lib/term-highlight.py -L)
33 | fi
34 |
35 | typeset -A _Dbg_complete_level_2_data
36 | _Dbg_complete_level_2_data[set_style]="$_Dbg_pygments_styles off"
37 |
38 | _Dbg_help_add_sub set style \
39 | '
40 | **set** **style** [*pygments-style* | **off**]
41 |
42 | Set the pygments style use in souce-code listings to *pygments-style* or
43 | remove any pygments formatting if *pygments-style* is **off**.
44 |
45 | See also:
46 | ---------
47 |
48 | See also: **set highlight**, **show style**, and **show highlight**.
49 | '
50 |
51 |
52 | _Dbg_list_styles() {
53 | typeset -a list=( $_Dbg_pygments_styles )
54 | _Dbg_msg "Valid styles are:"
55 | _Dbg_list_columns ' ' _Dbg_msg
56 | }
57 |
58 |
59 | _Dbg_do_set_style() {
60 | if (( ! _Dbg_working_term_highlight )) ; then
61 | _Dbg_errmsg "Can't run term-highlight. Setting forced off"
62 | return 1
63 | fi
64 | if (( $# == 0 )) ; then
65 | _Dbg_list_styles
66 | else
67 | style=$1
68 | if [[ "${style}" == "off" ]] ; then
69 | _Dbg_set_style=''
70 | _Dbg_filecache_reset
71 | _Dbg_readin $_Dbg_frame_last_filename
72 | _Dbg_do_show style
73 | elif [[ "${_Dbg_pygments_styles#*$style}" != "$_Dbg_pygments_styles" ]] ; then
74 | _Dbg_set_style=$style
75 | _Dbg_filecache_reset
76 | _Dbg_readin $_Dbg_frame_last_filename
77 | _Dbg_do_show style
78 | else
79 | _Dbg_errmsg "Can't find style $style"
80 | _Dbg_list_styles
81 | fi
82 | fi
83 |
84 | return 0
85 | }
86 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/trace-commands.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set trace-commands" debugger command
3 | #
4 | # Copyright (C) 2010-2011, 2014 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 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | typeset -A _Dbg_command_help_set
26 | typeset -A _Dbg_debugger_set_commands
27 | fi
28 |
29 | typeset -A _Dbg_complete_level_2_data
30 | _Dbg_complete_level_2_data[trace-commands]='on off'
31 |
32 | # Sets whether or not to display command before executing it.
33 | typeset _Dbg_set_trace_commands='off'
34 |
35 | # Handled special because of the dash in the command name.
36 | # _Dbg_help_add_sub set trace-commands \
37 | # 'Set showing debugger commands' 1
38 |
39 | _Dbg_do_set_trace_commands() {
40 | case "$1" in
41 | 1 )
42 | _Dbg_write_journal_eval "_Dbg_set_trace_commands=on"
43 | ;;
44 | 0 )
45 | _Dbg_write_journal_eval "_Dbg_set_trace_commands=off"
46 | ;;
47 | on | off )
48 | _Dbg_write_journal_eval "_Dbg_set_trace_commands=$1"
49 | ;;
50 | * )
51 | _Dbg_errmsg "\"on\", \"off\" expected."
52 | return 1
53 | esac
54 | return $?
55 | }
56 |
--------------------------------------------------------------------------------
/zshdb_dir/command/set_sub/width.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "set width" 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 width \
22 | '**set** **width** *width*
23 |
24 | Set maximum width of lines to *width*.'
25 |
26 | _Dbg_do_set_width() {
27 | if [[ $1 == [0-9]* ]] ; then
28 | _Dbg_write_journal_eval "_Dbg_set_linewidth=$1"
29 | else
30 | _Dbg_errmsg "Integer argument expected; got: $1"
31 | return 1
32 | fi
33 | return 0
34 | }
35 |
--------------------------------------------------------------------------------
/zshdb_dir/command/shell.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Enter nested shell
3 | #
4 | # Copyright (C) 2011, 2014, 2016, 2018 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_restore_info="${_Dbg_tmpdir}/${_Dbg_debugger_name}_restore_$$"
22 |
23 | _Dbg_help_add shell \
24 | "**shell** [*options*]
25 |
26 | Options:
27 | --------
28 |
29 | --no-fns | -F : don't copy in function definitions from parent shell
30 | --no-vars | -V : don't copy in variable definitions
31 | --shell SHELL_NAME
32 | --posix : corresponding shell option
33 | --login | l : corresponding shell option
34 | --noprofile : corresponding shell option
35 | --norc : corresponding shell option
36 |
37 | Enter a nested shell, not a subshell. Before entering the shell
38 | current variable definitions and function definitions are stored in
39 | profile $_Dbg_shell_temp_profile. which is is read in via the
40 | **--init-file** option.
41 |
42 | If you don't want variable definitions to be set, use option **-V** or
43 | **--no-vars**. If you don't want function definitions to be set, use
44 | option **-F** or **--no-fns**. There are several corresponding shell
45 | options. Many of these by nature defeate reading on saved functions
46 | and variables.
47 |
48 | The shell that used is taken from the shell used to build the debugger
49 | which is: $_Dbg_shell_name. Use **--shell** to use a different
50 | compatible shell.
51 |
52 | By default, variables set or changed in the shell do not persist after
53 | the shell is left to to back to the debugger or debugged program.
54 |
55 | However you can tag variables to persist by running the function
56 | 'save_vars' which takes a list of variable names. You can run this
57 | as many times as you want with as many variable names as you want.
58 |
59 | For example:
60 | save_vars PROFILE PARSER
61 | marks variable PROFILE and PARSER to be examined and their values used
62 | in the trap EXIT of the shell.
63 | "
64 |
65 | _Dbg_parse_shell_cmd_options() {
66 | OPTLIND=''
67 | while getopts_long lFV opt \
68 | no-fns 0 \
69 | login no_argument \
70 | shell required_argument \
71 | no-vars 0 \
72 | '' $@
73 | do
74 | case "$opt" in
75 | F | no-fns )
76 | _Dbg_o_fns=0;;
77 | V | no-vars )
78 | _Dbg_o_vars=0;;
79 | shell )
80 | shell=$OPTARG;;
81 | norc | posix | restricted | login | l | noediting | noprofile )
82 | _Dbg_shell_opts+="--$opt"
83 | ;;
84 | * )
85 | return 1
86 | ;;
87 | esac
88 | done
89 | return 0
90 | }
91 |
92 |
93 | _Dbg_do_shell() {
94 | typeset -i _Dbg_o_fns; _Dbg_o_fns=1
95 | typeset -i _Dbg_o_vars; _Dbg_o_vars=1
96 | typeset _Dbg_shell_opts=''
97 | typeset shell=$_Dbg_shell
98 |
99 | if (($# != 0)); then
100 | _Dbg_parse_shell_cmd_options $@
101 | (( $? != 0 )) && return
102 | fi
103 |
104 | typeset -i _Dbg_rc
105 | _Dbg_shell_new_shell_profile $_Dbg_o_vars _$Dbg_o_fns
106 |
107 | # Set prompt in new shell
108 | echo "PS1='${_Dbg_debugger_name} $ '" >>$_Dbg_shell_temp_profile
109 | ZDOTDIR=$_Dbg_tmpdir $shell -o TYPESET_SILENT $shell_opts
110 | rc=$?
111 | _Dbg_restore_from_nested_shell
112 | # FIXME: put in _Dbg_restore_from_nested_shell
113 | (( 1 == _Dbg_running )) && _Dbg_print_location_and_command
114 | }
115 |
116 | _Dbg_alias_add sh shell
117 | _Dbg_alias_add zsh shell
118 |
--------------------------------------------------------------------------------
/zshdb_dir/command/show_sub/.gitignore:
--------------------------------------------------------------------------------
1 | /*~
2 | /Makefile
3 | /Makefile.in
4 |
5 |
--------------------------------------------------------------------------------
/zshdb_dir/command/show_sub/Makefile.am:
--------------------------------------------------------------------------------
1 | MOSTLYCLEANFILES = *.orig *.rej
2 |
3 | pkgdatadir = ${datadir}/@PACKAGE@/command/show_sub
4 | pkgdata_DATA = $(wildcard *.sh)
5 |
6 | EXTRA_DIST = $(pkgdata_DATA)
7 |
--------------------------------------------------------------------------------
/zshdb_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_do_show_alias() {
28 | unsetopt ksharrays
29 | typeset -a list
30 | list=()
31 | for alias in ${(ki)_Dbg_aliases} ; do
32 | list+=("${alias}: ${_Dbg_aliases[$alias]}")
33 | done
34 | setopt ksharrays
35 | _Dbg_list_columns ' | '
36 | return 0
37 | }
38 |
--------------------------------------------------------------------------------
/zshdb_dir/command/show_sub/basename.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show basename" debugger command
3 | #
4 | # Copyright (C) 2014 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 basename \
22 | "show basename
23 |
24 | Show whether file basenames are in effect" 1
25 |
26 | _Dbg_do_show_basename() {
27 | typeset label="$1"
28 | [[ -n $label ]] && label='basename: '
29 | _Dbg_msg_nocr \
30 | "${label}Show short filenames is "
31 | if (( _Dbg_set_basename == 0 )); then
32 | _Dbg_msg 'off.'
33 | else
34 | _Dbg_msg 'on.'
35 | fi
36 | return 0
37 | }
38 |
--------------------------------------------------------------------------------
/zshdb_dir/command/show_sub/commands.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show commands" debugger command
3 | #
4 | # Copyright (C) 2011, 2014 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 == ${#funcfiletrace[@]} ]] ; then
22 | dirname=${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 | _Dbg_help_add_sub show commands \
28 | 'show commands
29 |
30 | Show the history of commands you typed.
31 | ' 1
32 |
33 | # _Dbg_show_nolist[commands]=1
34 |
35 | _Dbg_do_show_commands() {
36 | builtin fc -l
37 | }
38 |
--------------------------------------------------------------------------------
/zshdb_dir/command/show_sub/debug.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show debug" debugger command
3 | #
4 | # Copyright (C) 2010, 2011 Rocky Bernstein
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_sub show debug \
21 | "Show if we are set to debug the debugger." 1
22 |
23 | _Dbg_do_show_debug() {
24 | [[ -n $label ]] && label='debug: '
25 | _Dbg_show_onoff 'debug' 'Allow debugging the debugger' "$label"
26 | return 0
27 | }
28 |
--------------------------------------------------------------------------------
/zshdb_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, 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 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='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 |
--------------------------------------------------------------------------------
/zshdb_dir/command/show_sub/highlight.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show 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, 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 terminal highlighting" 1
23 |
24 | _Dbg_do_show_highlight() {
25 | typeset label="$1"
26 | [[ -n $label ]] && label='highlight: '
27 | _Dbg_msg_nocr \
28 | "${label}Terminal highlighting 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 |
--------------------------------------------------------------------------------
/zshdb_dir/command/show_sub/history.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # "show history" debugger command
3 | #
4 | # Copyright (C) 2010, 2014 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 show history \
22 | 'show history
23 |
24 | Show history settings
25 | ' 1
26 |
27 | _Dbg_do_show_history() {
28 | _Dbg_msg \
29 | "filename: The filename in which to record the command history is:"
30 | _Dbg_msg " $_Dbg_histfile"
31 | _Dbg_msg \
32 | "save: Saving of history save is" $(_Dbg_onoff $_Dbg_set_history)
33 | _Dbg_msg \
34 | "size: Debugger history size is $_Dbg_history_size"
35 | return 0
36 | }
37 |
--------------------------------------------------------------------------------
/zshdb_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 | _Dbg_help_add_sub show style \
22 | "Show pygments terminal formatting style" 1
23 |
24 | _Dbg_do_show_style() {
25 | typeset label="$1"
26 | [[ -n $label ]] && label='style: '
27 | _Dbg_msg_nocr \
28 | "${label}Pygments terminal formatting style is "
29 | if [[ -n $_Dbg_set_style ]] ; then
30 | _Dbg_msg "${_Dbg_set_style}."
31 | else
32 | _Dbg_msg 'off.'
33 | fi
34 | return 0
35 | }
36 |
--------------------------------------------------------------------------------
/zshdb_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 |
--------------------------------------------------------------------------------
/zshdb_dir/command/source.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "source" command.
3 | #
4 | # Copyright (C) 2002-2004, 2006, 2008, 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 | # 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 | # Redirect std input to new file and save new descriptor number
41 | exec {_Dbg_fdi}< $filename
42 | # Save descriptor number and assocated file name.
43 | _Dbg_fd+=($_Dbg_fdi)
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 |
--------------------------------------------------------------------------------
/zshdb_dir/command/trace.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | #
3 | # Copyright (C) 2008, 2010, 2016 Rocky Bernstein rocky@gnu.org
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 | # Wrap "set -x .. set +x" around a call to function $1.
21 | # Normally we also save and restrore any trap DEBUG functions. However
22 | # If $2 is 0 we will won't.
23 | # The wrapped function becomes the new function and the original
24 | # function is called old_$1.
25 | # $? is 0 if successful.
26 |
27 | _Dbg_help_add trace \
28 | '**trace** *function*
29 |
30 | trace alias *alias*
31 |
32 | Set "xtrace" (set -x) tracing when *function* is called.
33 | '
34 |
35 | function _Dbg_do_trace {
36 | if (($# == 0)) ; then
37 | _Dbg_errmsg "_Dbg_do_trace: missing function name."
38 | return 2
39 | fi
40 | typeset fn=$1
41 | if [[ $fn == 'alias' ]]; then
42 | shift
43 | _Dbg_do_trace_alias "$@"
44 | return $?
45 | fi
46 |
47 | typeset -ri clear_debug_trap=${2:-1}
48 | _Dbg_is_function "$fn" $_Dbg_set_debug || {
49 | _Dbg_errmsg "_Dbg_do_trace: \"$fn\" is not a function."
50 | return 3
51 | }
52 | cmd=old_$(typeset -f -- "$fn") || {
53 | return 4
54 | }
55 | typeset -ft $fn
56 | return 0
57 | }
58 |
59 | function _Dbg_do_trace_alias {
60 | if (($# == 0)) ; then
61 | _Dbg_errmsg "_Dbg_do_trace_alias: missing alias name."
62 | return 2
63 | fi
64 | typeset al=$1
65 | if _Dbg_is_alias "$al" ; then
66 | alias_body=$(alias $1)
67 | alias_body="set -x; $alias_body; set +x"
68 | alias ${al}=${alias_body}
69 | else
70 | _Dbg_errmsg "_Dbg_do_trace_alias: \"$al\" is not an alias."
71 | return 3
72 | fi
73 | return 0
74 | }
75 |
76 | _Dbg_help_add untrace \
77 | '**untrace** *function*
78 |
79 | Untrace previuosly traced *function*.
80 | '
81 |
82 | # Undo wrapping fn
83 | # $? is 0 if successful.
84 | function _Dbg_do_untrace {
85 | typeset -r fn=$1
86 | if [[ -z $fn ]] ; then
87 | _Dbg_errmsg "untrace: missing or invalid function name."
88 | return 2
89 | fi
90 | _Dbg_is_function "$fn" $_Dbg_set_debug || {
91 | _Dbg_errmsg "untrace: function \"$fn\" is not a function."
92 | return 3
93 | }
94 | typeset +ft $fn
95 | return 0
96 | }
97 |
--------------------------------------------------------------------------------
/zshdb_dir/command/undisplay.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # undisplay.sh - gdb-like "undisplay"
3 | #
4 | # Copyright (C) 2002-2003, 2006-2010, 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 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 1
45 | fi
46 |
47 | for del in $@ ; do
48 | if [ -n "${_Dbg_disp_exp[$del]}" ] ; then
49 | _Dbg_write_journal_eval "_Dbg_disp_exp[$del]=''"
50 | _Dbg_write_journal_eval "_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 |
--------------------------------------------------------------------------------
/zshdb_dir/command/up.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # gdb-like "up" debugger command
3 | #
4 | # Copyright (C) 2010-2012, 2014, 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 == ${#funcfiletrace[@]} ]] ; then
23 | dirname=${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.
36 |
37 | See also:
38 | ---------
39 |
40 | **down** and **frame**.'
41 |
42 | typeset -A _Dbg_complete_level_1_data
43 | _Dbg_complete_level_1_data[up]='-f_Dbg_frame_complete 1'
44 |
45 | function _Dbg_do_up {
46 | _Dbg_not_running && return 1
47 | typeset -i count=${1:-1}
48 | _Dbg_frame_adjust $count +1
49 | ((0 == $?)) && _Dbg_last_cmd='up'
50 | return 0
51 | }
52 |
53 | # Demo it
54 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
55 | for _Dbg_file in help msg sort columnize ; do
56 | source ${top_dir}/lib/${_Dbg_file}.sh
57 | done
58 | source ${top_dir}/command/help.sh
59 | _Dbg_args='up'
60 | _Dbg_do_help up
61 | fi
62 |
--------------------------------------------------------------------------------
/zshdb_dir/dbg-main.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Copyright (C) 2008, 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 | # Stuff common to zshdb and dbg-trace. Include the rest of options
20 | # processing. Also includes things which have to come before other includes
21 | . ${_Dbg_libdir}/dbg-pre.sh
22 |
23 | # All debugger lib code has to come before debugger command code.
24 | typeset _Dbg_file
25 | for _Dbg_file in ${_Dbg_libdir}/lib/*.sh ${_Dbg_libdir}/command/*.sh ; do
26 | source $_Dbg_file
27 | done
28 |
29 | unsetopt localtraps
30 | set -o DEBUG_BEFORE_CMD
31 |
32 | # Have we already specified where to read debugger input from?
33 | if [[ -n "$DBG_INPUT" ]] ; then
34 | _Dbg_do_source "$DBG_INPUT"
35 | _Dbg_no_nx=1
36 | fi
37 |
38 | if [[ -z "$_Dbg_tty" ]]; then
39 | _Dbg_tty=$(tty)
40 | [[ $_Dbg_tty == 'not a tty' ]] && unset _Dbg_tty
41 | fi
42 | [[ -n "$_Dbg_tty" ]] && _Dbg_do_set inferior-tty $_Dbg_tty
43 |
44 | # Run the user's debugger startup file. This has to come
45 | # *after* setting up the tty since _Dbg_do_set inferior-tty
46 | # smashes the current tty.
47 | typeset _Dbg_startup_cmdfile=${HOME:-~}/.${_Dbg_debugger_name}rc
48 | if (( 0 == _Dbg_o_nx)) && [[ -r "$_Dbg_startup_cmdfile" ]] ; then
49 | _Dbg_do_source "$_Dbg_startup_cmdfile"
50 | fi
51 |
52 | # _Dbg_DEBUGGER_LEVEL is the number of times we are nested inside a debugger
53 | # by virtue of running "debug" for example.
54 | if [[ -z "${_Dbg_DEBUGGER_LEVEL}" ]] ; then
55 | typeset -xi _Dbg_DEBUGGER_LEVEL=1
56 | fi
57 |
58 | if ((_Dbg_history_save)) ; then
59 | history -ap $_Dbg_histfile $_Dbg_history_size
60 | fi
61 |
62 | for source_file in ${_Dbg_o_init_files[@]} "$DBG_RESTART_FILE"; do
63 | if [[ -n "$source_file" ]] ; then
64 | if [[ -r "$source_file" ]] && [[ -f "$source_file" ]] ; then
65 | source $source_file
66 | else
67 | _Dbg_errmsg "Unable to read shell script: ${source_file}"
68 | fi
69 | fi
70 | done
71 |
--------------------------------------------------------------------------------
/zshdb_dir/dbg-pre.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # dbg-pre.sh - Code common to zshdb and zshdb-trace that has to run first
3 | #
4 | # Copyright (C) 2008-2010, 2014 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; see the file COPYING. If not, write to the Free Software
18 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
19 |
20 | # Here we put definitions common to both the script debugger and
21 | # dbg-trace.sh. In contrast to other routines, this code is sourced
22 | # early -- before most of the debugger script is run.
23 |
24 | # Note: initializations which are mostly used in only one sub-part
25 | # (e.g. variables for break/watch/actions) are in the corresponding
26 | # file: either in lib or (less good) command.
27 |
28 | # Are we using a debugger-enabled shell? If not let's stop right here.
29 | typeset old_setopt="$-"
30 |
31 | # is-at-least messes up in some situations so we have to not use it for now.
32 | # typeset -fuz is-at-least # Same as "functions -u -z" but better documented.
33 | # if ! is-at-least 4.3.6-dev-0 ; then
34 | # print "Sorry, your $_Dbg_shell_name just isn't modern enough." 2>&1
35 | # print "We need 4.3.6-dev-0 or greater." 2>&1
36 | # exit 30
37 | # fi
38 | # is-at-least does an emulate -L zsh
39 | # emulate -L ksh
40 |
41 | # Will be set to 1 if the top-level call is a debugger.
42 | typeset -i _Dbg_script=0
43 |
44 | # This function is overwritten by when lib/fns.sh gets loaded
45 | _Dbg_msg()
46 | {
47 | echo "$*"
48 | }
49 |
50 | # Used by "show version" as well as --version
51 | _Dbg_do_show_version()
52 | {
53 | _Dbg_msg "$_Dbg_debugger_name, release $_Dbg_release"
54 | }
55 |
56 | # Expand filename given as $1.
57 | # we echo the expanded name or return $1 unchanged if a bad filename.
58 | # Return is 0 if good or 1 if bad.
59 | # File globbing is handled.
60 | # Note we don't check that the file exists, just that the format is
61 | # valid; we do check that we can "search" the directory implied in the
62 | # filename.
63 |
64 | function _Dbg_expand_filename {
65 | typeset -r filename="$1"
66 |
67 | # Break out basename and dirname
68 | typeset basename="${filename##*/}"
69 | typeset -x dirname="${filename%/*}"
70 |
71 | # No slash given in filename? Then use . for dirname
72 | [[ $dirname == $basename ]] && [[ $filename != '/' ]] && dirname='.'
73 |
74 | # Dirname is ''? Then use / for dirname
75 | dirname=${dirname:-/}
76 |
77 | # Handle tilde expansion in dirname
78 | dirname=$(echo $dirname)
79 |
80 | typeset long_path
81 |
82 | [[ $basename == '.' ]] && basename=''
83 | if long_path=$( (cd "$dirname" ; pwd) 2>/dev/null ) ; then
84 | if [[ "$long_path" == '/' ]] ; then
85 | echo "/$basename"
86 | else
87 | echo "$long_path/$basename"
88 | fi
89 | return 0
90 | else
91 | echo $filename
92 | return 1
93 | fi
94 | }
95 |
96 | # Create temporary file based on $1
97 | # file $1
98 | _Dbg_tempname() {
99 | echo "$_Dbg_tmpdir/${_Dbg_debugger_name}_$1_$$"
100 | }
101 |
102 | # Process command-line options
103 | . ${_Dbg_libdir}/dbg-opts.sh
104 | OPTLIND=1
105 | _Dbg_parse_options "$@"
106 |
107 | if [[ ! -d $_Dbg_tmpdir ]] && [[ ! -w $_Dbg_tmpdir ]] ; then
108 | echo "${_Dbg_pname}: cannot write to temp directory $_Dbg_tmpdir." >&2
109 | echo "${_Dbg_pname}: Use -T try directory location." >&2
110 | exit 1
111 | fi
112 |
113 | # Save the initial working directory so we can reset it on a restart.
114 | typeset -x _Dbg_init_cwd=$PWD
115 |
116 | typeset -i _Dbg_running=1 # True we are not finished running the program
117 |
118 | typeset -i _Dbg_brkpt_num=0 # If nonzero, the breakpoint number that we
119 | # are currently stopped at.
120 |
121 | # Sets whether or not to display command before executing it.
122 | typeset _Dbg_set_trace_commands='off'
123 |
124 | # Known normal IFS consisting of a space, tab and newline
125 | typeset -x _Dbg_space_IFS=$' \t\r\n'
126 |
127 | # Number of statements to run before entering the debugger. Is used
128 | # intially to get out of sourced dbg-main.inc script and in top-level
129 | # debugger script to not stop in remaining debugger statements before
130 | # the sourcing the script to be debugged.
131 | typeset -i _Dbg_step_ignore=1
132 | [[ -n $_Dbg_histfile ]] && fc -p ${_Dbg_histfile}
133 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/.gitignore:
--------------------------------------------------------------------------------
1 | /*~
2 | /Makefile
3 | /Makefile.in
4 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/Makefile.am:
--------------------------------------------------------------------------------
1 | pkgdatadir = ${datadir}/@PACKAGE@/lib
2 | pkgdata_DATA = $(wildcard *.sh) term-highlight.py
3 |
4 | install-data-hook:
5 | chmod +x $(DESTDIR)$(pkgdatadir)/term-highlight.py
6 |
7 | EXTRA_DIST = $(pkgdata_DATA)
8 | MOSTLYCLEANFILES = *.orig *.rej
9 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/alias.sh:
--------------------------------------------------------------------------------
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 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 | # Return in help_aliases an array of strings that are aliases
46 | # of $1
47 | _Dbg_alias_find_aliased() {
48 | (($# != 1)) && return 255
49 | typeset find_name=$1
50 | aliases_found=''
51 | typeset -i i
52 | unsetopt ksharrays
53 | typeset aliases="${(k)_Dbg_aliases}"
54 | setopt ksharrays
55 | for alias in $aliases ; do
56 | if [[ ${_Dbg_aliases[$alias]} == "$find_name" ]] ; then
57 | [[ -n $aliases_found ]] && aliases_found+=', '
58 | aliases_found+="$alias"
59 | fi
60 | done
61 | return 0
62 | }
63 |
--------------------------------------------------------------------------------
/zshdb_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) 2008 Rocky Bernstein rocky@gnu.org
4 | #
5 | # zshdb 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 | # zshdb 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 zshdb; 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 | typeset _Dbg_trace_old_set_opts=$-
29 | set +u
30 | if (( $# > 0 )) ; then
31 | step_ignore=$1
32 | shift
33 | else
34 | typeset step_ignore=${_Dbg_step_ignore:-''}
35 | fi
36 |
37 | while (( $# > 0 )) ; do
38 | eval $1
39 | shift
40 | done
41 |
42 | if [[ -z $_Dbg_set_trace_init ]] ; then
43 | _Dbg_set_trace_init=1
44 | _Dbg_step_ignore=${step_ignore:-0}
45 | _Dbg_write_journal "_Dbg_step_ignore=0"
46 | else
47 | _Dbg_step_ignore=${1:-1}
48 | fi
49 | set -${_Dbg_trace_old_set_opts}
50 | unset _Dbg_trace_old_set_opts
51 | trap '_Dbg_trap_handler $? "$@"; ((2==$?)) && setopt errexit' DEBUG
52 | }
53 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/display.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # display.sh - Debugger display routines
3 | #
4 | # Copyright (C) 2010, 2013 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 | #================ VARIABLE INITIALIZATIONS ====================#
23 |
24 | # Display data structures
25 | typeset -a _Dbg_disp_exp; _Dbg_disp_exp=() # Watchpoint expressions
26 | typeset -ia _Dbg_disp_enable; _Dbg_disp_enable=() # 1/0 if enabled or not
27 | typeset -i _Dbg_disp_max=0 # Needed because we can't figure out what
28 | # the max index is and arrays can be sparse
29 |
30 |
31 | #========================= FUNCTIONS ============================#
32 |
33 | _Dbg_save_display() {
34 | typeset -p _Dbg_disp_exp >> $_Dbg_statefile
35 | typeset -p _Dbg_disp_enable >> $_Dbg_statefile
36 | typeset -p _Dbg_disp_max >> $_Dbg_statefile
37 | }
38 |
39 | # Enable/disable display by entry numbers.
40 | _Dbg_disp_enable_disable() {
41 | if (($# < 2)) ; then
42 | _Dbg_errmsg "Expecting at least two parameters. Got: ${#}."
43 | return 1
44 | fi
45 | typeset -i on=$1
46 | typeset en_dis=$2
47 | shift; shift
48 |
49 | typeset to_go="$@"
50 | typeset i
51 | for i in $to_go ; do
52 | case $i in
53 | [0-9]* )
54 | _Dbg_enable_disable_display $on $en_dis $i
55 | ;;
56 | * )
57 | _Dbg_errmsg "Invalid entry number $i skipped"
58 | ;;
59 | esac
60 | done
61 | return 0
62 | }
63 |
64 | _Dbg_eval_all_display() {
65 | typeset -i i
66 | for (( i=0; i < _Dbg_disp_max ; i++ )) ; do
67 | if [ -n "${_Dbg_disp_exp[$i]}" ] \
68 | && [[ ${_Dbg_disp_enable[i]} != 0 ]] ; then
69 | _Dbg_printf_nocr "%2d: %s = " $i "${_Dbg_disp_exp[i]}"
70 | typeset -i _Dbg_show_eval_rc; _Dbg_show_eval_rc=0
71 | _Dbg_do_eval "_Dbg_msg ${_Dbg_disp_exp[i]}"
72 | fi
73 | done
74 | }
75 |
76 | # Enable/disable display(s) by entry numbers.
77 | _Dbg_enable_disable_display() {
78 | typeset -i on=$1
79 | typeset en_dis=$2
80 | typeset -i i=$3
81 | if [ -n "${_Dbg_disp_exp[$i]}" ] ; then
82 | if [[ ${_Dbg_disp_enable[$i]} == $on ]] ; then
83 | _Dbg_errmsg "Display entry $i already ${en_dis}, so nothing done."
84 | else
85 | _Dbg_write_journal_eval "_Dbg_disp_enable[$i]=$on"
86 | _Dbg_msg "Display entry $i $en_dis."
87 | fi
88 | else
89 | _Dbg_errmsg "Display entry $i doesn't exist, so nothing done."
90 | fi
91 | }
92 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/file.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Things related to file handling.
3 | #
4 | # Copyright (C) 2008, 2010 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; see the file COPYING. If not, write to the Free Software
18 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
19 |
20 | # Directory search patch for unqualified file names
21 |
22 | typeset -a _Dbg_dir
23 | _Dbg_dir=('\$cdir' '\$cwd' )
24 |
25 | # _Dbg_cdir is the directory in which the script is located.
26 | [[ -z ${_Dbg_cdir} ]] && typeset _Dbg_cdir=${_Dbg_source_file%/*}
27 | [[ -z ${_Dbg_cdir} ]] && typeset _Dbg_cdir=$(pwd)
28 |
29 | # Either fill out or strip filename as determined by "basename_only"
30 | # and annotate settings
31 | _Dbg_adjust_filename() {
32 | typeset -r filename="$1"
33 | if (( _Dbg_set_annotate == 1 )) ; then
34 | print -- $(_Dbg_resolve_expand_filename "$filename")
35 | elif ((_Dbg_set_basename)) ; then
36 | print -- ${filename##*/}
37 | else
38 | print -- $filename
39 | fi
40 | }
41 |
42 | # $1 contains the name you want to glob. return 0 if exists and is
43 | # readable or 1 if not.
44 | # The result will be in variable $filename which is assumed to be
45 | # local'd by the caller
46 | _Dbg_tilde_expand_filename() {
47 | typeset cmd="filename=$(expr $1)"
48 | eval "$cmd"
49 | [[ -r "$filename" ]]
50 | }
51 |
52 | #
53 | # Resolve $1 to a full file name which exists. First see if filename has been
54 | # mentioned in a debugger "file" command. If not and the file name
55 | # is a relative name use _Dbg_dir to substitute a relative directory name.
56 | #
57 | function _Dbg_resolve_expand_filename {
58 |
59 | if (( $# == 0 )) ; then
60 | _Dbg_errmsg \
61 | "Internal debug error _Dbg_resolve_expand_filename(): null file to find"
62 | echo ''
63 | return 1
64 | fi
65 | typeset find_file="$1"
66 |
67 | # Is this one of the files we've that has been specified in a debugger
68 | # "FILE" command?
69 | typeset found_file
70 | found_file="${_Dbg_file2canonic[$find_file]}"
71 | if [[ -n $found_file ]] ; then
72 | print -- "$found_file"
73 | return 0
74 | fi
75 |
76 | if [[ ${find_file[0]} == '/' ]] ; then
77 | # Absolute file name
78 | full_find_file=$(_Dbg_expand_filename "$find_file")
79 | print -- "$full_find_file"
80 | return 0
81 | elif [[ ${find_file[0]} == '.' ]] ; then
82 | # Relative file name
83 | full_find_file=$(_Dbg_expand_filename "${_Dbg_init_cwd}/$find_file")
84 | if [[ -z "$full_find_file" ]] || [[ ! -r $full_find_file ]]; then
85 | # Try using cwd rather that Dbg_init_cwd
86 | full_find_file=$(_Dbg_expand_filename "$find_file")
87 | fi
88 | print -- "$full_find_file"
89 | return 0
90 | else
91 | # Resolve file using _Dbg_dir
92 | typeset -i n=${#_Dbg_dir[@]}
93 | typeset -i i
94 | for (( i=0 ; i < n; i++ )) ; do
95 | typeset basename="${_Dbg_dir[i]}"
96 | if [[ $basename == '\$cdir' ]] ; then
97 | basename=$_Dbg_cdir
98 | elif [[ $basename == '\$cwd' ]] ; then
99 | basename=$(pwd)
100 | fi
101 | if [[ -f "$basename/$find_file" ]] ; then
102 | print -- "$basename/$find_file"
103 | return 0
104 | fi
105 | done
106 | fi
107 | echo ''
108 | return 1
109 | }
110 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/gdb.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # routines that seem tailored more to the gdb-style of doing things.
3 | # Copyright (C) 2008, 2011, 2015, 2018 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 | # Print location in gdb-style format: file:line
21 | # So happens this is how it's stored in global _Dbg_frame_stack which
22 | # is where we get the information from
23 | function _Dbg_print_location {
24 | if (($# > 1)); then
25 | _Dbg_errmsg "got $# parameters, but need 0 or 1."
26 | return 2
27 | fi
28 | typeset -i pos=${1:-${_Dbg_stack_pos}}
29 | typeset file_line="${_Dbg_frame_stack[$pos]}"
30 |
31 | typeset split_result; _Dbg_split "$file_line" ':'
32 | typeset filename="${split_result[0]}"
33 | typeset -i line="${split_result[1]}"
34 | if [[ -n $filename ]] ; then
35 | _Dbg_readin "${filename}"
36 | if ((_Dbg_set_basename)); then
37 | filename=${filename##*/}
38 | file_line="${filename}:${line}"
39 | fi
40 | if [[ $filename == $_Dbg_func_stack[1] ]] ; then
41 | _Dbg_msg "($file_line): -- nope"
42 | else
43 | _Dbg_msg "($file_line):"
44 | fi
45 | fi
46 | }
47 |
48 | function _Dbg_print_command {
49 | typeset -i width; ((width=_Dbg_set_linewidth-6))
50 | if (( ${#ZSH_DEBUG_CMD} > width )) && [[ -n $_Dbg_set_highlight ]] ; then
51 | _Dbg_msg "${ZSH_DEBUG_CMD[0,$width]} ..."
52 | else
53 | if [[ -n $_Dbg_set_highlight ]] ; then
54 | filter="${_Dbg_libdir}/lib/term-highlight.py --bg=${_Dbg_set_highlight}"
55 | line=$(echo "$ZSH_DEBUG_CMD" | $filter 2>/dev/null)
56 | if (( $? == 0 )) ; then
57 | _Dbg_msg "$line"
58 | return 0
59 | fi
60 | fi
61 | _Dbg_msg $ZSH_DEBUG_CMD
62 | fi
63 | }
64 |
65 | function _Dbg_print_location_and_command {
66 | _Dbg_print_location $@
67 | _Dbg_print_command
68 | }
69 |
70 | # Print position $1 of stack frame (from global _Dbg_frame_stack)
71 | # If $2 is set, show the source line code.
72 | _Dbg_print_frame() {
73 | if (($# > 2)); then
74 | _Dbg_errmsg "got $# parameters, but need 0..2."
75 | return -1
76 | fi
77 |
78 | typeset -i pos; pos=${1:-$_Dbg_stack_pos}
79 | typeset -i show_source=${2:0}
80 |
81 | typeset prefix='##'
82 | (( pos == _Dbg_stack_pos)) && prefix='->'
83 |
84 | prefix+="$pos "
85 | if ((pos!=0)) ; then
86 | typeset fn_or_file; fn_or_file="${_Dbg_func_stack[$pos-1]}"
87 | (( _Dbg_set_basename )) && fn_or_file=${fn_or_file##*/}
88 | prefix+="$fn_or_file called from"
89 | else
90 | prefix+='in'
91 | fi
92 |
93 | typeset file_line
94 | file_line="${_Dbg_frame_stack[$pos]}"
95 |
96 | typeset -a split_result; _Dbg_split "$file_line" ':'
97 | typeset filename
98 | filename="${split_result[0]}"
99 | typeset -i line="${split_result[1]}"
100 | (( _Dbg_set_basename )) && filename=${filename##*/}
101 | _Dbg_msg "$prefix file \`$filename' at line $line"
102 | if (( show_source )) ; then
103 | _Dbg_list "$filename" $line 1
104 | fi
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/hist.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # hist.sh - Shell Debugger history routines
3 | #
4 | # Copyright (C) 2008, 2011, 2014 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; see the file COPYING. If not, write to the Free Software
18 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
19 |
20 | if [[ 0 == ${#funcfiletrace[@]} ]] ; then
21 | dirname=${0%/*}
22 | [[ $dirname == $0 ]] && _Dbg_libdir='..' || _Dbg_libdir=${dirname}/..
23 | # dbg-oppts sets defines _Dbg_history_size, _Dbg_histfile, and
24 | # _Dbg_history_save
25 | source $_Dbg_libdir/dbg-opts
26 | fi
27 |
28 | typeset -i _Dbg_hi_last_stop=-1
29 | typeset -i _Dbg_set_history=1
30 |
31 | _Dbg_history_read() {
32 | if ((_Dbg_history_save)) && [[ -r $_Dbg_histfile ]] ; then
33 | builtin fc -R $_Dbg_histfile
34 | fi
35 | }
36 |
37 | # Save history file
38 | _Dbg_history_write() {
39 | if (( _Dbg_history_size > 0 && _Dbg_set_history)) ; then
40 | # The following "fc" command doesn't work and I, rocky, don't
41 | # have the patients to deal with arcane zsh-isms to want to
42 | # make it work.
43 | ## fc -WI $_Dbg_histfile
44 | cat /dev/null >$_Dbg_histfile
45 | typeset line
46 | typeset -a buffer
47 | typeset -a history
48 | typeset saveIFS
49 | saveIFS=$IFS; IFS=$'\n'; history=($(builtin fc -l)); IFS=$saveIFS
50 | typeset -i last=${#history[@]}
51 | typeset -i start=0
52 | typeset -i i
53 | ((_Dbg_history_size < last+1)) && ((start=last+1-_Dbg_history_size))
54 | for ((i=start; i<=last; i++)); do
55 | buffer=(${history[i]})
56 | buffer[0]=()
57 | print -- "${buffer[@]}" >> $_Dbg_histfile;
58 | done
59 | fi
60 | }
61 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/info-help.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # info.sh - Debugger "info" support
3 |
4 | # Copyright (C) 2008, 2016 Rocky Bernstein rocky@gnu.org
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; see the file COPYING. If not, write to the Free Software
18 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
19 |
20 | typeset -r _Dbg_info_cmds='breakpoints display files line program source stack variables warranty'
21 |
22 | _Dbg_info_help() {
23 | typeset info_cmd=$1
24 | typeset label=$2
25 |
26 | if (($# > 0)) ; then
27 | typeset info_cmd=$1
28 | shift
29 | case $info_cmd in
30 | # ar | arg | args )
31 | # _Dbg_msg \
32 | # "info args -- Argument variables (e.g. \$1, \$2, ...) of the current stack frame."
33 | # return 0
34 | # ;;
35 | b | br | bre | brea | 'break' | breakp | breakpo | breakpoints )
36 | _Dbg_msg \
37 | 'info breakpoints -- Status of user-settable breakpoints'
38 | return 0
39 | ;;
40 | disp | displ | displa | display )
41 | _Dbg_msg \
42 | 'info display -- Show all display expressions'
43 | return 0
44 | ;;
45 | 'fi' | fil | file | files | sources )
46 | _Dbg_msg \
47 | 'info files -- Source files in the program'
48 | return 0
49 | ;;
50 | l | li| lin | line )
51 | _Dbg_msg \
52 | 'info line -- list current line number and and file name'
53 | return 0
54 | ;;
55 | p | pr | pro | prog | progr | progra | program )
56 | _Dbg_msg \
57 | 'info program -- Execution status of the program.'
58 | return 0
59 | ;;
60 | # h | ha | han | hand | handl | handle | \
61 | # si | sig | sign | signa | signal | signals )
62 | # _Dbg_msg \
63 | # 'info signals -- What debugger does when program gets various signals'
64 | # return 0
65 | # ;;
66 | so | sou | sourc | source )
67 | _Dbg_msg \
68 | 'info source -- Information about the current source file'
69 | return 0
70 | ;;
71 | st | sta | stac | stack )
72 | _Dbg_msg \
73 | 'info stack -- Backtrace of the stack'
74 | return 0
75 | ;;
76 | # te | ter | term | termi | termin | termina | terminal | tt | tty )
77 | # _Dbg_msg \
78 | # 'info terminal -- Print terminal device'
79 | # return 0
80 | # ;;
81 | # tr|tra|trac|trace|tracep | tracepo | tracepoi | tracepoint | tracepoints )
82 | # _Dbg_msg \
83 | # 'info tracepoints -- Status of tracepoints'
84 | # return 0
85 | # ;;
86 | v | va | var | vari | varia | variab | variabl | variable | variables )
87 | _Dbg_msg \
88 | "info variables [PROPERTY] -- Variable lists by property.
89 | PROPERTY is one of:
90 | \t$_Dbg_info_var_attrs"
91 | return 0
92 | ;;
93 | w | wa | war | warr | warra | warran | warrant | warranty )
94 | _Dbg_msg \
95 | 'info warranty -- Various kinds of warranty you do not have'
96 | return 0
97 | ;;
98 | * )
99 | _Dbg_errmsg "Unknown info subcommand: $info_cmd"
100 | msg=_Dbg_errmsg
101 | esac
102 | else
103 | msg=_Dbg_msg
104 | fi
105 | $msg "Info subcommands are:"
106 | typeset -a list; list=(${_Dbg_info_cmds})
107 | _Dbg_list_columns ' ' $msg
108 | [[ $msg == '_Dbg_errmsg' ]] && return 1 || return 0
109 | }
110 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/journal.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Things related to variable journaling.
3 | #
4 | # Copyright (C) 2008, 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 | # We use a journal file to save variable state so that we can pass
22 | # values set in a subshell or nested shell back. This typically
23 | # includes debugger information, e.g. breakpoints and state. This file
24 | # is just code (usually assignment statements) that get eval'd.
25 |
26 | # The file to save the journal information.
27 | typeset _Dbg_journal=$(_Dbg_tempname journal)
28 |
29 | # append a command into journal file and then run the command.
30 | _Dbg_write_journal_eval() {
31 | _Dbg_write_journal "$@"
32 | eval "$@"
33 | }
34 |
35 | # append a command into journal file and then run the command.
36 | _Dbg_write_journal_var() {
37 | typeset var_name="$1"
38 | typeset val
39 | typeset val_cmd="$val=\${$var_name}"
40 | eval $val_cmd
41 | _Dbg_write_journal "${var_name}=${val}"
42 | }
43 |
44 | typeset -fuz is-at-least
45 |
46 | _Dbg_write_journal_avar() {
47 | if (( ZSH_SUBSHELL != 0 )) ; then
48 | if is-at-least 5.4.1 ; then
49 | typeset -p $1 >> ${_Dbg_journal} 2>/dev/null
50 | else
51 | typeset -p $1 | grep -v ^typeset >> ${_Dbg_journal} 2>/dev/null
52 | fi
53 | fi
54 | }
55 |
56 | # Append a command into journal file. But we only need to do
57 | # if we are in a subshell.
58 | _Dbg_write_journal() {
59 | if (( ZSH_SUBSHELL != 0 )) ; then
60 | echo "$@" >> ${_Dbg_journal} 2>/dev/null
61 | fi
62 | return $?
63 | }
64 |
65 | # Remove all journal files.
66 | _Dbg_erase_journals() {
67 | [[ -f $_Dbg_journal ]] && rm ${_Dbg_journal} 2>/dev/null
68 | return $?
69 | }
70 |
71 | # read in or "source" in journal file which will set variables.
72 | _Dbg_source_journal() {
73 |
74 | if [ -r $_Dbg_journal ] ; then
75 | . $_Dbg_journal
76 | (( ZSH_SUBSHELL == 0 )) && _Dbg_erase_journals
77 | fi
78 | }
79 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/list.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # debugger source-code listing routines
3 | #
4 | # Copyright (C) 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 | # List search commands/routines
23 |
24 | # Last search pattern used.
25 | typeset _Dbg_last_search_pat
26 |
27 | # The current line to be listed. A 0 value indicates we should set
28 | # from _Dbg_frame_last_lineno
29 | typeset -i _Dbg_listline=0
30 |
31 | # list $3 lines starting at line $2 of file $1. If $1 is '', use
32 | # $_Dbg_frame_last_filename value. If $3 is ommited, print $_Dbg_set_listsize
33 | # lines. if $2 is omitted, use global variable $_Dbg_frame_last_lineno.
34 | _Dbg_list() {
35 | typeset filename
36 | if (( $# > 0 )) ; then
37 | filename=$1
38 | else
39 | filename=$_Dbg_frame_last_filename
40 | fi
41 |
42 | if [[ $2 == '.' ]]; then
43 | _Dbg_listline=$_Dbg_frame_last_lineno
44 | elif [[ -n $2 ]] ; then
45 | _Dbg_listline=$2
46 | elif (( 0 == _Dbg_listline )) ; then
47 | _Dbg_listline=$_Dbg_frame_last_lineno
48 | fi
49 | (( _Dbg_listline==0 && _Dbg_listline++ ))
50 |
51 | typeset -i cnt
52 | cnt=${3:-$_Dbg_set_listsize}
53 | typeset -i n
54 | n=$((_Dbg_listline+cnt-1))
55 |
56 | _Dbg_readin_if_new "$filename"
57 |
58 | typeset -i max_line
59 | max_line=$(_Dbg_get_maxline "$filename")
60 | if (( $? != 0 )) ; then
61 | _Dbg_errmsg "internal error getting number of lines in $filename"
62 | return 1
63 | fi
64 |
65 | if (( _Dbg_listline > max_line )) ; then
66 | _Dbg_errmsg \
67 | "Line number $_Dbg_listline out of range;" \
68 | "$filename has $max_line lines."
69 | return 1
70 | fi
71 |
72 | typeset source_line
73 | typeset frame_fullfile
74 | frame_fullfile=${_Dbg_file2canonic[$_Dbg_frame_last_filename]}
75 |
76 | for (( ; _Dbg_listline <= n && _Dbg_listline <= max_line \
77 | ; _Dbg_listline++ )) ; do
78 | typeset prefix=' '
79 | _Dbg_get_source_line $_Dbg_listline "$filename"
80 |
81 | (( _Dbg_listline == _Dbg_frame_last_lineno )) \
82 | && [[ $fullname == $frame_fullfile ]] && prefix=' => '
83 | _Dbg_printf "%3d:%s%s" $_Dbg_listline "$prefix" "$source_line"
84 | done
85 | (( _Dbg_listline > max_line && _Dbg_listline-- ))
86 | return 0
87 | }
88 |
89 | _Dbg_list_columns() {
90 | typeset colsep=' '
91 | (($# > 0 )) && { colsep="$1"; shift; }
92 | typeset -i linewidth
93 | # 2 below is the initial prefix
94 | if (($# > 0 )) && ; then
95 | msg=$1
96 | shift
97 | else
98 | msg=_Dbg_msg
99 | fi
100 | if (($# > 0 )) ; then
101 | ((linewidth=$1-2));
102 | shift
103 | else
104 | ((linewidth=_Dbg_set_linewidth-2))
105 | fi
106 | (($# != 0)) && return 1
107 | typeset -a columnized; columnize $linewidth "$colsep"
108 | typeset -i i
109 | for ((i=0; i<${#columnized[@]}; i++)) ; do
110 | $msg " ${columnized[i]}"
111 | done
112 |
113 | }
114 | _Dbg_list_locals() {
115 | typeset -a list
116 | list=(${(k)parameters[(R)*local*]})
117 | typeset -i rc=$?
118 | (( rc != 0 )) && return $rc
119 | _Dbg_list_columns
120 | }
121 |
122 | _Dbg_list_globals() {
123 | typeset -a list
124 | list=(${(k)parameters[(R)^*local*]})
125 | typeset -i rc=$?
126 | (( rc != 0 )) && return $rc
127 | _Dbg_list_columns
128 | }
129 |
130 | _Dbg_list_typeset_attr() {
131 | typeset -a list
132 | list=( $(_Dbg_get_typeset_attr '+p' $*) )
133 | typeset -i rc=$?
134 | (( rc != 0 )) && return $rc
135 | _Dbg_list_columns
136 | }
137 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/run.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Copyright (C) 2008 Rocky Bernstein rocky@gnu.org
3 | #
4 | # zshdb 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 | # zshdb 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 zshdb; see the file COPYING. If not, write to the Free Software
16 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
17 |
18 | function _Dbg_run_cmdline {
19 | typeset -a cmd
20 | cmd=( $(COLUMNS=3000 ps h -o command -p $$) )
21 | SH_RUN_CMDLINE=${cmd[@]}
22 | }
23 |
24 | _Dbg_not_running () {
25 | if (( ! _Dbg_running )) ; then
26 | _Dbg_errmsg 'The program is not being run.'
27 | return 0
28 | fi
29 | return 1
30 | }
31 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/save-restore.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Save and restore user settings
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 | # Options which are set inside the debugger
22 | [[ -z $_Dbg_debugger_set_opts ]] && \
23 | typeset -r _Dbg_debugger_set_opts=\
24 | 'extendedhistory extendedglob shwordsplit ksharrays histignoredups zle rematchpcre bashrematch'
25 |
26 | # Options which are unset inside the debugger
27 | [[ -z $_Dbg_debugger_unset_opts ]] && \
28 | typeset -r _Dbg_debugger_unset_opts='localtraps'
29 |
30 | # Options to save/restore between entering/leaving the debugger
31 | [[ -z $_Dbg_check_opts ]] && \
32 | typeset -r _Dbg_check_opts=\
33 | "$_Dbg_debugger_set_opts $_Dbg_debugger_unset_opts"
34 |
35 | # Do things for debugger entry. Set some global debugger variables
36 | # Remove trapping ourselves.
37 | # We assume that we are nested two calls deep from the point of debug
38 | # or signal fault. If this isn't the constant 2, then consider adding
39 | # a parameter to this routine.
40 | _Dbg_set_debugger_entry() {
41 |
42 | _Dbg_rc=0
43 | _Dbg_return_rc=0
44 | _Dbg_old_IFS="$IFS"
45 | _Dbg_old_PS4="$PS4"
46 | if (( $# > 0 )) ; then
47 | _Dbg_create_unsetopt "$_Dbg_check_opts"
48 | fi
49 | _Dbg_set_debugger_internal
50 | _Dbg_source_journal
51 | if (( _Dbg_QUIT_LEVELS > 0 )) ; then
52 | _Dbg_do_quit $_Dbg_debugged_exit_code
53 | fi
54 | }
55 |
56 | # Return 0 if $1 is not a zsh option set
57 | _Dbg_is_unsetopt() {
58 | (( $# != 1 )) || [[ -z $1 ]] && return 2
59 | ! setopt | grep "$1" >/dev/null 2>&1
60 | }
61 |
62 | # Set string unset_opts to be those zsh options in $* that are not set.
63 | function _Dbg_create_unsetopt {
64 | typeset unset_opts=''
65 | typeset set_opts=''
66 | eval "set -- $*"
67 | for opt ; do
68 | if _Dbg_is_unsetopt $opt ; then
69 | unset_opts="$unset_opts $opt"
70 | else
71 | set_opts="$set_opts $opt"
72 | fi
73 | done
74 | _Dbg_restore_unsetopt=$unset_opts
75 | _Dbg_restore_setopt=$set_opts
76 | }
77 |
78 |
79 | # Does things to after on entry of after an eval to set some debugger
80 | # internal settings
81 | _Dbg_set_debugger_internal() {
82 | IFS="$_Dbg_space_IFS"
83 | PS4='(%x:%I): %? $_Dbg_debugger_name
84 | '
85 | setopt ksharrays shwordsplit norcs bashrematch
86 | unsetopt $_Dbg_debugger_unset_opts
87 | }
88 |
89 | _Dbg_restore_user_vars() {
90 | IFS="$_Dbg_old_IFS"
91 | PS4="$_Dbg_old_PS4"
92 | [[ -n $_Dbg_restore_unsetopt ]] && eval "unsetopt $_Dbg_restore_unsetopt"
93 | [[ -n $_Dbg_restore_setopt ]] && eval "setopt $_Dbg_restore_setopt"
94 | set -$_Dbg_old_set_opts
95 |
96 | }
97 |
98 | _Dbg_set_to_return_from_debugger() {
99 | _Dbg_stop_reason=''
100 | _Dbg_listline=0
101 | _Dbg_rc=${1:-0}
102 | _Dbg_brkpt_num=0
103 | _Dbg_restore_user_vars
104 | }
105 |
106 | _Dbg_save_state() {
107 | # _Dbg_statefile=$(_Dbg_tempname statefile)
108 | # echo "" > $_Dbg_statefile
109 | # _Dbg_save_breakpoints
110 | # _Dbg_save_actions
111 | # _Dbg_save_watchpoints
112 | # _Dbg_save_display
113 | # _Dbg_save_Dbg_set
114 | # echo "unset DBG_RESTART_FILE" >> $_Dbg_statefile
115 | # echo "rm $_Dbg_statefile" >> $_Dbg_statefile
116 | # export DBG_RESTART_FILE="$_Dbg_statefile"
117 | # _Dbg_write_journal "export DBG_RESTART_FILE=\"$_Dbg_statefile\""
118 | :
119 | }
120 |
121 | _Dbg_restore_state() {
122 | typeset statefile=$1
123 | . $1
124 | }
125 |
126 | # Things we do when coming back from a nested shell.
127 | # "shell", and "debug" create nested shells.
128 | _Dbg_restore_from_nested_shell() {
129 | rm -f $_Dbg_shell_temp_profile 2>&1 >/dev/null
130 | if [[ -r $_Dbg_restore_info ]] ; then
131 | . $_Dbg_restore_info
132 | rm $_Dbg_restore_info
133 | fi
134 | }
135 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/set-d-vars.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | #$Id: set-d-vars.sh,v 1.2 2007/02/11 23:06:41 rockyb Exp $
3 | # Copyright (C) 2008 Rocky Bernstein rocky@gnu.org
4 | #
5 | # zshdb 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 | # zshdb 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 zshdb; 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 | typeset _Dbg_set_str='set --'
23 | typeset -i _Dbg__i
24 | for (( _Dbg__i=0 ; _Dbg__i<${#_Dbg_arg[@]}; _Dbg__i++ )) ; do
25 | local dq_argi="${_Dbg_arg[_Dbg__i]}"
26 | _Dbg_set_str="$_Dbg_set_str \"$dq_argi\""
27 | done
28 | eval $_Dbg_set_str
29 |
30 | _Dbg_restore_user_vars
31 |
32 | # Setting $? has to be done last.
33 | _Dbg_set_dol_q $_Dbg_debugged_exit_code
34 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/setshow.sh:
--------------------------------------------------------------------------------
1 | # setshow.sh - Helper routines for help/set/show
2 | #
3 | # Copyright (C) 2010, 2011 Rocky Bernstein
4 | #
5 | # This 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 | # 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 -l 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_internal $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="${cmd}: "
44 | typeset onoff='off'
45 | typeset -l 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 -l cmd="$1"
56 | typeset -l label="$2"
57 | typeset -l msg="$3"
58 | typeset -l variable_value
59 | eval_cmd="variable_value=\${_Dbg_set_$cmd}"
60 | eval $eval_cmd
61 | [[ -n $label ]] && label="set $cmd -- "
62 | typeset onoff="off."
63 | (( variable_value != 0 )) && onoff='on.'
64 | _Dbg_msg \
65 | "${label}${msg} is" $onoff
66 | return 0
67 | }
68 |
69 | # _Dbg_msg() {
70 | # print $*
71 | # }
72 |
73 | # for i in 0 1 ; do
74 | # _Dbg_foo=$i
75 | # _Dbg_help_set_onoff "foo" "foo" "Set short xx"
76 | # typeset -l _Dbg_foo
77 | # done
78 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/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 | _Dbg_shell_temp_profile="$_Dbg_tmpdir/.zshenv"
22 |
23 | zmodload -ap zsh/parameter parameters
24 | _Dbg_shell_variable_names() {
25 | echo ${(k@)parameters}
26 | }
27 |
28 | _Dbg_shell_variable_typeset() {
29 | typeset var=$1
30 | case ${parameters[$var]} in
31 | *export* )
32 | return 2
33 | ;;
34 | *special* )
35 | return 3
36 | ;;
37 | # This must come before local and *
38 | *readonly*)
39 | return 1
40 | ;;
41 | *local* | *)
42 | return 0
43 | ;;
44 | esac
45 | return 3
46 | }
47 |
48 | _Dbg_shell_append_typesets() {
49 | [[ -z $_Dbg_var_names ]] && _Dbg_var_names=(${(k@)parameters[@]})
50 | local _Dbg_profile
51 | _Dbg_profile=${1:-$_Dbg_shell_temp_profile}
52 | typeset _Dbg_set_debug
53 | _Dbg_set_debug=${2:-1}
54 |
55 | typeset -A exclude_list
56 | typeset var_set_cmd
57 | exclude_list[exclude_list]=1
58 | for var_name in ${_Dbg_var_names[@]}; do
59 | [[ -z $var_name ]] && continue
60 | ((_Dbg_set_debug)) && [[ $var_name =~ ^_Dbg_ ]] && continue
61 | ((exclude_list[var_name])) && continue
62 | _Dbg_shell_variable_typeset "$var_name"
63 | case $? in
64 | 0)
65 | typeset -p $var_name 2>/dev/null
66 | ;;
67 | 1)
68 | print "typeset -p ${var_name} 2>/dev/null 1>&2 || $(typeset -p $var_name)" 2>/dev/null
69 | ;;
70 | *)
71 | ;;
72 | esac
73 | done >>$_Dbg_profile
74 | }
75 |
76 | _Dbg_shell_append_fn_typesets() {
77 | typeset -a words
78 | typeset -pf | while read -a words ; do
79 | [[ declare != ${words[0]} ]] && continue
80 | fn_name=${words[2]%%=*}
81 | ((0 == _Dbg_set_debug)) && [[ $fn_name =~ ^_Dbg_ ]] && continue
82 | flags=${words[1]}
83 | echo $(typeset -pf ${fn_name} 2>/dev/null)
84 | done >>$_Dbg_shell_temp_profile
85 | }
86 |
87 | _Dbg_shell_new_shell_profile() {
88 | typeset -i _Dbg_o_vars; _Dbg_o_vars=${1:-1}
89 | typeset -i _Dbg_o_fns; _Dbg_o_fns=${2:-1}
90 |
91 | echo '# debugger shell profile' > $_Dbg_shell_temp_profile
92 |
93 | ((_Dbg_o_vars)) && _Dbg_shell_append_typesets
94 |
95 | # Add where file to allow us to restore info and
96 | # Routine use can call to mark which variables should persist
97 | typeset -p _Dbg_restore_info >> $_Dbg_shell_temp_profile
98 | echo "source ${_Dbg_libdir}/data/shell.sh" >> $_Dbg_shell_temp_profile
99 |
100 | ((_Dbg_o_fns)) && _Dbg_shell_append_fn_typesets
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/zshdb_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 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/tox.ini:
--------------------------------------------------------------------------------
1 | ; Settings file for flake8:
2 | ; http://flake8.readthedocs.org/en/latest/config.html#settings
3 | [flake8]
4 | exclude = .tox,./build,./trepan/processor/command/tmp
5 | filename = *.py
6 | ignore = C901,E113,E121,E122,E123,E124,E125,E126,E127,E128,E129,E201,E202,E203,E221,E222,E225,E226,E241,E242,E251,E261,E271,E272,E302,E401,E501,F401,E701,E702
7 |
--------------------------------------------------------------------------------
/zshdb_dir/lib/tty.sh:
--------------------------------------------------------------------------------
1 | # -*- shell-script -*-
2 | # Things related to tty
3 | #
4 | # Copyright (C) 2008, 2011 Rocky Bernstein
5 | #
6 | # zshdb 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 | # zshdb 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 zshdb; see the file COPYING. If not, write to the Free Software
18 | # Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
19 |
20 | #
21 | # Return 0 if $1 is a tty and open it. Otherwise return
22 | # 0. _Dbg_new_fdi will be set to the file descriptor of the open tty
23 | # or set to -1 if none could be opened.
24 | #
25 | # We write the interface this way because intead of say a routine to
26 | # test a name refers to a terminal, because it's easy to tell if a
27 | # file descriptor is a tty but not so easy using just the name. And we
28 | # want to avoid opening and closing file descriptors unnecessarily.
29 | #
30 | function _Dbg_open_if_tty {
31 | _Dbg_new_fd=-1
32 | (( $# != 1 )) && return 1
33 | [[ ! -w $1 ]] && return 1
34 | typeset -i r=1
35 | # Code modelled off of code from David Korn:
36 | {
37 | if exec ${_Dbg_new_fd} > $1 ; then
38 | if [[ -t $_Dbg_new_fd ]] ; then
39 | r=0
40 | else
41 | # Can't specify <> below like we did on the open
42 | # above, but since there's one input/output file
43 | # descriptor, in zsh both input and output are closed.
44 | exec {_Dbg_new_fd}<&-
45 | _Dbg_new_fd=-1
46 | fi
47 | fi
48 | } 2> /dev/null
49 |
50 | return $r
51 | }
52 |
53 | # Redirect input and output to tty $1
54 | # Stéphane Chazelas also suggests considering
55 | ## clone $tty
56 | function _Dbg_set_tty {
57 | if (( $# != 1 )) ; then
58 | _Dbg_errmsg "Need a single tty parameter; got $# args instead."
59 | return 1
60 | fi
61 | typeset -i _Dbg_new_fd
62 | if _Dbg_open_if_tty $1 ; then
63 | _Dbg_fdi=$_Dbg_new_fd
64 | _Dbg_fd[-1]=$_Dbg_fdi
65 | else
66 | _Dbg_errmsg "$1 is not reputed to be a tty."
67 | fi
68 | }
69 |
--------------------------------------------------------------------------------
/zshdb_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 |
26 | # _Dbg_is_alias returns 0 if $1 is an alias or nonzero otherwise.
27 | _Dbg_is_alias() {
28 | # setopt ksharrays # Done in _Dbg_debug_trap_handler
29 | (( 0 == $# )) && return 1
30 | typeset needed_alias=$1
31 | typeset al
32 | al=$(alias $needed_alias 2>&1)
33 | return $?
34 | }
35 |
36 | _Dbg_is_function() {
37 | # setopt ksharrays # Done in _Dbg_debug_trap_handler
38 | (( 0 == $# )) && return 1
39 | typeset needed_fn=$1
40 | typeset -i include_system=${2:-0}
41 | [[ ${needed_fn[0,0]} == '_' ]] && ((!include_system)) && {
42 | return 1
43 | }
44 | typeset fn
45 | fn=$(declare -f $needed_fn 2>&1)
46 | [[ -n "$fn" ]]
47 | return $?
48 | }
49 |
50 | # _Dbg_is_int returns 0 if $1 is an integer or nonzero otherwise.
51 | _Dbg_is_int() {
52 | (( 1 == $# )) || return 1
53 | if [[ $1 == [0-9]* ]] ; then
54 | return 0
55 | else
56 | return 1
57 | fi
58 | }
59 |
60 | # _Dbg_is_signed_int returns 0 if $1 is an integer or nonzero otherwise.
61 | _Dbg_is_signed_int() {
62 | (( 1 == $# )) || return 1
63 | if [[ $1 == [0-9]* ]] || [[ $1 == [+-][0-9]* ]] ; then
64 | return 0
65 | else
66 | return 1
67 | fi
68 | }
69 |
--------------------------------------------------------------------------------