[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-mode 6f0bad7c73 5/5: Merge pull request #1810 from
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-mode 6f0bad7c73 5/5: Merge pull request #1810 from mobid/bugfix/debugger |
Date: |
Thu, 13 Jul 2023 04:00:19 -0400 (EDT) |
branch: elpa/haskell-mode
commit 6f0bad7c730b99f4702267355656655b8b10049d
Merge: 3814b0b0ba 6dd373811b
Author: Steve Purcell <steve@sanityinc.com>
Commit: GitHub <noreply@github.com>
Merge pull request #1810 from mobid/bugfix/debugger
fixed debugger for GHC 8/9
---
haskell-debug.el | 62 ++++++++++++++++++++++++++++++++------------------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/haskell-debug.el b/haskell-debug.el
index 9981f154da..5c65e273bb 100644
--- a/haskell-debug.el
+++ b/haskell-debug.el
@@ -253,11 +253,12 @@
(let* ((breakpoints (haskell-debug-get-breakpoints))
(context (haskell-debug-get-context))
(string
- (haskell-process-queue-sync-request
- (haskell-debug-process)
- (if expr
- (concat ":step " expr)
- ":step"))))
+ (haskell-debug-trim-break-location
+ (haskell-process-queue-sync-request
+ (haskell-debug-process)
+ (if expr
+ (concat ":step " expr)
+ ":step")))))
(cond
((string= string "not stopped at a breakpoint\n")
(if haskell-debug-bindings-cache
@@ -310,11 +311,18 @@
(format "*debug:%s*"
(haskell-session-name session)))
+(defun haskell-debug-trim-break-location (string)
+ "Remove trailing location of current break from output STRING if exists."
+ (if-let ((i (string-match "^\\(... \\)?\\[[^]]+\\] $" string)))
+ (substring string 0 i)
+ string))
+
(defun haskell-debug-get-breakpoints ()
"Get the list of breakpoints currently set."
- (let ((string (haskell-process-queue-sync-request
- (haskell-debug-process)
- ":show breaks")))
+ (let ((string (haskell-debug-trim-break-location
+ (haskell-process-queue-sync-request
+ (haskell-debug-process)
+ ":show breaks"))))
(if (string= string "No active breakpoints.\n")
(list)
(mapcar #'haskell-debug-parse-break-point
@@ -322,9 +330,10 @@
(defun haskell-debug-get-modules ()
"Get the list of modules currently set."
- (let ((string (haskell-process-queue-sync-request
- (haskell-debug-process)
- ":show modules")))
+ (let ((string (haskell-debug-trim-break-location
+ (haskell-process-queue-sync-request
+ (haskell-debug-process)
+ ":show modules"))))
(if (string= string "")
(list)
(mapcar #'haskell-debug-parse-module
@@ -332,18 +341,20 @@
(defun haskell-debug-get-context ()
"Get the current context."
- (let ((string (haskell-process-queue-sync-request
- (haskell-debug-process)
- ":show context")))
+ (let ((string (haskell-debug-trim-break-location
+ (haskell-process-queue-sync-request
+ (haskell-debug-process)
+ ":show context"))))
(if (string= string "")
nil
(haskell-debug-parse-context string))))
(defun haskell-debug-get-history ()
"Get the step history."
- (let ((string (haskell-process-queue-sync-request
- (haskell-debug-process)
- ":history")))
+ (let ((string (haskell-debug-trim-break-location
+ (haskell-process-queue-sync-request
+ (haskell-debug-process)
+ ":history"))))
(if (or (string= string "")
(string= string "Not stopped at a breakpoint\n"))
nil
@@ -520,15 +531,13 @@ some old history, then display that."
(point-max)))))))))
(defun haskell-debug-parse-stopped-at (string)
- "Parse the location stopped at from the given string.
+ "Parse the location stopped at from the given STRING.
-For example:
+For examples:
Stopped at /home/foo/project/src/x.hs:6:25-36
-
-"
- (let ((index (string-match "Stopped at \\([^:]+\\):\\(.+\\)\n?"
- string)))
+Stopped in X.test, /home/foo/project/src/x.hs:6:25-36"
+ (let ((index (string-match "Stopped \\(?:at\\|in [^,]+,\\)
\\([^:]+\\):\\(.+\\)\n?" string)))
(when index
(list :path (match-string 1 string)
:span (haskell-debug-parse-span (match-string 2 string))
@@ -657,9 +666,10 @@ variances in source span notation."
(defun haskell-debug-navigate (direction)
"Navigate in DIRECTION \"back\" or \"forward\"."
- (let ((string (haskell-process-queue-sync-request
- (haskell-debug-process)
- (concat ":" direction))))
+ (let ((string (haskell-debug-trim-break-location
+ (haskell-process-queue-sync-request
+ (haskell-debug-process)
+ (concat ":" direction)))))
(let ((bindings (haskell-debug-parse-logged string)))
(setq haskell-debug-bindings-cache
bindings)