如何关闭 sbcl 中的调试器

发布于 2024-09-05 22:44:04 字数 127 浏览 3 评论 0原文

我目前正在尝试学习 common lisp,并且一直在使用 sbcl (我希望这是一个不错的实现选择。)

来自 ruby​​ 和 irb,我发现此时每个错误都会自动转移到调试器,这有点烦人。有没有办法在我玩的时候暂时关闭它。

I'm trying to learn common lisp currently and I've been using sbcl (I hope that's a decent implementation choice.)

Coming from ruby and irb I find the automatic moved to a debugger on every mistake a little annoying at this time. Is there a way to turn it off temporarily when I'm playing around.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤寂小茶 2024-09-12 22:44:04

Common Lisp 有一个变量 *debugger-hook*,可以绑定它/设置为一个函数。

* (aref "123" 10)

debugger invoked on a SB-INT:INVALID-ARRAY-INDEX-ERROR:
  Index 10 out of bounds for (SIMPLE-ARRAY CHARACTER
                              (3)), should be nonnegative and <3.

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-INT:INVALID-ARRAY-INDEX-ERROR "123" 10 3 NIL)
0] 0

* (defun debug-ignore (c h) (declare (ignore h)) (print c) (abort))

DEBUG-IGNORE
* (setf *debugger-hook* #'debug-ignore)

#<FUNCTION DEBUG-IGNORE>
* (aref "123" 10)

#<SB-INT:INVALID-ARRAY-INDEX-ERROR {1002A661D1}>
* 

Common Lisp has a variable *debugger-hook*, which can be bound/set to a function.

* (aref "123" 10)

debugger invoked on a SB-INT:INVALID-ARRAY-INDEX-ERROR:
  Index 10 out of bounds for (SIMPLE-ARRAY CHARACTER
                              (3)), should be nonnegative and <3.

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-INT:INVALID-ARRAY-INDEX-ERROR "123" 10 3 NIL)
0] 0

* (defun debug-ignore (c h) (declare (ignore h)) (print c) (abort))

DEBUG-IGNORE
* (setf *debugger-hook* #'debug-ignore)

#<FUNCTION DEBUG-IGNORE>
* (aref "123" 10)

#<SB-INT:INVALID-ARRAY-INDEX-ERROR {1002A661D1}>
* 
半寸时光 2024-09-12 22:44:04

有一个 --disable-debugger 命令行选项,例如:

$ sbcl --disable-debugger

从手册页:

默认情况下,当 SBCL 遇到
错误,进入内置
调试器,允许交互
诊断和可能的调解。
该选项禁用调试器,
导致打印回溯错误
并以状态 1 退出 --
哪种操作方式比较好
适合批量处理。请参阅
SB-EXT:DISABLE-DEBUGGER 用户手册
了解详情。

您可能还会发现 --noinform--noprint CL 选项很有用。

There is a --disable-debugger command-line option, e.g.:

$ sbcl --disable-debugger

From the man page:

By default when SBCL encounters an
error, it enters the builtin
debugger, allowing interactive
diagnosis and possible intercession.
This option disables the debugger,
causing errors to print a back‐trace
and exit with status 1 instead --
which is a mode of operation better
suited for batch processing. See the
User Manual on SB-EXT:DISABLE-DEBUGGER
for details.

There are also --noinform and --noprint CL options you may find useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文