-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make -S --style option work... And bump copyright * Resolve filenames in `backtrace` command (#54) * Resolve file paths in "backtrace" * Save mapping when doing the "load" command; resolve the filename in the "backtrace" command * Add a test for the "load" command --------- Co-authored-by: Joachim Ansorg <[email protected]> * Save more file information from initial call... In particular, resolve the initial source directory and store that as _Dbg_init_dir. Resolve the name of main bash program and add that to canonicalized filenames. * Update bashdb.in Co-authored-by: Joachim Ansorg <[email protected]> * Update lib/hook.sh Co-authored-by: Joachim Ansorg <[email protected]> * Update bashdb.in Co-authored-by: Joachim Ansorg <[email protected]> * Add more places we resolve/expand files In some cases though automatic file loading no longer happens. In particular, on "list" and "break" commands. * One more quoted statement. --------- Co-authored-by: rocky <[email protected]> Co-authored-by: R. Bernstein <[email protected]>
- Loading branch information
1 parent
beb6106
commit 248cb7d
Showing
22 changed files
with
189 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# Top-level debugger program. This program may be initially invoked. | ||
# | ||
# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, | ||
# 2009, 2010, 2011 Rocky Bernstein <[email protected]> | ||
# 2009, 2010, 2011, 2019 Rocky Bernstein <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License as | ||
|
@@ -62,6 +62,7 @@ _Dbg_assign_libdir() { typeset prefix="@prefix@"; _Dbg_libdir="@PKGDATADIR@"; }; | |
# supplied over any of the above guesses. Go over options and parse | ||
# just the library option. | ||
typeset -xa _Dbg_script_args; _Dbg_script_args=("$@") | ||
|
||
typeset -i _Dbg_i | ||
for ((_Dbg_i=0; _Dbg_i<${#_Dbg_script_args[@]}-1; _Dbg_i++)) ; do | ||
typeset _Dbg_script_arg=${_Dbg_script_args[$_Dbg_i]} | ||
|
@@ -94,6 +95,16 @@ if [[ ! -r "$_Dbg_main" ]] ; then | |
fi | ||
|
||
. "${_Dbg_libdir}/@[email protected]" | ||
|
||
# Resolve and save mapping for main script, and resolve | ||
# the starting directory. | ||
_Dbg_full_filename="$(_Dbg_is_file "$_Dbg_script_file")" | ||
_Dbg_file2canonic["${_Dbg_script_file}"]="$_Dbg_full_filename" | ||
# Note: expand_filename is expanding a *directory* here, not a filename. | ||
# This might cause a problem in the future if _Dbg_expand_filename becomes | ||
# more specific about this aspect. | ||
_Dbg_init_cwd="$(_Dbg_expand_filename "${_Dbg_script_file%/*}")" | ||
|
||
trap '_Dbg_debug_trap_handler 0 "$BASH_COMMAND" "$@"' DEBUG | ||
set -o functrace | ||
. "$_Dbg_script_file" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# gdb-like "backtrace" debugger command | ||
# | ||
# Copyright (C) 2002-2006, 2008, 2010-2011, 2018-2019 | ||
# Rocky Bernstein <[email protected]> | ||
# 2024 Rocky Bernstein <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License as | ||
|
@@ -129,7 +129,8 @@ function _Dbg_do_backtrace { | |
if (( frame_start == 0 )) ; then | ||
((count--)) ; | ||
adjusted_pos=$(_Dbg_frame_adjusted_pos 0) | ||
filename=$(_Dbg_file_canonic "${BASH_SOURCE[$adjusted_pos]}") | ||
filename="$(_Dbg_resolve_expand_filename "${BASH_SOURCE[$adjusted_pos]}")" | ||
filename="$(_Dbg_adjust_filename "$filename")" | ||
_Dbg_frame_print $(_Dbg_frame_prefix 0) '0' '' "$filename" "$_Dbg_frame_last_lineno" '' | ||
fi | ||
|
||
|
@@ -153,8 +154,6 @@ function _Dbg_do_backtrace { | |
adjusted_pos=$(_Dbg_frame_adjusted_pos $i) | ||
_Dbg_msg_nocr $(_Dbg_frame_prefix $i)$i ${FUNCNAME[$adjusted_pos-1]} | ||
|
||
typeset parms='' | ||
|
||
# Print out parameter list. | ||
if (( 0 != ${#BASH_ARGC[@]} )) ; then | ||
_Dbg_frame_fn_param_str | ||
|
@@ -170,7 +169,8 @@ function _Dbg_do_backtrace { | |
else | ||
lineno=${BASH_LINENO[$adjusted_pos-1]} | ||
fi | ||
filename=$(_Dbg_file_canonic "${BASH_SOURCE[$adjusted_pos]}") | ||
filename="$(_Dbg_resolve_expand_filename "${BASH_SOURCE[$adjusted_pos]}")" | ||
filename="$(_Dbg_adjust_filename "$filename")" | ||
_Dbg_msg "($_Dbg_parm_str) called from file \`$filename'" "at line $lineno" | ||
if (( show_source )) ; then | ||
_Dbg_get_source_line $lineno "${BASH_SOURCE[$adjusted_pos]}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# Debugger load SCRIPT command. | ||
# | ||
# Copyright (C) 2002-2006, 2008, 2010-2011, 2018-2019 Rocky | ||
# Bernstein <[email protected]> | ||
# 2024 Bernstein <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License as | ||
|
@@ -52,7 +52,13 @@ _Dbg_do_load() { | |
done | ||
|
||
_Dbg_readin "$_Dbg_full_filename" | ||
_Dbg_msg "File $_Dbg_full_filename loaded." | ||
if (( _Dbg_set_basename )) ; then | ||
_Dbg_msg "File $_Dbg_filename loaded." | ||
else | ||
_Dbg_msg "File $_Dbg_full_filename loaded." | ||
fi | ||
_Dbg_file2canonic["${_Dbg_filename}"]="$_Dbg_full_filename" | ||
|
||
else | ||
_Dbg_errmsg "Couldn't resolve or read $_Dbg_filename" | ||
return 3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
dnl Process this file with autoconf to produce a configure script. | ||
|
||
# Copyright (C) 2002-2012, | ||
# 2014-2019, 2023 Rocky Bernstein <[email protected]> | ||
# 2014-2019, 2023-2024 Rocky Bernstein <[email protected]> | ||
|
||
# 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 | ||
|
@@ -254,6 +254,8 @@ AC_CONFIG_FILES([test/unit/test-cmd-info-variables.sh], | |
[chmod +x test/unit/test-cmd-info-variables.sh]) | ||
AC_CONFIG_FILES([test/unit/test-cmd-eval.sh], | ||
[chmod +x test/unit/test-cmd-eval.sh]) | ||
AC_CONFIG_FILES([test/unit/test-cmd-load.sh], | ||
[chmod +x test/unit/test-cmd-load.sh]) | ||
AC_CONFIG_FILES([test/unit/test-columns.sh], | ||
[chmod +x test/unit/test-columns.sh]) | ||
AC_CONFIG_FILES([test/unit/test-eval.sh], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# -*- shell-script -*- | ||
# debugger command options processing. The bane of programming. | ||
# | ||
# Copyright (C) 2008-2012, 2014-2019, 2021 Rocky Bernstein <[email protected]> | ||
# Copyright (C) 2008-2012, 2014-2019, 2021, 2023-2024 | ||
# Rocky Bernstein <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License as | ||
|
@@ -94,9 +95,11 @@ if ( pygmentize --version || pygmentize -V ) 2>/dev/null 1>/dev/null ; then | |
fi | ||
|
||
typeset -ix _Dbg_working_term_highlight | ||
typeset -x _Dbg_pygments_styles='' | ||
|
||
if "${_Dbg_libdir}/lib/term-highlight.py" -V 2>/dev/null 1>/dev/null ; then | ||
_Dbg_working_term_highlight=1 | ||
_Dbg_pygments_styles=$("${_Dbg_libdir}/lib/term-highlight.py" -L) | ||
else | ||
_Dbg_working_term_highlight=0 | ||
fi | ||
|
@@ -132,7 +135,7 @@ _Dbg_parse_options() { | |
typeset -i _Dbg_highlight_enabled=1 | ||
typeset OPTLARG OPTLERR OPTLPENDING opt | ||
|
||
while getopts_long A:Bc:x:hL:nqTt:Yy:VX opt \ | ||
while getopts_long A:Bc:x:hL:nqS:T:t:Yy:VX opt \ | ||
annotate required_argument \ | ||
basename no_argument \ | ||
command required_argument \ | ||
|
@@ -146,6 +149,7 @@ _Dbg_parse_options() { | |
no-init no_argument \ | ||
nx no_argument \ | ||
quiet no_argument \ | ||
style required_argument \ | ||
tempdir required_argument \ | ||
tty required_argument \ | ||
terminal required_argument \ | ||
|
@@ -177,8 +181,8 @@ _Dbg_parse_options() { | |
esac | ||
|
||
if (( ! _Dbg_have_working_pygmentize )) ; then | ||
printf "Can't run pygmentize. --highlight forced off" >&2 | ||
_Dbg_highlight_enabled=0 | ||
printf "Can't run pygmentize. --highlight forced off." >&2 | ||
_Dbg_highlight_enabled=0 | ||
_Dbg_set_highlight='' | ||
fi | ||
;; | ||
|
@@ -197,6 +201,15 @@ _Dbg_parse_options() { | |
_Dbg_o_nx=1 ;; | ||
q | quiet ) | ||
_Dbg_o_quiet=1 ;; | ||
S | style ) | ||
if (( ! _Dbg_have_working_pygmentize )) ; then | ||
printf "Can't run pygmentize. --style option ignored." >&2 | ||
elif [[ "${_Dbg_pygments_styles#*$OPTLARG}" != "$_Dbg_pygments_styles" ]] ; then | ||
_Dbg_set_style="$OPTLARG" | ||
else | ||
printf "Can't find style ${OPTLARG}; --style option ignored." >&1 | ||
fi | ||
;; | ||
tempdir) | ||
_Dbg_tmpdir=$OPTLARG ;; | ||
terminal | tty ) | ||
|
@@ -230,7 +243,7 @@ _Dbg_parse_options() { | |
[[ -n $_Dbg_release ]] ; then | ||
echo "$_Dbg_shell_name debugger, $_Dbg_debugger_name, release $_Dbg_release" | ||
printf ' | ||
Copyright 2002-2004, 2006-2012, 2014, 2016-2019, 2021 Rocky Bernstein | ||
Copyright 2002-2004, 2006-2012, 2014, 2016-2019, 2021, 2023-2024 Rocky Bernstein | ||
This is free software, covered by the GNU General Public License, and you are | ||
welcome to change it and/or distribute copies of it under certain conditions. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# hook.sh - Debugger trap hook | ||
# | ||
# Copyright (C) 2002-2011, 2014, 2017-2019 | ||
# Rocky Bernstein <[email protected]> | ||
# 2024 Rocky Bernstein <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License as | ||
|
@@ -119,6 +119,13 @@ _Dbg_debug_trap_handler() { | |
|
||
_Dbg_save_args "$@" | ||
|
||
typeset _Dbg_full_filename | ||
_Dbg_full_filename="$(_Dbg_is_file "${BASH_SOURCE[1]}")" | ||
if [[ -r "$_Dbg_full_filename" ]] ; then | ||
_Dbg_file2canonic["${BASH_SOURCE[1]}"]="$_Dbg_full_filename" | ||
fi | ||
|
||
|
||
# if in step mode, decrement counter | ||
if ((_Dbg_step_ignore > 0)) ; then | ||
((_Dbg_step_ignore--)) | ||
|
@@ -146,12 +153,6 @@ _Dbg_debug_trap_handler() { | |
fi | ||
done | ||
|
||
typeset _Dbg_full_filename | ||
_Dbg_full_filename=$(_Dbg_is_file "$_Dbg_frame_last_filename") | ||
if [[ -r "$_Dbg_full_filename" ]] ; then | ||
_Dbg_file2canonic["$_Dbg_frame_last_filename"]="$_Dbg_full_filename" | ||
fi | ||
|
||
# Run applicable action statement | ||
if ((_Dbg_action_count > 0)) ; then | ||
_Dbg_hook_action_hit "$_Dbg_full_filename" | ||
|
Oops, something went wrong.