Thanks David! That looks very promising.

Rather than printing the arguments using displayVal each time, would it be
possible to instead print a number identifying the argument value, so that
multiple calls to traced functions where some of the arguments are the same
re-use the same numbers?

I want to use the trace produced for replaying the sequence of function
calls in a context where it is expensive (or sometimes impossible) to
reconstruct the arguments from what displayVal prints, but where any value
can be saved and associated with a number for later use.

On 12 October 2015 at 19:03, David Matthews <[email protected]>
wrote:

> Hi Ramana,
> There's nothing specific but the new DebuggingInterface structure should
> allow you to build this yourself.
>
> First build the new compiler with "make compiler" then compile your
> function with PolyML.Compiler.debug := true; before it.  You don't need to
> compile your whole program with debugging; just the bit with the function
> you're interested in.
>
> PolyML.Compiler.debug := false; (* Don't compile this with debugging! *)
> open PolyML.DebuggerInterface PolyML.NameSpace;
>
> fun trace(fnName, _) =
>     if String.isSubstring "myname" fnName
>     then
>     let
>         val args =
>              debugFunctionArg(hd(debugState(Thread.Thread.self())))
>     in
>         PolyML.prettyPrint(TextIO.print, 90 (* Line length *))
>              (displayVal(args, 100 (* Depth *), PolyML.globalNameSpace))
>     end
>     else ();
> setOnEntry(SOME trace);
>
> Run your program and every time it enters a function that matches the test
> it will print the arguments.
>
> The DebuggerInterface structure is still a bit fluid so some things may
> change before the final release.
>
> David
>
>
> On 11/10/2015 08:20, Ramana Kumar wrote:
>
>> Hi all,
>>
>> Does Poly/ML include any facility for tracing calls to (certain)
>> functions?
>> I am interested in generating a log of all calls to certain functions
>> (including their arguments), in order, during the run of some program.
>>
>> Perhaps there is something in the profiler that can help with this?
>>
>> Cheers,
>> Ramana
>>
>>
>>
>> _______________________________________________
>> polyml mailing list
>> [email protected]
>> http://lists.inf.ed.ac.uk/mailman/listinfo/polyml
>>
>> _______________________________________________
> polyml mailing list
> [email protected]
> http://lists.inf.ed.ac.uk/mailman/listinfo/polyml
>
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to