From: "Ludovic Courtès" <ludo@gnu.org>
To: 40077@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#40077] [PATCH 4/4] inferior: '&inferior-exception' includes a stack trace.
Date: Sun, 15 Mar 2020 18:15:07 +0100 [thread overview]
Message-ID: <20200315171507.22910-4-ludo@gnu.org> (raw)
In-Reply-To: <20200315171507.22910-1-ludo@gnu.org>
* guix/inferior.scm (port->inferior): Bump protocol to (0 1 1).
(&inferior-exception)[stack]: New field.
(read-repl-response): Recognize 'exception' form for protocol (0 1 1).
* tests/inferior.scm ("&inferior-exception"): Check the value returned
by 'inferior-exception-stack'.
---
guix/inferior.scm | 17 ++++++++++++++---
tests/inferior.scm | 3 +++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/guix/inferior.scm b/guix/inferior.scm
index ec8ff8ddbe..c9a5ee5129 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -66,6 +66,7 @@
inferior-exception?
inferior-exception-arguments
inferior-exception-inferior
+ inferior-exception-stack
read-repl-response
inferior-packages
@@ -164,7 +165,7 @@ inferior."
(match rest
((n _ ...)
(when (>= n 1)
- (send-inferior-request '(() repl-version 0 1) result)))
+ (send-inferior-request '(() repl-version 0 1 1) result)))
(_
#t))
@@ -211,7 +212,8 @@ equivalent. Return #f if the inferior could not be launched."
(define-condition-type &inferior-exception &error
inferior-exception?
(arguments inferior-exception-arguments) ;key + arguments
- (inferior inferior-exception-inferior)) ;<inferior> | #f
+ (inferior inferior-exception-inferior) ;<inferior> | #f
+ (stack inferior-exception-stack)) ;list of (FILE COLUMN LINE)
(define* (read-repl-response port #:optional inferior)
"Read a (guix repl) response from PORT and return it as a Scheme object.
@@ -226,10 +228,19 @@ Raise '&inferior-exception' when an exception is read from PORT."
(match (read port)
(('values objects ...)
(apply values (map sexp->object objects)))
+ (('exception ('arguments key objects ...)
+ ('stack frames ...))
+ ;; Protocol (0 1 1) and later.
+ (raise (condition (&inferior-exception
+ (arguments (cons key (map sexp->object objects)))
+ (inferior inferior)
+ (stack frames)))))
(('exception key objects ...)
+ ;; Protocol (0 0).
(raise (condition (&inferior-exception
(arguments (cons key (map sexp->object objects)))
- (inferior inferior)))))))
+ (inferior inferior)
+ (stack '())))))))
(define (read-inferior-response inferior)
(read-repl-response (inferior-socket inferior)
diff --git a/tests/inferior.scm b/tests/inferior.scm
index b4417d8629..2f5215920b 100644
--- a/tests/inferior.scm
+++ b/tests/inferior.scm
@@ -68,6 +68,9 @@
(guard (c ((inferior-exception? c)
(close-inferior inferior)
(and (eq? inferior (inferior-exception-inferior c))
+ (match (inferior-exception-stack c)
+ (((_ (files lines columns)) ..1)
+ (member "guix/repl.scm" files)))
(inferior-exception-arguments c))))
(inferior-eval '(throw 'a 'b 'c 'd) inferior)
'badness)))
--
2.25.1
next prev parent reply other threads:[~2020-03-15 17:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-15 17:00 [bug#40077] [PATCH 0/4] Inferior provide stack traces along with exceptions Ludovic Courtès
2020-03-15 17:15 ` [bug#40077] [PATCH 1/4] repl: Allow clients to send their protocol version Ludovic Courtès
2020-03-15 17:15 ` [bug#40077] [PATCH 2/4] inferior: Adjust to protocol (0 1) Ludovic Courtès
2020-03-15 17:15 ` [bug#40077] [PATCH 3/4] repl: Return stack traces along with exceptions Ludovic Courtès
2020-03-15 17:15 ` Ludovic Courtès [this message]
2020-03-19 14:15 ` bug#40077: [PATCH 0/4] Inferior provide " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200315171507.22910-4-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=40077@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).