[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile debugger workgroup?
From: |
Attila Lendvai |
Subject: |
Re: Guile debugger workgroup? |
Date: |
Mon, 28 Nov 2022 14:12:11 +0000 |
> Do you have examples in mind of things you’d like to log and that would
> have helped you on a debugging journey?
the first thing that pops to my mind is the service start gexp's in shepherd:
they felt impossible to debug. i often was pretty much resorting to staring at
the code, and then trying ad-hoc changes (with a minute+ long edit-compile-test
cycle).
there are multiple issues here. the first one is that there's no proper error
handling in shepherd. but if there was at least a semi-global error handler,
that logged a full backtrace into a log file, then it would have been immensely
helpful.
for inspiration, this is what we developed in common lisp:
https://hub.darcs.net/hu.dwim/hu.dwim.util/browse/source/error-handling.lisp#10
WITH-LAYERED-ERROR-HANDLERS is a macro for which you can provide a "level 1"
error handler hook that does whatever it wants. if any errors happen within
this hook, then a level2 error handler kicks in, turns off several things (e.g.
custom PRINT-OBJECT methods), and tries to log a backtrace in a defensive way
(e.g. there are error handlers installed while printing each backtrace level).
if even level2 errors out, then a super conservative level3 error handler logs
this fact, so that there's *some* sign of an error.
note that the logging library must also be smart about how it deals with errors.
the default level1 handler has fancy features like "backtrace decorators",
which is a registry of dinamically bound thunks that are called when a
backtrace is printed. they can decorate the end of the backtrace with dynamic
information from the context that is not captured by the backtrace (e.g. the
web session, the user logged in, etc).
this error handler mechanism is installed at strategic points, like the
handling of a http request, or a great candidate would be when calling the user
code in the start gexp of a shpeherd service.
let me know if anything like this is available in scheme.
i know about these in guix and guile:
/guix/ui.scm: (define (call-with-error-handling
/module/system/repl/error-handling.scm: (define* (call-with-error-handling
the longer i work on/in guix, the higher the chance that i'll port parts of our
CL debugging stuff to scheme. i think i was just procractinating it until i
develop a deep enough understanding of scheme to do it properly.
HTH,
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“We are caged by our cultural programming. Culture is a mass hallucination, and
when you step outside the mass hallucination you see it for what it's worth.”
— Terence McKenna (1946–2000), from the lecture 'Eros and the Eschaton'
(1994)
- Re: Guile debugger workgroup?, (continued)
- Re: Guile debugger workgroup?, Attila Lendvai, 2022/11/27
- Re: Guile debugger workgroup?, Maxim Cournoyer, 2022/11/27
- Re: Guile debugger workgroup?, Joshua Branson, 2022/11/28
- Re: Guile debugger workgroup?, Ludovic Courtès, 2022/11/28
- Re: Guile debugger workgroup?,
Attila Lendvai <=
- Re: Guile debugger workgroup?, Ludovic Courtès, 2022/11/29
Re: Guile debugger workgroup? (was: Coding style: similarly-named variables), Csepp, 2022/11/28
Re: Guile debugger workgroup?, Jannneke Nieuwenhuizen, 2022/11/30