Skip to content

Commit

Permalink
Resolve file paths in "backtrace"
Browse files Browse the repository at this point in the history
Save mapping when doing "load" command
resolve filename in "backtrace" command
  • Loading branch information
rocky committed Dec 8, 2024
1 parent cd4d498 commit 3fc8fea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions command/backtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -168,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]}"
Expand Down
4 changes: 3 additions & 1 deletion command/load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Debugger load SCRIPT command.
#
# Copyright (C) 2002-2006, 2008, 2010-2011, 2018-2019 Rocky
# Bernstein <rocky@gnu.org>
# 2024 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
Expand Down Expand Up @@ -54,6 +54,8 @@ _Dbg_do_load() {

_Dbg_readin "$_Dbg_full_filename"
_Dbg_msg "File $_Dbg_full_filename loaded."
_Dbg_file2canonic["${_Dbg_filename}"]="$_Dbg_full_filename"

else
_Dbg_errmsg "Couldn't resolve or read $_Dbg_filename"
return 3
Expand Down

0 comments on commit 3fc8fea

Please sign in to comment.