Skip to content

Commit 6f0bad7

Browse files
authored
Merge pull request #1810 from mobid/bugfix/debugger
fixed debugger for GHC 8/9
2 parents 3814b0b + 6dd3738 commit 6f0bad7

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

haskell-debug.el

+36-26
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,12 @@
253253
(let* ((breakpoints (haskell-debug-get-breakpoints))
254254
(context (haskell-debug-get-context))
255255
(string
256-
(haskell-process-queue-sync-request
257-
(haskell-debug-process)
258-
(if expr
259-
(concat ":step " expr)
260-
":step"))))
256+
(haskell-debug-trim-break-location
257+
(haskell-process-queue-sync-request
258+
(haskell-debug-process)
259+
(if expr
260+
(concat ":step " expr)
261+
":step")))))
261262
(cond
262263
((string= string "not stopped at a breakpoint\n")
263264
(if haskell-debug-bindings-cache
@@ -310,40 +311,50 @@
310311
(format "*debug:%s*"
311312
(haskell-session-name session)))
312313

314+
(defun haskell-debug-trim-break-location (string)
315+
"Remove trailing location of current break from output STRING if exists."
316+
(if-let ((i (string-match "^\\(... \\)?\\[[^]]+\\] $" string)))
317+
(substring string 0 i)
318+
string))
319+
313320
(defun haskell-debug-get-breakpoints ()
314321
"Get the list of breakpoints currently set."
315-
(let ((string (haskell-process-queue-sync-request
316-
(haskell-debug-process)
317-
":show breaks")))
322+
(let ((string (haskell-debug-trim-break-location
323+
(haskell-process-queue-sync-request
324+
(haskell-debug-process)
325+
":show breaks"))))
318326
(if (string= string "No active breakpoints.\n")
319327
(list)
320328
(mapcar #'haskell-debug-parse-break-point
321329
(haskell-debug-split-string string)))))
322330

323331
(defun haskell-debug-get-modules ()
324332
"Get the list of modules currently set."
325-
(let ((string (haskell-process-queue-sync-request
326-
(haskell-debug-process)
327-
":show modules")))
333+
(let ((string (haskell-debug-trim-break-location
334+
(haskell-process-queue-sync-request
335+
(haskell-debug-process)
336+
":show modules"))))
328337
(if (string= string "")
329338
(list)
330339
(mapcar #'haskell-debug-parse-module
331340
(haskell-debug-split-string string)))))
332341

333342
(defun haskell-debug-get-context ()
334343
"Get the current context."
335-
(let ((string (haskell-process-queue-sync-request
336-
(haskell-debug-process)
337-
":show context")))
344+
(let ((string (haskell-debug-trim-break-location
345+
(haskell-process-queue-sync-request
346+
(haskell-debug-process)
347+
":show context"))))
338348
(if (string= string "")
339349
nil
340350
(haskell-debug-parse-context string))))
341351

342352
(defun haskell-debug-get-history ()
343353
"Get the step history."
344-
(let ((string (haskell-process-queue-sync-request
345-
(haskell-debug-process)
346-
":history")))
354+
(let ((string (haskell-debug-trim-break-location
355+
(haskell-process-queue-sync-request
356+
(haskell-debug-process)
357+
":history"))))
347358
(if (or (string= string "")
348359
(string= string "Not stopped at a breakpoint\n"))
349360
nil
@@ -520,15 +531,13 @@ some old history, then display that."
520531
(point-max)))))))))
521532

522533
(defun haskell-debug-parse-stopped-at (string)
523-
"Parse the location stopped at from the given string.
534+
"Parse the location stopped at from the given STRING.
524535
525-
For example:
536+
For examples:
526537
527538
Stopped at /home/foo/project/src/x.hs:6:25-36
528-
529-
"
530-
(let ((index (string-match "Stopped at \\([^:]+\\):\\(.+\\)\n?"
531-
string)))
539+
Stopped in X.test, /home/foo/project/src/x.hs:6:25-36"
540+
(let ((index (string-match "Stopped \\(?:at\\|in [^,]+,\\) \\([^:]+\\):\\(.+\\)\n?" string)))
532541
(when index
533542
(list :path (match-string 1 string)
534543
:span (haskell-debug-parse-span (match-string 2 string))
@@ -657,9 +666,10 @@ variances in source span notation."
657666

658667
(defun haskell-debug-navigate (direction)
659668
"Navigate in DIRECTION \"back\" or \"forward\"."
660-
(let ((string (haskell-process-queue-sync-request
661-
(haskell-debug-process)
662-
(concat ":" direction))))
669+
(let ((string (haskell-debug-trim-break-location
670+
(haskell-process-queue-sync-request
671+
(haskell-debug-process)
672+
(concat ":" direction)))))
663673
(let ((bindings (haskell-debug-parse-logged string)))
664674
(setq haskell-debug-bindings-cache
665675
bindings)

0 commit comments

Comments
 (0)