diff --git a/command/load.sh b/command/load.sh index cd3591e..a50364a 100644 --- a/command/load.sh +++ b/command/load.sh @@ -53,6 +53,7 @@ _Dbg_do_load() { done _Dbg_readin "$_Dbg_full_filename" + _Dbg_file2canonic["${_Dbg_filename}"]="$_Dbg_full_filename" _Dbg_msg "File $_Dbg_full_filename loaded." else _Dbg_errmsg "Couldn't resolve or read $_Dbg_filename" diff --git a/lib/break.sh b/lib/break.sh index 449a3aa..94dc3e8 100644 --- a/lib/break.sh +++ b/lib/break.sh @@ -247,11 +247,12 @@ _Dbg_set_brkpt() { _Dbg_write_journal_eval "_Dbg_brkpt_file2linenos[\"$source_file\"]+=\" $lineno \"" _Dbg_write_journal_eval "_Dbg_brkpt_file2brkpt[\"$source_file\"]+=\" $_Dbg_brkpt_max \"" - source_file=$(_Dbg_adjust_filename "$source_file") + resolved_source_file=$(_Dbg_adjust_filename "$source_file") + _Dbg_file2canonic["$source_file"]="$resolved_source_file" if (( is_temp == 0 )) ; then - _Dbg_msg "Breakpoint $_Dbg_brkpt_max set in file ${source_file}, line $lineno." + _Dbg_msg "Breakpoint $_Dbg_brkpt_max set in file ${resolved_source_file}, line $lineno." else - _Dbg_msg "One-time breakpoint $_Dbg_brkpt_max set in file ${source_file}, line $lineno." + _Dbg_msg "One-time breakpoint $_Dbg_brkpt_max set in file ${resolved_source_file}, line $lineno." fi _Dbg_write_journal "_Dbg_brkpt_max=$_Dbg_brkpt_max" return 0 diff --git a/lib/filecache.sh b/lib/filecache.sh index 3ee92a9..bbef239 100644 --- a/lib/filecache.sh +++ b/lib/filecache.sh @@ -2,7 +2,7 @@ # filecache.sh - cache file information # # Copyright (C) 2008-2011, 2013-2015, 2018-2019 Rocky Bernstein -# +# 2024 # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -63,7 +63,7 @@ _Dbg_check_line() { # Error message for file not read in function _Dbg_file_not_read_in { typeset -r filename=$(_Dbg_adjust_filename "$1") - _Dbg_errmsg "File \"$filename\" not found in read-in files." + _Dbg_errmsg "File \"$filename\" ($1) not found in read-in files." _Dbg_errmsg "See 'info files' for a list of known files and" _Dbg_errmsg "'load' to read in a file." } @@ -106,7 +106,9 @@ _Dbg_get_source_line() { filename="$1" fi _Dbg_readin_if_new "$filename" - if [[ -n $_Dbg_set_highlight ]] && [[ -n $_Dbg_highlight_array_var ]]; then + if [[ -z "$_Dbg_source_array_var" ]]; then + _Dbg_source_line="??" + elif [[ -n $_Dbg_set_highlight ]] && [[ -n $_Dbg_highlight_array_var ]]; then eval "typeset -i count=\${#$_Dbg_highlight_array_var[@]}" if (( count )) ; then eval "_Dbg_source_line=\${$_Dbg_highlight_array_var[lineno]}" @@ -244,7 +246,11 @@ function _Dbg_readin { (( line_count >= NOT_SMALLFILE )) && _Dbg_msg "done." # Add $filename to list of all filenames - _Dbg_filenames["$fullname"]=$_Dbg_source_array_var; + if [[ ! -z $fullname ]] ; then + _Dbg_filenames["$fullname"]=$_Dbg_source_array_var; + else + echo "XXX ${filename}" + fi return 0 } diff --git a/lib/hook.sh b/lib/hook.sh index df77e79..0406233 100644 --- a/lib/hook.sh +++ b/lib/hook.sh @@ -148,6 +148,7 @@ _Dbg_debug_trap_handler() { 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" _Dbg_file2canonic["${BASH_SOURCE[1]}"]="$_Dbg_full_filename" diff --git a/lib/list.sh b/lib/list.sh index 947458b..4b22431 100644 --- a/lib/list.sh +++ b/lib/list.sh @@ -36,10 +36,14 @@ typeset _Dbg_source_line function _Dbg_print_location_and_command { typeset line_number=${1:-$_Dbg_frame_last_lineno} typeset filename=${2:-$_Dbg_frame_last_filename} - _Dbg_get_source_line $line_number "$filename" - filename=$(_Dbg_adjust_filename "$filename") - _Dbg_msg "(${filename}:${line_number}): + if [[ -z "$filename" ]] ; then + _Dbg_msg "(??:${line_number}):" + else + _Dbg_get_source_line $line_number "$filename" + filename=$(_Dbg_adjust_filename "$filename") + _Dbg_msg "(${filename}:${line_number}): ${line_number}:\t${_Dbg_source_line}" + fi # If we are at the same place in the file but the command has changed, # then we have multiple commands on the line. So print which one we are diff --git a/lib/save-restore.sh b/lib/save-restore.sh index e84e524..4e6e090 100644 --- a/lib/save-restore.sh +++ b/lib/save-restore.sh @@ -87,8 +87,11 @@ function _Dbg_set_debugger_entry { _Dbg_stack_pos=_0 _Dbg_listline=_Dbg_frame_last_lineno _Dbg_set_debugger_internal - _Dbg_frame_last_filename=${BASH_SOURCE[$discard_top_fn_count]:-$_Dbg_bogus_file} - _Dbg_frame_last_filename=$(_Dbg_resolve_expand_filename "$_Dbg_frame_last_filename") + typeset -l frame_last_filename=${BASH_SOURCE[$discard_top_fn_count]:-$_Dbg_bogus_file} + _Dbg_frame_last_filename=$(_Dbg_resolve_expand_filename "$frame_last_filename") + if [[ -z "$_Dbg_frame_last_filename" ]]; then + _Dbg_frame_last_filename="$frame_last_filename" + fi # Read in the journal to pick up variable settings that might have # been left from a subshell.