[ANN] zpst 0.1.6 -- see source and actual arguments in your stack trace

111 views
Skip to first unread message

Kim Kinnear

unread,
Jun 20, 2018, 8:47:24 PM6/20/18
to Clojure
zpst: A library for printing Clojure stacktraces, showing source and arguments for Clojure functions on the stack.


There are three increasingly detailed ways to use zpst -- all without any changes to your source:

  1. As a replacement for pst, it will print your stacktrace and include source for all of the functions for which it can find the source (which is pretty much what you can see with the doc function).

    It will attempt to highlight the expression which was executing when the exception occurred.  It doesn't show the source for an entire function, rather it shows the name, the parameter list, and 8 lines before and two lines after the expression that was executing (by default).

  2. If you have a "deterministic" exception -- that is, an exception which you can recreate at will, then after you get an exception you can run (collect), recreate the exception a second time, and then run (analyze).  Now when you use zpst, it will show you both the source for the functions in the stacktrace (as above), and also the actual arguments to those functions paired up with the parameter names from the function definition.

    This is why you would want to use zpst -- seeing the actual arguments to your functions, without having to instrument your source to do so, can be pretty compelling.

  3. If you have done #2 above, you can also get access to the arguments for any frame where the source was shown.  You can examine the arguments at the repl, and you can change and reset the arguments for any frame.  Then you can re-evaluate the functions on the stack from that frame and see if the new arguments change the exception or the return value.
Note that printing the stack trace with source code included (#1, above) is very similar to what the pyro library does, though zpst will attempt to highlight the actual expression executing.

To the best of my knowledge, no other library will collect and display the actual arguments to functions on the stack with no modifications to your source code.  As well, I know of no library which will allow you to modify those arguments and retry the function calls from pretty much anywhere on the stack.

This is the first release for this library, so I expect that some issues will arise.  

Khalid Jebbari

unread,
Jun 21, 2018, 5:38:45 PM6/21/18
to Clojure
Haven't tried yet but this looks very interesting! Thanks for sharing.
Reply all
Reply to author
Forward
0 new messages