-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
dbg-trace.sh.in
79 lines (66 loc) · 2.59 KB
/
dbg-trace.sh.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- shell-script -*-
# This program needs to be SOURCE'd and is not called as an executable
#
# Copyright (C) 2008, 2011, 2024 Rocky Bernstein <rocky@gnu.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
# MA 02111 USA.
typeset _Dbg_trace_old_set_opts
_Dbg_trace_old_set_opts=$-
set +u
# Name we refer to ourselves by
typeset _Dbg_debugger_name='@PACKAGE@'
# The shell we are configured to run under.
typeset _Dbg_shell='@SH_PROG@'
# The short shell name. Helps keep code common in bash, zsh, and ksh debuggers.
# Equivalent to
typeset _Dbg_shell_name="${_Dbg_shell##*/}"
typeset -a _Dbg_script_args; _Dbg_script_args=("$@")
# Original $0. Note we can't set this in an include.
typeset _Dbg_orig_0="$0"
# Equivalent to basename $0; the short program name
typeset _Dbg_pname="${0##*/}"
## Stuff set by autoconf/configure ###
# @PKGDATADIR@ often uses $prefix, _Dbg_libdir must be a global variable
function { typeset prefix="@prefix@"; _Dbg_libdir="@PKGDATADIR@"; }
###
[[ ! -d "$_Dbg_libdir" ]] && _Dbg_libdir='.'
# Parse just the libdir option
typeset -a libdir
zparseopts -a libdir -E L: -library:
if (( ${#libdir} > 0 )) ; then
typeset -a lib_opts; eval "lib_opts=($libdir)"
if [[ ! -d "${lib_opts[2]}" ]] ; then
print "${lib_opts[2]} is not a directory"
exit 1
fi
_Dbg_libdir="${lib_opts[2]}"
unset lib_opts
fi
# Pull in the rest of the debugger code.
typeset _Dbg_main="$_Dbg_libdir/dbg-main.sh"
if [[ ! -r "$_Dbg_main" ]] ; then
print "${_Dbg_pname}: Can't read debugger library file '${_Dbg_main}'."
print "${_Dbg_pname}: Perhaps @PACKAGE@ is installed wrong (if its installed)." >&2
print "${_Dbg_pname}: Try running @PACKAGE@ using -L (with a different directory)." >&2
print "${_Dbg_pname}: Run @PACKAGE@ --help for a list and explanation of options." >&2
exit 1
fi
. "${_Dbg_libdir}/dbg-main.sh"
set -${_Dbg_trace_old_set_opts}
unset _Dbg_trace_old_set_opts
_Dbg_debugger() {
trap '_Dbg_trap_handler $? "$0" "$@"' DEBUG
}