如何在堆栈跟踪中看到函数的参数?

时间:2016-06-05 12:14:41

标签: debugging clojure

这是一个典型的堆栈跟踪:

#error {
 :cause "No implementation of method: :put! of protocol: #'clojure.core.async.impl.protocols/WritePort found for class: clojure.lang.PersistentArrayMap"
 :via
 [{:type java.lang.IllegalArgumentException
   :message "No implementation of method: :put! of protocol: #'clojure.core.async.impl.protocols/WritePort found for class: clojure.lang.PersistentArrayMap"
   :at [clojure.core$_cache_protocol_fn invokeStatic "core_deftype.clj" 568]}]
 :trace
 [[clojure.core$_cache_protocol_fn invokeStatic "core_deftype.clj" 568]
  [clojure.core$_cache_protocol_fn invoke "core_deftype.clj" 560]
  [clojure.core.async.impl.protocols$eval1004$fn__1005$G__995__1014 invoke "protocols.clj" 18]
  [clojure.core.async$_GT__BANG__BANG_ invokeStatic "async.clj" 137]
  [clojure.core.async$_GT__BANG__BANG_ invoke "async.clj" 132]
  [fargish.cart$do_clockstep invokeStatic "cart.clj" 132]
  [fargish.cart$do_clockstep invoke "cart.clj" 131]
  [fargish.cart$run_cartnos$body__29824__auto____40594$fn__40641 invoke "cart.clj" 155]
  [clojure.lang.ArrayChunk reduce "ArrayChunk.java" 58]
  [clojure.core.protocols$fn__6750 invokeStatic "protocols.clj" 136]
  [clojure.core.protocols$fn__6750 invoke "protocols.clj" 124]
  [clojure.core.protocols$fn__6710$G__6705__6719 invoke "protocols.clj" 19]
  [clojure.core.protocols$seq_reduce invokeStatic "protocols.clj" 31]
  [clojure.core.protocols$fn__6738 invokeStatic "protocols.clj" 75]
  [clojure.core.protocols$fn__6738 invoke "protocols.clj" 75]
  [clojure.core.protocols$fn__6684$G__6679__6697 invoke "protocols.clj" 13]
  [clojure.core$reduce invokeStatic "core.clj" 6545]
  [clojure.core$reduce invoke "core.clj" 6527]
  [fargish.cart$run_cartnos$body__29824__auto____40594 invoke "cart.clj" 155]
  [fargish.cart$run_cartnos invokeStatic "cart.clj" 154]
  [fargish.cart$run_cartnos invoke "cart.clj" 150]
  [user$eval40833 invokeStatic "form-init6256859177727771967.clj" 1]
  [user$eval40833 invoke "form-init6256859177727771967.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 6927]
  [clojure.lang.Compiler eval "Compiler.java" 6890]
  [clojure.core$eval invokeStatic "core.clj" 3105]
  [clojure.core$eval invoke "core.clj" 3101]
  [clojure.main$repl$read_eval_print__7408$fn__7411 invoke "main.clj" 240]
  [clojure.main$repl$read_eval_print__7408 invoke "main.clj" 240]
  [clojure.main$repl$fn__7417 invoke "main.clj" 258]
  [clojure.main$repl invokeStatic "main.clj" 258]
  [clojure.main$repl doInvoke "main.clj" 174]
  [clojure.lang.RestFn invoke "RestFn.java" 1523]
  [clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__18913 invoke "interruptible_eval.clj" 87]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.AFn applyTo "AFn.java" 144]
  [clojure.core$apply invokeStatic "core.clj" 646]
  [clojure.core$with_bindings_STAR_ invokeStatic "core.clj" 1881]
  [clojure.core$with_bindings_STAR_ doInvoke "core.clj" 1881]
  [clojure.lang.RestFn invoke "RestFn.java" 425]
  [clojure.tools.nrepl.middleware.interruptible_eval$evaluate invokeStatic "interruptible_eval.clj" 85]
  [clojure.tools.nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 55]
  [clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__18958$fn__18961 invoke "interruptible_eval.clj" 222]
  [clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__18953 invoke "interruptible_eval.clj" 190]
  [clojure.lang.AFn run "AFn.java" 22]
  [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1142]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 617]
  [java.lang.Thread run "Thread.java" 745]]}

如何查看传递给这些函数的参数值?这将有助于追踪出现问题的原因。

1 个答案:

答案 0 :(得分:1)

目前,这是不可能的,但您可以查看clojure/tools.trace库。它解决了类似于您的问题,但您必须将所有计算包装在一个特殊的宏中。