ghci debugger: showing function argumetns when stopped at its definition

Peter Hercek phercek at gmail.com
Fri Jul 10 10:31:51 EDT 2009


Hi,

It would be cool if ghci debugger could grab not only the free variables  
in the selected expression but in one case a bit more. The case is when 
we stop at a function definition the first time (when just entering it). 
In this case it should provide bindings of the function arguments. Is it 
doable without bad consequences? Looks to me like it should not result in 
some memory leak problems though I do not have idea whether it is hard to 
do.

The reason I want it is that if it would be available I could put a break 
point which never stops and only continues at the start of a function I'm 
interested in. Then If I later stop somewhere in the function I have a 
pretty good chance that the correct arguments are stored in the trace 
history and I could retrieve them.

E.g. with my GhciExt it would be as simple as:
-- to strobe function arguments
:count 0 <QualifiedFncName>
-- and to look them up later when stopped somewhere
--   in the function  I could just use
:locate :back <QualifiedFncName>
-- ... or for a specific argument value
:find :back <ArgumentName>

If you are interested GhciExt is available here:
http://www.hck.sk/users/peter/pub/

But other users could do it too in a bit more complicated way (e.g. by 
stopping at the function start manually and then continuing and then 
searching the trace history manually again).

Of course I can make sure the function arguments get to the history even 
now but in much more complicated way (by putting a non-stopping break 
point at each first use of each argument). The problem with this approach 
is that:
* one must look up all the places in the source code
* some of the places may not be hit before we stop at some interesting 
place in the function so some arguments would not be visible yet


Thanks,
Peter.



More information about the Glasgow-haskell-users mailing list