File tree Expand file tree Collapse file tree 9 files changed +26
-17
lines changed Expand file tree Collapse file tree 9 files changed +26
-17
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,15 @@ if [[ -n $_Dbg_script_file ]] ; then
102
102
fi
103
103
typeset _Dbg_dollar_0=" $0 "
104
104
105
+ # Resolve and save mapping for main script, and resolve
106
+ # the starting directory.
107
+ _Dbg_full_filename=$( _Dbg_is_file " $_Dbg_script_file " )
108
+ _Dbg_file2canonic[" ${_Dbg_script_file} " ]=" $_Dbg_full_filename "
109
+ # Note: expand_filename is expanding a *directory* here, not a filename.
110
+ # This might cause a problem in the future if _Dbg_expand_filename becomes
111
+ # more specific about this aspect.
112
+ _Dbg_init_cwd=$( _Dbg_expand_filename " ${_Dbg_script_file%/* } " )
113
+
105
114
trap ' _Dbg_debug_trap_handler 0 "$BASH_COMMAND" "$@"' DEBUG
106
115
set -o functrace
107
116
. " $_Dbg_script_file "
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ function _Dbg_resolve_expand_filename {
96
96
full_find_file=$( _Dbg_expand_filename " ${_Dbg_init_cwd} /$find_file " )
97
97
if [[ -z " $full_find_file " ]] || [[ ! -r $full_find_file ]]; then
98
98
# Try using cwd rather that Dbg_init_cwd
99
- full_find_file=$( _Dbg_expand_filename " $find_file " )
99
+ full_find_file=$( _Dbg_expand_filename " $find_file " ) s
100
100
fi
101
101
echo " $full_find_file "
102
102
return 0
Original file line number Diff line number Diff line change @@ -119,6 +119,13 @@ _Dbg_debug_trap_handler() {
119
119
120
120
_Dbg_save_args " $@ "
121
121
122
+ typeset _Dbg_full_filename
123
+ _Dbg_full_filename=$( _Dbg_is_file " ${BASH_SOURCE[1]} " )
124
+ if [[ -r " $_Dbg_full_filename " ]] ; then
125
+ _Dbg_file2canonic[" ${BASH_SOURCE[1]} " ]=" $_Dbg_full_filename "
126
+ fi
127
+
128
+
122
129
# if in step mode, decrement counter
123
130
if (( _Dbg_step_ignore > 0 )) ; then
124
131
(( _Dbg_step_ignore-- ))
@@ -146,13 +153,6 @@ _Dbg_debug_trap_handler() {
146
153
fi
147
154
done
148
155
149
- typeset _Dbg_full_filename
150
- _Dbg_full_filename=$( _Dbg_is_file " $_Dbg_frame_last_filename " )
151
- if [[ -r " $_Dbg_full_filename " ]] ; then
152
- _Dbg_file2canonic[" $_Dbg_frame_last_filename " ]=" $_Dbg_full_filename "
153
- _Dbg_file2canonic[" ${BASH_SOURCE[1]} " ]=" $_Dbg_full_filename "
154
- fi
155
-
156
156
# Run applicable action statement
157
157
if (( _Dbg_action_count > 0 )) ; then
158
158
_Dbg_hook_action_hit " $_Dbg_full_filename "
Original file line number Diff line number Diff line change @@ -248,7 +248,7 @@ Num Type Enb Expression
248
248
breakpoint already hit 1 time
249
249
No actions have been set.
250
250
+cont
251
- FUNCNAME[2]: source called from bashdb at line 107
251
+ FUNCNAME[2]: source called from bashdb at line 116
252
252
Breakpoint 6 hit (3 times).
253
253
(dbg-test1.sub:11):
254
254
11: local -i j=i+1
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ i=1 result=Breakpoint 1 hit (1 times).
17
17
+bt
18
18
->0 in file `fib.sh' at line 5
19
19
##1 fibonacci("1") called from file `fib.sh' at line 18
20
- ##2 source("fib.sh") called from file `bashdb' at line 107
20
+ ##2 source("fib.sh") called from file `bashdb' at line 116
21
21
##3 main() called from file `bashdb' at line 0
22
22
+delete 1
23
23
Deleted breakpoint 1
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ SOURCED BASH_SOURCE[0] dbg-test1.sub
15
15
SOURCED FN LINENO 5
16
16
FUNCNAME[0]: sourced_fn called from dbg-test1.sub at line 22
17
17
FUNCNAME[1]: source called from dbg-test1.sh at line 34
18
- FUNCNAME[2]: source called from bashdb at line 107
18
+ FUNCNAME[2]: source called from bashdb at line 116
19
19
FUNCNAME[3]: main called from bashdb at line 0
20
20
(dbg-test1.sh:35):
21
21
35: exit 0;
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ SOURCED BASH_SOURCE[0] dbg-test1.sub
48
48
SOURCED FN LINENO 5
49
49
FUNCNAME[0]: sourced_fn called from dbg-test1.sub at line 22
50
50
FUNCNAME[1]: source called from dbg-test1.sh at line 34
51
- FUNCNAME[2]: source called from bashdb at line 107
51
+ FUNCNAME[2]: source called from bashdb at line 116
52
52
FUNCNAME[3]: main called from bashdb at line 0
53
53
Debugged program terminated normally. Use q to quit or R to restart.
54
54
+### Try some commands that require a running debugger
Original file line number Diff line number Diff line change @@ -66,12 +66,12 @@ Restarting with: /src/external-vcs/sourceforge/bashdb/bashdb -B --no-highlight -
66
66
Watchpoint 2: $x changed:
67
67
old value: '22'
68
68
new value: ''
69
- (bashdb:106 ):
70
- 106 : set -o functrace
69
+ (bashdb:115 ):
70
+ 115 : set -o functrace
71
71
+# 2nd part of Restart test
72
72
+l>
73
- 106 : => set -o functrace
74
- 107 : . "$_Dbg_script_file"
73
+ 115 : => set -o functrace
74
+ 116 : . "$_Dbg_script_file"
75
75
+info watch
76
76
Num Type Enb Expression
77
77
------------------------------
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ test_file_resolve_expand_filename()
91
91
filename=$( _Dbg_resolve_expand_filename ./fdafdsa)
92
92
assertEquals ' 0' $?
93
93
typeset -i size=${# filename}
94
- assertEquals ' /fdafdsa ' " ${filename: $size -8} "
94
+ assertEquals ' fdafdsas ' " ${filename: $size -8} "
95
95
assertNotEquals ' .' " ${filename: $size -1} "
96
96
}
97
97
You can’t perform that action at this time.
0 commit comments