|
801 | 801 | jdi/invoke-single-threaded |
802 | 802 | args)))) |
803 | 803 |
|
804 | | -(defn frame-locals |
805 | | - "Return frame locals for slime, a sequence of [LocalVariable Value] |
806 | | - sorted by name." |
807 | | - [thread n] |
808 | | - (let [frame (nth (.frames thread) n)] |
809 | | - (sort-by |
810 | | - #(.name (key %)) |
811 | | - (merge {} (jdi/clojure-locals frame) (jdi/frame-locals frame))))) |
812 | | - |
813 | 804 | (defn frame-locals-with-string-values |
814 | 805 | "Return frame locals for slime" |
815 | 806 | [context thread n] |
816 | 807 | (doall |
817 | | - (for [map-entry (seq (frame-locals thread n))] |
818 | | - {:name (.name (key map-entry)) |
819 | | - :value (val map-entry) |
820 | | - :string-value (inspect/value-as-string |
821 | | - (assoc context :current-thread thread) |
822 | | - (val map-entry))}))) |
| 808 | + (for [{:keys [value] :as map-entry} (jdi/unmangled-frame-locals |
| 809 | + (nth (.frames thread) n))] |
| 810 | + (assoc map-entry |
| 811 | + :string-value (inspect/value-as-string |
| 812 | + (assoc context :current-thread thread) value))))) |
823 | 813 |
|
824 | 814 | (defn nth-frame-var |
825 | 815 | "Return the var-index'th var in the frame-index'th frame" |
|
836 | 826 | [map-sym locals] |
837 | 827 | (mapcat |
838 | 828 | (fn [local] |
839 | | - (let [local (.name (key local))] |
| 829 | + (let [local (:unmangled-name local)] |
840 | 830 | `[~(symbol local) ((var-get (ns-resolve '~'user '~map-sym)) ~local)])) |
841 | 831 | locals)) |
842 | 832 |
|
|
875 | 865 | "Assoc a local variable into a remote var" |
876 | 866 | [context thread map-var local] |
877 | 867 | (jdi-clj/remote-call |
878 | | - context thread (invoke-option-for (val local)) |
| 868 | + context thread (invoke-option-for (:value local)) |
879 | 869 | `assoc map-var |
880 | | - (jdi-clj/remote-str context (.name (key local))) |
881 | | - (when-let [value (val local)] |
| 870 | + (jdi-clj/remote-str context (:unmangled-name local)) |
| 871 | + (when-let [value (:value local)] |
882 | 872 | (jdi-clj/remote-object value context thread)))) |
883 | 873 |
|
884 | 874 | (defn set-remote-values |
|
900 | 890 |
|
901 | 891 | (defn eval-string-in-frame |
902 | 892 | "Eval the string `expr` in the context of the specified `frame-number`." |
903 | | - [context thread expr frame-number] |
| 893 | + [connection context thread expr frame-number] |
904 | 894 | (try |
905 | 895 | (let [_ (assert (.isSuspended thread)) |
906 | | - locals (frame-locals thread frame-number) |
907 | | - _ (logging/trace "eval-string-in-frame: map-sym") |
| 896 | + locals (jdi/unmangled-frame-locals |
| 897 | + (nth (.frames thread) frame-number)) |
908 | 898 | map-sym (remote-map-sym context thread) |
909 | | - _ (logging/trace "eval-string-in-frame: map-var for %s" map-sym) |
910 | 899 | map-var (jdi-clj/eval-to-value |
911 | 900 | context thread jdi/invoke-single-threaded |
912 | 901 | `(intern '~'user '~map-sym {})) |
913 | | - _ (logging/trace "eval-string-in-frame: form") |
914 | 902 | form (with-local-bindings-form map-sym locals (read-string expr))] |
915 | | - (logging/trace "eval-string-in-frame: form %s" form) |
916 | | - (try |
917 | | - (logging/trace "eval-string-in-frame: set-remote-values") |
918 | | - (set-remote-values context thread map-var locals) |
919 | | - ;; create a bindings form |
920 | | - (logging/trace "eval-string-in-frame: eval") |
921 | | - (jdi-clj/eval context thread jdi/invoke-single-threaded form) |
922 | | - (finally |
923 | | - (logging/trace "eval-string-in-frame: clear-remote-values") |
924 | | - (clear-remote-values context thread map-var)))) |
| 903 | + (locking remote-map-sym |
| 904 | + (try |
| 905 | + (set-remote-values context thread map-var locals) |
| 906 | + (let [v (jdi-clj/eval-to-value |
| 907 | + context thread jdi/invoke-single-threaded form)] |
| 908 | + (inspect/value-as-string (assoc context :current-thread thread) v)) |
| 909 | + (finally |
| 910 | + (clear-remote-values context thread map-var))))) |
| 911 | + (catch com.sun.jdi.InvocationException e |
| 912 | + (if connection |
| 913 | + (invoke-debugger* |
| 914 | + connection (InvocationExceptionEvent. (.exception e) thread)) |
| 915 | + (do |
| 916 | + (println (.exception e)) |
| 917 | + (println e) |
| 918 | + (.printStackTrace e)))))) |
| 919 | + |
| 920 | +(defn pprint-eval-string-in-frame |
| 921 | + "Eval the string `expr` in the context of the specified `frame-number`, |
| 922 | + and pretty print the result" |
| 923 | + [connection context thread expr frame-number] |
| 924 | + (try |
| 925 | + (let [_ (assert (.isSuspended thread)) |
| 926 | + locals (jdi/unmangled-frame-locals |
| 927 | + (nth (.frames thread) frame-number)) |
| 928 | + map-sym (remote-map-sym context thread) |
| 929 | + map-var (jdi-clj/eval-to-value |
| 930 | + context thread jdi/invoke-single-threaded |
| 931 | + `(intern '~'user '~map-sym {})) |
| 932 | + form `(with-out-str |
| 933 | + (require 'clojure.pprint) |
| 934 | + ((resolve 'clojure.pprint/pprint) |
| 935 | + ~(with-local-bindings-form |
| 936 | + map-sym locals (read-string expr))))] |
| 937 | + (locking remote-map-sym |
| 938 | + (try |
| 939 | + (set-remote-values context thread map-var locals) |
| 940 | + (jdi-clj/eval-to-string |
| 941 | + context thread jdi/invoke-single-threaded form) |
| 942 | + (finally |
| 943 | + (clear-remote-values context thread map-var))))) |
925 | 944 | (catch com.sun.jdi.InvocationException e |
926 | | - (invoke-debugger* |
927 | | - context (InvocationExceptionEvent. (.exception e) thread))))) |
| 945 | + (if connection |
| 946 | + (invoke-debugger* |
| 947 | + connection (InvocationExceptionEvent. (.exception e) thread)) |
| 948 | + (do |
| 949 | + (println (.exception e)) |
| 950 | + (println e) |
| 951 | + (.printStackTrace e)))))) |
928 | 952 |
|
929 | 953 | ;;; events |
930 | 954 | (defn add-exception-event-request |
|
1185 | 1209 | (for [method methods |
1186 | 1210 | :let [ops (disassemble-method const-pool method)] |
1187 | 1211 | :let [clinit (first (drop 3 ops))] |
1188 | | - :when (not (.contains clinit ":invokevirtual \"<clinit>\""))] |
| 1212 | + :when (not (.contains clinit ":invokevirtual \""))] |
1189 | 1213 | (concat |
1190 | 1214 | [(str sym-ns "/" sym-name |
1191 | 1215 | "(" (string/join " " (.argumentTypeNames method)) ")\n")] |
|
0 commit comments