Skip to content

Commit db3c604

Browse files
committed
Add trace function
1 parent 34be008 commit db3c604

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

haskell-debug.el

+19-3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070

7171
(define-key haskell-debug-mode-map (kbd "g") 'haskell-debug/refresh)
7272
(define-key haskell-debug-mode-map (kbd "s") 'haskell-debug/step)
73+
(define-key haskell-debug-mode-map (kbd "t") 'haskell-debug/trace)
7374
(define-key haskell-debug-mode-map (kbd "d") 'haskell-debug/delete)
7475
(define-key haskell-debug-mode-map (kbd "b") 'haskell-debug/break-on-function)
7576
(define-key haskell-debug-mode-map (kbd "a") 'haskell-debug/abandon)
@@ -184,6 +185,7 @@
184185
"Refresh the debugger buffer."
185186
(interactive)
186187
(with-current-buffer (haskell-debug-buffer-name (haskell-debug-session))
188+
(cd (haskell-session-current-dir (haskell-debug-session)))
187189
(let ((inhibit-read-only t)
188190
(p (point)))
189191
(erase-buffer)
@@ -222,6 +224,19 @@
222224
(plist-get break :number)))
223225
(haskell-debug/refresh))))))
224226

227+
(defun haskell-debug/trace ()
228+
"Trace the expression."
229+
(interactive)
230+
(haskell-debug-with-modules
231+
(haskell-debug-with-breakpoints
232+
(let ((expr (read-from-minibuffer "Expression to trace: "
233+
(haskell-ident-at-point))))
234+
(haskell-process-queue-sync-request
235+
(haskell-debug-process)
236+
(concat ":trace " expr))
237+
(message "Tracing expression: %s" expr)
238+
(haskell-debug/refresh)))))
239+
225240
(defun haskell-debug/step (&optional expr)
226241
"Step into the next function."
227242
(interactive)
@@ -332,7 +347,8 @@
332347
(defun haskell-debug-insert-bindings (modules breakpoints context)
333348
"Insert a list of bindings."
334349
(if breakpoints
335-
(progn (haskell-debug-insert-binding "s" "step into an expression")
350+
(progn (haskell-debug-insert-binding "t" "trace an expression")
351+
(haskell-debug-insert-binding "s" "step into an expression")
336352
(haskell-debug-insert-binding "b" "breakpoint" t))
337353
(progn
338354
(when modules
@@ -360,9 +376,9 @@
360376

361377
(defun haskell-debug-insert-breakpoints (breakpoints)
362378
"insert the list of breakpoints."
363-
(haskell-debug-insert-header "breakpoints")
379+
(haskell-debug-insert-header "Breakpoints")
364380
(if (null breakpoints)
365-
(haskell-debug-insert-muted "no active breakpoints.")
381+
(haskell-debug-insert-muted "No active breakpoints.")
366382
(cl-loop for break in breakpoints
367383
do (insert (propertize (format "%d"
368384
(plist-get break :number))

0 commit comments

Comments
 (0)