ghci debugger :trace command does not always extend trace history

Peter Hercek phercek at gmail.com
Mon Dec 29 14:45:09 EST 2008


Hi,

I expected ":trace expr" to always add data to the trace history but it 
does not do so for CAFs (which are not reduced yet).
My point is that the command ":trace z" did not add anything to the 
trace history and I cannot check why value z is 2, because value of y is 
not in the trace history. Is this the expected behavior? If it is, how 
can I make ghci to extend the trace history when "forcing" variables?

Peter.

Here is the example:

status:0 peter at metod [765] ~/tmp
% cat a.hs
test :: Int -> Int
test x =
   let y = x+1 in
   let z = y+1 in
   z
status:0 peter at metod [766] ~/tmp
% ghci a.hs
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( a.hs, interpreted )
Ok, modules loaded: Main.
*Main> :break Main 5
Breakpoint 0 activated at a.hs:5:2
*Main> :trace test 0
Stopped at a.hs:5:2
_result :: Int = _
z :: Int = _
4    let z = y+1 in
5    z
6
[a.hs:5:2] *Main> :back
Logged breakpoint at a.hs:(2,0)-(5,2)
_result :: Int
1  test :: Int -> Int
2  test x =
3    let y = x+1 in
4    let z = y+1 in
5    z
6
[-1: a.hs:(2,0)-(5,2)] *Main> :back
no more logged breakpoints
[-1: a.hs:(2,0)-(5,2)] *Main> :forward
Stopped at a.hs:5:2
_result :: Int
z :: Int
4    let z = y+1 in
5    z
6
[a.hs:5:2] *Main> :trace z
2
[a.hs:5:2] *Main> :back
Logged breakpoint at a.hs:(2,0)-(5,2)
_result :: Int
1  test :: Int -> Int
2  test x =
3    let y = x+1 in
4    let z = y+1 in
5    z
6
[-1: a.hs:(2,0)-(5,2)] *Main> y
<interactive>:1:0: Not in scope: `y'

[-1: a.hs:(2,0)-(5,2)] *Main> :back
no more logged breakpoints
[-1: a.hs:(2,0)-(5,2)] *Main> :forward
Stopped at a.hs:5:2
_result :: Int
z :: Int
4    let z = y+1 in
5    z
6
[a.hs:5:2] *Main> z
2
[a.hs:5:2] *Main> y

<interactive>:1:0: Not in scope: `y'
[a.hs:5:2] *Main> :quit
Leaving GHCi.
status:0 peter at metod [767] ~/tmp
%



More information about the Glasgow-haskell-users mailing list