Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 143 lines (122 sloc) 4.765 kB
#!@SH_PROG@
# -*- shell-script -*-
# top-level debugger program.
#
# Copyright (C) 2008, 2009, 2011 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.
# This routine gets called via the -c or --command option and its sole
# purpose is to capture the command string such as via "x $*" or
# in a traceback ("where").
function _Dbg_eval {
eval $* # Type: "x $*" to see what's being run.
}
typeset -a _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 ###
typeset prefix=@prefix@
typeset _Dbg_libdir=@PKGDATADIR@
###
# 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 release name we are configured to run under.
typeset _Dbg_release='@PACKAGE_VERSION@'
# The short shell name. Helps keep code common in bash, zsh, and ksh debuggers.
typeset _Dbg_shell_name=${_Dbg_shell##*/} # Equivalent to basename(_Dbg_shell)
# Parse just the libdir option
typeset -i _Dbg_i
for ((_Dbg_i=0; $_Dbg_i<${#_Dbg_script_args[@]}-1; _Dbg_i++)) ; do
typeset arg=${_Dbg_script_args[$_Dbg_i]}
if [[ $arg == '-L' || $arg == '--libdir' ]] ; then
((_Dbg_i++))
_Dbg_libdir="${_Dbg_script_args[$_Dbg_i]}"
break
fi
done
if [[ ! -d $_Dbg_libdir ]] && [[ ! -d $_Dbg_libdir ]] ; then
echo "${_Dbg_pname}: Can't read debugger library directory '${_Dbg_libdir}'."
echo "${_Dbg_pname}: Perhaps @PACKAGE@ is installed wrong (if its installed)." >&2
echo "${_Dbg_pname}: Try running @PACKAGE@ using -L (with a different directory)." >&2
echo "${_Dbg_pname}: Run @PACKAGE@ --help for a list and explanation of options." >&2
exit 1
fi
# [[ $# == 0 && -z $show_version && -z $_Dbg_cmd ]] && {
# echo "${_Dbg_pname}: Need to give a script name to debug."
# exit 1
# }
# 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
_Dbg_set_debugger_entry
# Note that this is called via kshdb rather than "ksh --debugger" or kshdb-trace
_Dbg_script=1
if [[ -n $_Dbg_EXECUTION_STRING ]] ; then
_Dbg_script_file=$(_Dbg_tempname cmd)
echo "$_Dbg_EXECUTION_STRING" >$_Dbg_script_file
fi
if (( ${#_Dbg_script_args[@]} > 0 )) ; then
_Dbg_script_file="${_Dbg_script_args[0]}"
case ${_Dbg_script_file:0:1} in
'.' | '/' )
# Leave alone
;;
* )
# Make . explicit.
_Dbg_script_file="./${_Dbg_script_file}"
_Dbg_script_args[0]="$_Dbg_script_file"
esac
# FIXME:
# shift _Dbg_script_args
elif [[ -z $_Dbg_EXECUTION_STRING ]] ; then
echo >&2 "${_Dbg_pname}: need to give a script to debug or use the -c option."
exit 1
fi
if [[ ! -r "$_Dbg_script_file" ]] ; then
echo "${_Dbg_pname}: cannot read program to debug: $_Dbg_script_file." >&2
exit 1
fi
_Dbg_step_ignore=2
while : ; do
# We need to escape the script arguments in case there are
# embedded blanks say in the debugged script filename. The below
# two lines are the only way I know how to do this. Perhaps
# there's a simpler way?
source_cmd=$(printf '%q ' "${_Dbg_script_args[@]}")
eval " trap '_Dbg_trap_handler $? \"$@\"' DEBUG; source $source_cmd"
trap '' DEBUG
_Dbg_msg_nocr 'Program terminated.'
if (( !o_no_quit )); then
_Dbg_msg "Type 's' to restart."
_Dbg_process_commands
_Dbg_step_ignore=2
# _Dbg_msg "Type 's' or 'R' to restart."
else
_Dbg_msg ''
break
fi
done
Jump to Line
Something went wrong with that request. Please try again.