Skip to content

Commit

Permalink
An attempt to solve problem/screenshot 2
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Dec 6, 2024
1 parent 7d2cd69 commit b669759
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions command/load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions lib/break.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions lib/filecache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# filecache.sh - cache file information
#
# Copyright (C) 2008-2011, 2013-2015, 2018-2019 Rocky Bernstein
# <[email protected]>
# 2024 <[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
Expand Down Expand Up @@ -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."
}
Expand Down Expand Up @@ -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]}"
Expand Down Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions lib/hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 7 additions & 3 deletions lib/list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions lib/save-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b669759

Please sign in to comment.