Skip to content

Commit 75c9781

Browse files
committed
Merge branch 'release/0.1.6'
2 parents 2856a0a + a5fbb5c commit 75c9781

File tree

21 files changed

+434
-138
lines changed

21 files changed

+434
-138
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ This is alpha quality.
88
- Allows stepping from breakpoints
99
- Allows evaluation of expressions in the context of a stack frame
1010
- Inspection of locals in any stack frame
11+
- Disassembly of functions from symbol or stack frame
12+
13+
Should work with clojure 1.3.0-alpha7.
1114

1215
## Install
1316

14-
Add `[swank-clj "0.1.5"]` to your project.clj `:dev-dependencies`.
17+
Add `[swank-clj "0.1.6"]` to your project.clj `:dev-dependencies`.
1518

1619
Install the slime-clj.el contrib from [marmalade](http://marmalade-repo.org/).
1720

ReleaseNotes.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
# Release Notes
22

3-
Current release is 0.1.5.
3+
Current release is 0.1.6.
4+
5+
* 0.1.6
6+
7+
- Add debug/pprint-eval-string-in-frame
8+
This moves the pretty printing into the debugee
9+
10+
- Unmangle clojure names for local variables
11+
12+
- Fix pprint-eval-string-in-frame to correctly output a string
13+
14+
- Fix generation of nested exceptions on eval-in-frame
15+
16+
- Fix fuzzy completion of explicitly namespaced symbols
17+
18+
- Improve filtering of unimplimented arities in disassembly listings
19+
20+
- Try harder to maintain relative source paths when compiling
21+
22+
- Stop focussing repl on slime-javadoc
23+
24+
- Add support for invokePrim
25+
Clojure 1.3 introduces a new function invokePrim to handle primitive
26+
arguments.
27+
28+
- disable AOT
29+
In order for swank-clj to work across clojure versions, remove the aot.
30+
31+
- Fix return value of fuzzy-completions when no completions found
432

533
* 0.1.5
634

finish-release.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# finish the release after updating release notes
4+
5+
if [[ $# -lt 1 ]]; then
6+
echo "usage: $(basename $0) new-version" >&2
7+
exit 1
8+
fi
9+
10+
version=$1
11+
12+
echo "finish release of $version"
13+
14+
echo -n "commiting project.clj, release notes and readme. enter to continue:" \
15+
&& read x \
16+
&& git add project.clj ReleaseNotes.md README.md \
17+
&& git commit -m "Updated project.clj, release notes and readme for $version" \
18+
&& echo -n "Peform release. enter to continue:" && read x \
19+
&& lein test \
20+
&& lein jar, pom \
21+
&& git flow release finish $version \
22+
&& scp swank-clj-${version}.jar pom.xml clojars: \
23+
&& bash build-elpa-package.sh \
24+
&& echo "Now push and upload to github and marmalade"
25+

project.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
(defproject swank-clj "0.1.5"
1+
(defproject swank-clj "0.1.6"
22
:description "Another swank for clojure"
33
:source-path "src/main/clojure"
44
:resources-path "src/main/resources"
55
:test-path "src/test/clojure"
6-
:aot [swank-clj.main]
6+
;; :aot [swank-clj.main]
77
:dependencies [[org.clojure/clojure "1.2.0"]]
88
:dev-dependencies [[swank-clojure "1.2.1"]
99
[lein-swank-clj "1.0.0-SNAPSHOT"]

src/main/clojure/swank_clj/commands/basic.clj

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,21 @@
151151
(catch Throwable t
152152
(.printStackTrace t) ;; prints to *inferior-lisp*
153153
(messages/compilation-result
154-
(map exception-message (helpers/exception-causes t)) ; notes
155-
nil ; results
156-
(secs-for-ns (- (System/nanoTime) start))))))) ; durations
154+
[(exception-message t)] ; notes
155+
nil ; results
156+
(secs-for-ns (- (System/nanoTime) start))))))) ; durations
157+
158+
(defn possibly-relative-path
159+
"If file-path can be expressed relative tot he classloader root, then
160+
do so"
161+
[file-path]
162+
(try
163+
(let [base (File. (System/getProperty "user.dir"))
164+
file (File. file-path)]
165+
(if (.startsWith (.getCanonicalPath file) (.getCanonicalPath base))
166+
(.substring
167+
(.getAbsolutePath file) (inc (count (.getAbsolutePath base))))
168+
file-path))))
157169

158170
(defslimefn compile-file-for-emacs
159171
[connection file-name load? & compile-options]

src/main/clojure/swank_clj/commands/contrib/swank_fuzzy.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@
106106
(let [[xs x] (fuzzy-completion-set string default-package-name
107107
limit time-limit-in-msec)]
108108
(list
109-
(map (fn [[symbol score chunks class]]
110-
(list symbol score (map (partial apply list) chunks) class))
111-
xs)
109+
(seq (map (fn [[symbol score chunks class]]
110+
(list symbol score (map (partial apply list) chunks) class))
111+
xs))
112112
(when x 't))))
113113

114114
(commands/defslimefn fuzzy-completion-selected [_ _ _] nil)

src/main/clojure/swank_clj/commands/debugger.clj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,13 @@ corresponding attribute values per thread."
125125
(let [[level-info level] (connection/current-sldb-level-info connection)
126126
thread (:thread level-info)]
127127
(debug/eval-string-in-frame
128-
(connection/vm-context connection) thread expr n)))
128+
connection (connection/vm-context connection) thread expr n)))
129129

130130
(defslimefn pprint-eval-string-in-frame [connection expr n]
131-
(pprint/pprint (eval-string-in-frame connection expr n)))
131+
(let [[level-info level] (connection/current-sldb-level-info connection)
132+
thread (:thread level-info)]
133+
(debug/pprint-eval-string-in-frame
134+
connection (connection/vm-context connection) thread expr n)))
132135

133136
;; disassemble
134137
(defslimefn sldb-disassemble [connection frame-index]

src/main/clojure/swank_clj/jpda/debug.clj

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -801,25 +801,15 @@
801801
jdi/invoke-single-threaded
802802
args))))
803803

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-
813804
(defn frame-locals-with-string-values
814805
"Return frame locals for slime"
815806
[context thread n]
816807
(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)))))
823813

824814
(defn nth-frame-var
825815
"Return the var-index'th var in the frame-index'th frame"
@@ -836,7 +826,7 @@
836826
[map-sym locals]
837827
(mapcat
838828
(fn [local]
839-
(let [local (.name (key local))]
829+
(let [local (:unmangled-name local)]
840830
`[~(symbol local) ((var-get (ns-resolve '~'user '~map-sym)) ~local)]))
841831
locals))
842832

@@ -875,10 +865,10 @@
875865
"Assoc a local variable into a remote var"
876866
[context thread map-var local]
877867
(jdi-clj/remote-call
878-
context thread (invoke-option-for (val local))
868+
context thread (invoke-option-for (:value local))
879869
`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)]
882872
(jdi-clj/remote-object value context thread))))
883873

884874
(defn set-remote-values
@@ -900,31 +890,65 @@
900890

901891
(defn eval-string-in-frame
902892
"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]
904894
(try
905895
(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))
908898
map-sym (remote-map-sym context thread)
909-
_ (logging/trace "eval-string-in-frame: map-var for %s" map-sym)
910899
map-var (jdi-clj/eval-to-value
911900
context thread jdi/invoke-single-threaded
912901
`(intern '~'user '~map-sym {}))
913-
_ (logging/trace "eval-string-in-frame: form")
914902
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)))))
925944
(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))))))
928952

929953
;;; events
930954
(defn add-exception-event-request
@@ -1185,7 +1209,7 @@
11851209
(for [method methods
11861210
:let [ops (disassemble-method const-pool method)]
11871211
:let [clinit (first (drop 3 ops))]
1188-
:when (not (.contains clinit ":invokevirtual \"<clinit>\""))]
1212+
:when (not (.contains clinit ":invokevirtual \""))]
11891213
(concat
11901214
[(str sym-ns "/" sym-name
11911215
"(" (string/join " " (.argumentTypeNames method)) ")\n")]

0 commit comments

Comments
 (0)