You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Printing variables in stack frames other than the current one gives incorrect results. Consider the program,
load system io.
function fact
with 0 do
1
with n do
n*fact(n-1)
end
io @println (fact 3)
when using MAD ,
lutz$ asteroid -d fact.ast
Minimal Asteroid Debugger 0.0.1
(c) University of Rhode Island
type "help" for additional information
mad> next
> 1 load system io.
2
3 function fact
4 with 0 do
5 1
mad> next
1 load system io.
2
> 3 function fact
4 with 0 do
5 1
6 with n do
7 n*fact(n-1)
mad> set 7
mad> cont
reached breakpoint (fact.ast:7)
4 with 0 do
5 1
6 with n do
> 7 n*fact(n-1)
8 end
9
10 io @println (fact 3)
11
mad> cont
reached breakpoint (fact.ast:7)
4 with 0 do
5 1
6 with n do
> 7 n*fact(n-1)
8 end
9
10 io @println (fact 3)
11
mad> stack
Runtime stack (most recent call first):
frame #0: fact.ast @fact
frame #1: fact.ast @fact
frame #2: fact.ast @<toplevel>
mad> print n
n: 2
mad> up
you are looking at frame #1
mad> print n
n: 2 <<<< this should be 3
mad>
Notice that we keep returning the value of n associated with the current frame.
The text was updated successfully, but these errors were encountered:
This seems like something that happens with how the debugger handles print * and print $SYM. Calling print * tells the debugger to load the current stack frame from the SymTab with MAD's self.frame_ix. However, print $SYM is handled by calling the SymTab method .lookup_sym(), which then calls .find_sym_dict() to return the first dictionary that contains a specific symbol. This is why calling print * correctly displays the value of n in different scopes.
Minimal Asteroid Debugger 0.0.1
(c) University of Rhode Island
type "help" for additional information
mad> next
> 1 load system io.
2
3 function fact
4 with 0 do
5 1
mad> next
1 load system io.
2
> 3 function fact
4 with 0 do
5 1
6 with n do
7 n*fact(n-1)
mad> set 7
mad> cont
reached breakpoint (.\fact.ast:7)
4 with 0 do
5 1
6 with n do
> 7 n*fact(n-1)
8 end
9
10 io @println (fact 3
11 [EOF]
mad> cont
reached breakpoint (.\fact.ast:7)
4 with 0 do
5 1
6 with n do
> 7 n*fact(n-1)
8 end
9
10 io @println (fact 3
11 [EOF]
mad> stack
Runtime stack (most recent call first):
frame #0: .\fact.ast @fact
frame #1: .\fact.ast @fact
frame #2: .\fact.ast @<toplevel>
mad> print n
n: 2
mad> up
you are looking at frame #1
mad> print n
n: 2
mad> print *
n: 3
mad> down
you are looking at frame #0
mad> print *
n: 2
mad>
This else branch in ._handle_print()may need to get the current scope instead of looking up the symbol from the table directly.
Printing variables in stack frames other than the current one gives incorrect results. Consider the program,
when using MAD ,
Notice that we keep returning the value of n associated with the current frame.
The text was updated successfully, but these errors were encountered: