如何从REPL调试控制台应用程序?

如何从REPL调试控制台应用程序?

问题描述:

使用emacs + cider进行日常开发是非常舒适的。我在文本编辑器中配置的所有东西都使它成为该任务的理想选择。

It's really confortable to use emacs+cider for the daily development. All the stuff I've configured in my text editor makes it ideal for the task.

我在空闲时间工作的当前项目是文本编辑器。我已经在C ++中隐藏了一个,我从emacs中使用了 gdb 来调试。要运行它,我在 gdb中输入设置新控制台运行 code>缓冲区。这将使弹出一个新的控制台来处理所有的I / O

The current project that I'm working on my spare time is a text editor. I've already implmented one in C++ and I used gdb to debug, from emacs. To run it, I entered set new-console on and run in the gdb buffer. This would pop a new console that would handle all the I/O.

现在我试图在Clojure中重新实现它。到目前为止,我最大的问题之一是调试。我认为这不会像我在 gdb 中使用的东西类似。

Now I'm trying to reimplement it in Clojure. By far, one of my biggest concerns is debugging. I think it wouldn't be bad something similar to what I used with gdb.

对于阅读键盘没有缓冲,我使用 JLine 。这意味着读取行不会提供所需的结果。

For reading the keyboard without buffering, I'm using JLine. This means read-line won't provide the desired result.

什么是合理的方式调试这种应用程序(来自控制台的大量I / O )?

What is a reasonable way to debug this kind of app (with lots of I/O from the console)?

如何从emacs / cider 如何做?

使用lein,如果这很重要。

I'm using lein, if this matters.

PS :这是一个类似的问题我做了一个更广泛的意图。我认为值得一看。

P.S.: Here's a similar question I made, with a more broad "intend". I think it's worth seeing.

CIDER附带了一个非常好的调试器。另见截图

CIDER comes with an excellent debugger nowadays. See also this screenshot.

最简单的事情可能是创建一个lein / boot构建配置文件,其中包括nREPL和CIDER作为依赖关系,并使用 embedded CIDER instance 。这将让您从终端运行您的应用程序独立,您可以获得无缓冲的键盘I / O,您可以通过 Mx cider-connect 连接到嵌入式nREPL + CIDER实例,以充分利用调试器和代码加载的方式。

The easiest thing for you will probably be to create a lein/boot build profile which includes nREPL and CIDER as dependencies and make use of an embedded CIDER instance. This will let you run your app "standalone" from a terminal where you'll be able to get unbuffered keyboard I/O, and you can connect via M-x cider-connect to the embedded nREPL+CIDER instance to take full advantage of the debugger and code loading as you normally would.