From unknown Sun Jun 22 04:10:37 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#40077] [PATCH 0/4] Inferior provide stack traces along with exceptions Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 15 Mar 2020 17:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 40077 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40077@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15842916356636 (code B ref -1); Sun, 15 Mar 2020 17:01:02 +0000 Received: (at submit) by debbugs.gnu.org; 15 Mar 2020 17:00:35 +0000 Received: from localhost ([127.0.0.1]:35399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWct-0001ix-EM for submit@debbugs.gnu.org; Sun, 15 Mar 2020 13:00:35 -0400 Received: from lists.gnu.org ([209.51.188.17]:59475) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWcs-0001iq-4p for submit@debbugs.gnu.org; Sun, 15 Mar 2020 13:00:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53534) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDWcq-0001cl-7o for guix-patches@gnu.org; Sun, 15 Mar 2020 13:00:33 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_40 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54996) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jDWcp-00043i-KT; Sun, 15 Mar 2020 13:00:31 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41128 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jDWcp-0000L7-6p; Sun, 15 Mar 2020 13:00:31 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sun, 15 Mar 2020 18:00:19 +0100 Message-Id: <20200315170019.22544-1-ludo@gnu.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello! This patch series allows inferiors to provide stack traces when an exception is thrown. The wire format needed to be changed to provide that info, and thus the protocol had to be adjusted to support both forward and backward compatibility: a new client must be able to talk to an old ‘guix repl’, and an old client must be able to talk to a new ‘guix repl’. To that end, clients now send the protocol version they support. Note that, with these patches, stack traces are available but inferior exceptions are not reported more nicely than before: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (open-inferior "/home/ludo/src/guix" #:command "scripts/guix") $1 = #< pid: pipe socket: # close: # version: (0 1 1) packages: #> table: #>> scheme@(guile-user)> (inferior-eval '(throw 'x 'y 'z) $1) ice-9/boot-9.scm:1669:16: In procedure raise-exception: ERROR: 1. &inferior-exception: arguments: (x y z) inferior: #< pid: pipe socket: # close: # version: (0 1 1) packages: #> table: #>> stack: ((#f ("ice-9/boot-9.scm" 1763 13)) (raise-exception ("ice-9/boot-9.scm" 1668 16)) (#f (#f #f #f)) (#f ("guix/repl.scm" 92 21)) (with-exception-handler ("ice-9/boot-9.scm" 1735 10)) (with-exception-handler ("ice-9/boot-9.scm" 1730 15)) (#f ("guix/repl.scm" 119 7))) Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. --8<---------------cut here---------------end--------------->8--- This is left as an exercise to the reader. Feedback welcome! Ludo’. Ludovic Courtès (4): repl: Allow clients to send their protocol version. inferior: Adjust to protocol (0 1). repl: Return stack traces along with exceptions. inferior: '&inferior-exception' includes a stack trace. guix/inferior.scm | 24 +++++++++++-- guix/repl.scm | 86 ++++++++++++++++++++++++++++++++++++++-------- tests/inferior.scm | 3 ++ 3 files changed, 97 insertions(+), 16 deletions(-) -- 2.25.1 From unknown Sun Jun 22 04:10:37 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#40077] [PATCH 1/4] repl: Allow clients to send their protocol version. References: <20200315170019.22544-1-ludo@gnu.org> In-Reply-To: <20200315170019.22544-1-ludo@gnu.org> Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 15 Mar 2020 17:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40077 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40077@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 40077-submit@debbugs.gnu.org id=B40077.15842925338188 (code B ref 40077); Sun, 15 Mar 2020 17:16:01 +0000 Received: (at 40077) by debbugs.gnu.org; 15 Mar 2020 17:15:33 +0000 Received: from localhost ([127.0.0.1]:35419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWrM-000280-M3 for submit@debbugs.gnu.org; Sun, 15 Mar 2020 13:15:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36888) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWrK-00027g-IR for 40077@debbugs.gnu.org; Sun, 15 Mar 2020 13:15:30 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jDWrF-0002ju-03; Sun, 15 Mar 2020 13:15:25 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41152 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jDWr4-0005z8-3y; Sun, 15 Mar 2020 13:15:23 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sun, 15 Mar 2020 18:15:04 +0100 Message-Id: <20200315171507.22910-1-ludo@gnu.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * guix/repl.scm (send-repl-response): Add #:version. (machine-repl): Make 'loop' an internal define with a 'version' parameter. Pass VERSION to 'send-repl-response'. Send (0 1) as the protocol version. If the first element read from INPUT matches (() repl-version _ ...), interpret it as the client's protocol version. --- guix/repl.scm | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/guix/repl.scm b/guix/repl.scm index 0f75f9cd0b..a141003812 100644 --- a/guix/repl.scm +++ b/guix/repl.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2018, 2019 Ludovic Courtès +;;; Copyright © 2018, 2019, 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -39,9 +39,10 @@ (one-of symbol? string? keyword? pair? null? array? number? boolean? char?))) -(define (send-repl-response exp output) +(define* (send-repl-response exp output + #:key (version '(0 0))) "Write the response corresponding to the evaluation of EXP to PORT, an -output port." +output port. VERSION is the client's protocol version we are targeting." (define (value->sexp value) (if (self-quoting? value) `(value ,value) @@ -72,13 +73,26 @@ The protocol of this REPL is meant to be machine-readable and provides proper support to represent multiple-value returns, exceptions, objects that lack a read syntax, and so on. As such it is more convenient and robust than parsing Guile's REPL prompt." - (write `(repl-version 0 0) output) - (newline output) - (force-output output) - - (let loop () - (match (read input) + (define (loop exp version) + (match exp ((? eof-object?) #t) (exp - (send-repl-response exp output) - (loop))))) + (send-repl-response exp output + #:version version) + (loop (read input) version)))) + + (write `(repl-version 0 1) output) + (newline output) + (force-output output) + + ;; In protocol version (0 0), clients would not send their supported + ;; protocol version. Thus, the code below checks for two case: (1) a (0 0) + ;; client that directly sends an expression to evaluate, and (2) a more + ;; recent client that sends (() repl-version ...). This form is chosen to + ;; be unambiguously distinguishable from a regular Scheme expression. + + (match (read input) + ((() 'repl-version version ...) + (loop (read input) version)) + (exp + (loop exp '(0 0))))) -- 2.25.1 From unknown Sun Jun 22 04:10:37 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#40077] [PATCH 2/4] inferior: Adjust to protocol (0 1). Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 15 Mar 2020 17:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40077 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40077@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 40077-submit@debbugs.gnu.org id=B40077.15842925358208 (code B ref 40077); Sun, 15 Mar 2020 17:16:01 +0000 Received: (at 40077) by debbugs.gnu.org; 15 Mar 2020 17:15:35 +0000 Received: from localhost ([127.0.0.1]:35423 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWrP-00028J-0x for submit@debbugs.gnu.org; Sun, 15 Mar 2020 13:15:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36958) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWrM-00027i-3s for 40077@debbugs.gnu.org; Sun, 15 Mar 2020 13:15:32 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jDWrG-00030s-WE; Sun, 15 Mar 2020 13:15:27 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41152 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jDWrF-0005z8-BK; Sun, 15 Mar 2020 13:15:26 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sun, 15 Mar 2020 18:15:05 +0100 Message-Id: <20200315171507.22910-2-ludo@gnu.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200315171507.22910-1-ludo@gnu.org> References: <20200315171507.22910-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * guix/inferior.scm (port->inferior): For protocol (0 x ...), where x >= 1, send the (() repl-version ...) form. --- guix/inferior.scm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/guix/inferior.scm b/guix/inferior.scm index 6b685ece30..ec8ff8ddbe 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -159,6 +159,15 @@ inferior." (letrec ((result (inferior 'pipe pipe close (cons 0 rest) (delay (%inferior-packages result)) (delay (%inferior-package-table result))))) + + ;; For protocol (0 1) and later, send the protocol version we support. + (match rest + ((n _ ...) + (when (>= n 1) + (send-inferior-request '(() repl-version 0 1) result))) + (_ + #t)) + (inferior-eval '(use-modules (guix)) result) (inferior-eval '(use-modules (gnu)) result) (inferior-eval '(use-modules (ice-9 match)) result) -- 2.25.1 From unknown Sun Jun 22 04:10:37 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#40077] [PATCH 3/4] repl: Return stack traces along with exceptions. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 15 Mar 2020 17:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40077 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40077@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 40077-submit@debbugs.gnu.org id=B40077.15842925368218 (code B ref 40077); Sun, 15 Mar 2020 17:16:02 +0000 Received: (at 40077) by debbugs.gnu.org; 15 Mar 2020 17:15:36 +0000 Received: from localhost ([127.0.0.1]:35425 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWrP-00028L-8e for submit@debbugs.gnu.org; Sun, 15 Mar 2020 13:15:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36995) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWrM-00027k-UN for 40077@debbugs.gnu.org; Sun, 15 Mar 2020 13:15:33 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jDWrH-00038Q-QV; Sun, 15 Mar 2020 13:15:27 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41152 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jDWrH-0005z8-9B; Sun, 15 Mar 2020 13:15:27 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sun, 15 Mar 2020 18:15:06 +0100 Message-Id: <20200315171507.22910-3-ludo@gnu.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200315171507.22910-1-ludo@gnu.org> References: <20200315171507.22910-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * guix/repl.scm (repl-prompt): New variable. (stack->frames): New procedure. (send-repl-response)[frame->sexp, handle-exception]: New procedure. Pass HANDLE-EXCEPTION as a pre-unwind handler. (machine-repl): Define 'tag'. Bump protocol version to (0 1 1). Wrap 'loop' call in 'call-with-prompt'. --- guix/repl.scm | 64 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/guix/repl.scm b/guix/repl.scm index a141003812..0ace5976cf 100644 --- a/guix/repl.scm +++ b/guix/repl.scm @@ -17,6 +17,8 @@ ;;; along with GNU Guix. If not, see . (define-module (guix repl) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:use-module (ice-9 match) #:export (send-repl-response machine-repl)) @@ -39,6 +41,17 @@ (one-of symbol? string? keyword? pair? null? array? number? boolean? char?))) +(define repl-prompt + ;; Current REPL prompt or #f. + (make-parameter #f)) + +(define (stack->frames stack) + "Return STACK's frames as a list." + (unfold (cute >= <> (stack-length stack)) + (cut stack-ref stack <>) + 1+ + 0)) + (define* (send-repl-response exp output #:key (version '(0 0))) "Write the response corresponding to the evaluation of EXP to PORT, an @@ -49,6 +62,32 @@ output port. VERSION is the client's protocol version we are targeting." `(non-self-quoting ,(object-address value) ,(object->string value)))) + (define (frame->sexp frame) + `(,(frame-procedure-name frame) + ,(match (frame-source frame) + ((_ (? string? file) (? integer? line) . (? integer? column)) + (list file line column)) + (_ + '(#f #f #f))))) + + (define (handle-exception key . args) + (define reply + (match version + ((0 1 (? positive?) _ ...) + ;; Protocol (0 1 1) and later. + (let ((stack (if (repl-prompt) + (make-stack #t handle-exception (repl-prompt)) + (make-stack #t)))) + `(exception (arguments ,key ,@(map value->sexp args)) + (stack ,@(map frame->sexp (stack->frames stack)))))) + (_ + ;; Protocol (0 0). + `(exception ,key ,@(map value->sexp args))))) + + (write reply output) + (newline output) + (force-output output)) + (catch #t (lambda () (let ((results (call-with-values @@ -59,10 +98,8 @@ output port. VERSION is the client's protocol version we are targeting." output) (newline output) (force-output output))) - (lambda (key . args) - (write `(exception ,key ,@(map value->sexp args))) - (newline output) - (force-output output)))) + (const #t) + handle-exception)) (define* (machine-repl #:optional (input (current-input-port)) @@ -73,6 +110,9 @@ The protocol of this REPL is meant to be machine-readable and provides proper support to represent multiple-value returns, exceptions, objects that lack a read syntax, and so on. As such it is more convenient and robust than parsing Guile's REPL prompt." + (define tag + (make-prompt-tag "repl-prompt")) + (define (loop exp version) (match exp ((? eof-object?) #t) @@ -81,7 +121,7 @@ Guile's REPL prompt." #:version version) (loop (read input) version)))) - (write `(repl-version 0 1) output) + (write `(repl-version 0 1 1) output) (newline output) (force-output output) @@ -91,8 +131,12 @@ Guile's REPL prompt." ;; recent client that sends (() repl-version ...). This form is chosen to ;; be unambiguously distinguishable from a regular Scheme expression. - (match (read input) - ((() 'repl-version version ...) - (loop (read input) version)) - (exp - (loop exp '(0 0))))) + (call-with-prompt tag + (lambda () + (parameterize ((repl-prompt tag)) + (match (read input) + ((() 'repl-version version ...) + (loop (read input) version)) + (exp + (loop exp '(0 0)))))) + (const #f))) -- 2.25.1 From unknown Sun Jun 22 04:10:37 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#40077] [PATCH 4/4] inferior: '&inferior-exception' includes a stack trace. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 15 Mar 2020 17:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40077 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40077@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 40077-submit@debbugs.gnu.org id=B40077.15842925368224 (code B ref 40077); Sun, 15 Mar 2020 17:16:02 +0000 Received: (at 40077) by debbugs.gnu.org; 15 Mar 2020 17:15:36 +0000 Received: from localhost ([127.0.0.1]:35427 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWrP-00028V-QO for submit@debbugs.gnu.org; Sun, 15 Mar 2020 13:15:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWrO-00027m-21 for 40077@debbugs.gnu.org; Sun, 15 Mar 2020 13:15:34 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jDWrI-0003H3-U3; Sun, 15 Mar 2020 13:15:28 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41152 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jDWrI-0005z8-6T; Sun, 15 Mar 2020 13:15:28 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sun, 15 Mar 2020 18:15:07 +0100 Message-Id: <20200315171507.22910-4-ludo@gnu.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200315171507.22910-1-ludo@gnu.org> References: <20200315171507.22910-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * 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)) ; | #f + (inferior inferior-exception-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 From unknown Sun Jun 22 04:10:37 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#40077: closed (Re: [bug#40077] [PATCH 0/4] Inferior provide stack traces along with exceptions) Message-ID: References: <871rpo5t37.fsf@gnu.org> <20200315170019.22544-1-ludo@gnu.org> X-Gnu-PR-Message: they-closed 40077 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 40077@debbugs.gnu.org Date: Thu, 19 Mar 2020 14:16:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1584627362-30331-1" This is a multi-part message in MIME format... ------------=_1584627362-30331-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #40077: [PATCH 0/4] Inferior provide stack traces along with exceptions which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 40077@debbugs.gnu.org. --=20 40077: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D40077 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1584627362-30331-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 40077-done) by debbugs.gnu.org; 19 Mar 2020 14:15:33 +0000 Received: from localhost ([127.0.0.1]:43446 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jEvxN-0007sC-FS for submit@debbugs.gnu.org; Thu, 19 Mar 2020 10:15:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jEvxM-0007s1-4m for 40077-done@debbugs.gnu.org; Thu, 19 Mar 2020 10:15:32 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47963) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jEvxH-0005ff-1v for 40077-done@debbugs.gnu.org; Thu, 19 Mar 2020 10:15:27 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=51114 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jEvxG-0001ui-Ed for 40077-done@debbugs.gnu.org; Thu, 19 Mar 2020 10:15:26 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: 40077-done@debbugs.gnu.org Subject: Re: [bug#40077] [PATCH 0/4] Inferior provide stack traces along with exceptions References: <20200315170019.22544-1-ludo@gnu.org> Date: Thu, 19 Mar 2020 15:15:24 +0100 In-Reply-To: <20200315170019.22544-1-ludo@gnu.org> ("Ludovic \=\?utf-8\?Q\?Cou\?\= \=\?utf-8\?Q\?rt\=C3\=A8s\=22's\?\= message of "Sun, 15 Mar 2020 18:00:19 +0100") Message-ID: <871rpo5t37.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 40077-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Ludovic Court=C3=A8s skribis: > repl: Allow clients to send their protocol version. > inferior: Adjust to protocol (0 1). > repl: Return stack traces along with exceptions. > inferior: '&inferior-exception' includes a stack trace. Pushed as 1dca6aaafa9f842565deab1fe7e6929f25544551. Ludo=E2=80=99. ------------=_1584627362-30331-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 15 Mar 2020 17:00:35 +0000 Received: from localhost ([127.0.0.1]:35399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWct-0001ix-EM for submit@debbugs.gnu.org; Sun, 15 Mar 2020 13:00:35 -0400 Received: from lists.gnu.org ([209.51.188.17]:59475) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDWcs-0001iq-4p for submit@debbugs.gnu.org; Sun, 15 Mar 2020 13:00:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53534) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDWcq-0001cl-7o for guix-patches@gnu.org; Sun, 15 Mar 2020 13:00:33 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_40 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54996) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jDWcp-00043i-KT; Sun, 15 Mar 2020 13:00:31 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41128 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jDWcp-0000L7-6p; Sun, 15 Mar 2020 13:00:31 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH 0/4] Inferior provide stack traces along with exceptions Date: Sun, 15 Mar 2020 18:00:19 +0100 Message-Id: <20200315170019.22544-1-ludo@gnu.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello! This patch series allows inferiors to provide stack traces when an exception is thrown. The wire format needed to be changed to provide that info, and thus the protocol had to be adjusted to support both forward and backward compatibility: a new client must be able to talk to an old ‘guix repl’, and an old client must be able to talk to a new ‘guix repl’. To that end, clients now send the protocol version they support. Note that, with these patches, stack traces are available but inferior exceptions are not reported more nicely than before: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (open-inferior "/home/ludo/src/guix" #:command "scripts/guix") $1 = #< pid: pipe socket: # close: # version: (0 1 1) packages: #> table: #>> scheme@(guile-user)> (inferior-eval '(throw 'x 'y 'z) $1) ice-9/boot-9.scm:1669:16: In procedure raise-exception: ERROR: 1. &inferior-exception: arguments: (x y z) inferior: #< pid: pipe socket: # close: # version: (0 1 1) packages: #> table: #>> stack: ((#f ("ice-9/boot-9.scm" 1763 13)) (raise-exception ("ice-9/boot-9.scm" 1668 16)) (#f (#f #f #f)) (#f ("guix/repl.scm" 92 21)) (with-exception-handler ("ice-9/boot-9.scm" 1735 10)) (with-exception-handler ("ice-9/boot-9.scm" 1730 15)) (#f ("guix/repl.scm" 119 7))) Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. --8<---------------cut here---------------end--------------->8--- This is left as an exercise to the reader. Feedback welcome! Ludo’. Ludovic Courtès (4): repl: Allow clients to send their protocol version. inferior: Adjust to protocol (0 1). repl: Return stack traces along with exceptions. inferior: '&inferior-exception' includes a stack trace. guix/inferior.scm | 24 +++++++++++-- guix/repl.scm | 86 ++++++++++++++++++++++++++++++++++++++-------- tests/inferior.scm | 3 ++ 3 files changed, 97 insertions(+), 16 deletions(-) -- 2.25.1 ------------=_1584627362-30331-1--