Permalink
Browse files

Clean up before a kill -9. And some code clean ups.

  • Loading branch information...
1 parent a34b453 commit 73a9baf58e188a10295cd7a3ea24f7b7cace99dc @rocky committed Mar 27, 2011
Showing with 91 additions and 81 deletions.
  1. +2 −0 command/Makefile.am
  2. +29 −23 command/kill.sh
  3. +32 −31 kshdb.in
  4. +26 −25 lib/journal.sh
  5. +1 −1 test/data/restart.cmd
  6. +1 −1 test/data/restart.right
View
@@ -1,5 +1,7 @@
SUBDIRS = info_sub set_sub show_sub
+MOSTLYCLEANFILES = *.orig *.rej
+
pkgdatadir = ${datadir}/@PACKAGE@/command
pkgdata_DATA = \
alias.sh \
View
@@ -1,7 +1,7 @@
# -*- shell-script -*-
# gdb-like "kill" debugger command
#
-# Copyright (C) 2009 Rocky Bernstein rocky@gnu.org
+# Copyright (C) 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
@@ -29,26 +29,32 @@ The signal is sent to process \$\$ (which is $$ right now).
Also similar is the \"signal\" command." 1
-function _Dbg_do_kill {
- if (($# > 1)); then
- _Dbg_errmsg "Got $# parameters, but need 0 or 1."
- return 1
- fi
- typeset _Dbg_prompt_output=${_Dbg_tty:-/dev/null}
- typeset signal='-9'
- (($# == 1)) && signal="$1"
-
- if [[ ${signal:0:1} != '-' ]] ; then
- _Dbg_errmsg "Kill signal ($signal} should start with a '-'"
- return 1
- fi
-
- _Dbg_confirm "Send kill signal ${signal} which may terminate the debugger? (y/N): " 'N'
-
- if [[ $_Dbg_response == 'y' ]] ; then
- kill $signal $$
- else
- _Dbg_msg "Kill not done - not confirmed."
- fi
- return 0
+_Dbg_do_kill() {
+ if (($# > 1)); then
+ _Dbg_errmsg "Got $# parameters, but need 0 or 1."
+ return 1
+ fi
+ typeset _Dbg_prompt_output=${_Dbg_tty:-/dev/null}
+ typeset signal='-9'
+ (($# == 1)) && signal="$1"
+
+ if [[ ${signal:0:1} != '-' ]] ; then
+ _Dbg_errmsg "Kill signal ($signal) should start with a '-'"
+ return 2
+ fi
+
+ _Dbg_confirm "Send kill signal ${signal} which may terminate the debugger? (y/N): " 'N'
+
+ if [[ $_Dbg_response == [yY] ]] ; then
+ case $signal in
+ -9 | -SEGV )
+ _Dbg_cleanup2
+ ;;
+ esac
+ kill $signal $$
+ else
+ _Dbg_msg "Kill not done - not confirmed."
+ return 3
+ fi
+ return 0
}
View
@@ -1,22 +1,23 @@
#!@SH_PROG@
# -*- shell-script -*-
-# kshdb - top-level debugger program.
+# top-level debugger program.
#
-# Copyright (C) 2008, 2009 Rocky Bernstein rocky@gnu.org
+# Copyright (C) 2008, 2009, 2011 Rocky Bernstein <rocky@gnu.org>
#
-# kshdb 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 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.
#
-# kshdb 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.
+# 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 kshdb; see the file COPYING. If not, write to the Free Software
-# Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+# 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
@@ -55,17 +56,17 @@ 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
+ ((_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 kshdb is installed wrong (if its installed)." >&2
- echo "${_Dbg_pname}: Try running kshdb using -L (with a different directory)." >&2
- echo "${_Dbg_pname}: Run kshdb --help for a list and explanation of options." >&2
+ 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
@@ -99,13 +100,13 @@ fi
if (( ${#_Dbg_script_args[@]} > 0 )) ; then
_Dbg_script_file="${_Dbg_script_args[0]}"
case ${_Dbg_script_file:0:1} in
- '.' | '/' )
- # Leave alone
- ;;
+ '.' | '/' )
+ # Leave alone
+ ;;
* )
- # Make . explicit.
- _Dbg_script_file="./${_Dbg_script_file}"
- _Dbg_script_args[0]="$_Dbg_script_file"
+ # Make . explicit.
+ _Dbg_script_file="./${_Dbg_script_file}"
+ _Dbg_script_args[0]="$_Dbg_script_file"
esac
# FIXME:
# shift _Dbg_script_args
@@ -130,12 +131,12 @@ while : ; do
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."
+ _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
+ _Dbg_msg ''
+ break
fi
done
View
@@ -1,21 +1,22 @@
# -*- shell-script -*-
# Things related to variable journaling.
#
-# Copyright (C) 2008 Rocky Bernstein rocky@gnu.org
+# Copyright (C) 2008, 2011 Rocky Bernstein <rocky@gnu.org>
#
-# kshdb 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 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.
#
-# kshdb 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.
+# 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 kshdb; see the file COPYING. If not, write to the Free Software
-# Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+# 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.
# We use a journal file to save variable state so that we can pass
# values set in a subshell or nested shell back. This typically
@@ -27,26 +28,26 @@ typeset _Dbg_journal=$(_Dbg_tempname journal)
# append a command into journal file and then run the command.
_Dbg_write_journal_eval() {
- _Dbg_write_journal "$@"
- eval "$@"
+ _Dbg_write_journal "$@"
+ eval "$@"
}
# append a command into journal file and then run the command.
_Dbg_write_journal_var() {
- typeset var_name=$1
- typeset val
- typeset val_cmd="$val=\${$var_name}"
- eval $val_cmd
- _Dbg_write_journal "${var_name}=${val}"
+ typeset var_name="$1"
+ typeset val
+ typeset val_cmd="$val=\${$var_name}"
+ eval "$val_cmd"
+ _Dbg_write_journal "${var_name}=${val}"
}
_Dbg_write_journal_avar() {
- typeset decl_str=$(declare -p $1)
- typeset -a decl_a
- decl_a=($decl_str)
- typeset -a decl_a2
- decl_a2=${decl_a[@]:2}
- _Dbg_write_journal ${decl_a2[@]}
+ typeset decl_str; decl_str=$(declare -p $1)
+ typeset -a decl_a
+ decl_a=($decl_str)
+ typeset -a decl_a2
+ decl_a2=${decl_a[@]:2}
+ _Dbg_write_journal ${decl_a2[@]}
}
# Append a command into journal file. But we only need to do
@@ -4,7 +4,7 @@ list
step
step
break 5
-restart -B -q -L ../.. -x ../../test/data/restart2.cmd ../../test/example/restart.sh
+restart -B -n -q -L ../.. -x ../../test/data/restart2.cmd ../../test/example/restart.sh
# We never get here
print You should not see this.
quit
@@ -17,7 +17,7 @@ cd /
y=2
+break 5
Breakpoint 1 set in file restart.sh, line 5.
-+run -B -q -L ... restart.sh
++run -B -n -q -L ... restart.sh
Restarting with ... restart.sh
(restart.sh:4):
x=1

0 comments on commit 73a9baf

Please sign in to comment.