Skip to content(if available)orjump to list(if available)

A Debugger is a REPL is a Debugger

A Debugger is a REPL is a Debugger

20 comments

·March 25, 2025

porridgeraisin

  $ alias breakpoint
  alias breakpoint='
      while read -p"Debugging(Ctrl-d to exit)> " debugging_line
      do
          eval "$debugging_line"
      done
  '
Good breakpoint repl you can insert anywhere in a bash script

JoelMcCracken

Nice. I recently have been doing a bash deep dive and realizing that treating it like repl driven development is very useful. Been wondering if this is worth writing about for others.

You can also just execute another ‘bash’ process, of course the environment is a bit different

attila-lendvai

in (Common) Lisp it has been like that forever.

the debugger is just a REPL started in a peculiar environment that has e.g. some extra restarts registered by the error handler.

fooker

Sure, a 1980s debugger.

Modern debuggers have specialized capabilities way beyond the reach of REPLs.

Reverse debugging and debugging optimized programs come to mind.

eadmund

Why couldn’t a sufficiently smart REPL have those things as well? Anything can happen after the read and around the execute stage!

fooker

A sufficiently smart anything can do anything.

What makes modern debuggers special is the insane amount of engineering to make it work.

LLDB is close to a thousand man years of engineering iirc.

eadmund

Imagine if that man-millennium of engineering had been spent working on a decent language and ecosystem instead of C, C++ and Objective-C!

That’s what gets me: better languages are able to scrape by with several orders of magnitude less investment, precisely because they are better — but imagine how much more progress we as an industry would have made had we only invested a little more in those more promising ecosystems and a little less in the terrible ones.

bsder

> Modern debuggers have specialized capabilities way beyond the reach of REPLs.

Only if you are running on a machine with a full OS.

Embedded debugging is so bad that Microsoft forcing everybody to use DAP (Debug Adapter Protocol) was a step up.

It also doesn't help that compiler writers never met an optimization that they didn't like. It's often really hard to unwind optimized code back to something useful to probe. Sure, you can turn on debug optimizations but then your code runs an order of magnitude slower.

taeric

I'm curious what features you have in mind that you can't do from the Common LISP REPL?

pjmlp

Only if you ignore Smalltalk and Lisp environments.

There is still some catching up missing from other programming stacks.

whitten

What issues do the lisp and smalltalk repls make easier to debug ?

pjmlp

You can inspect any expression, break into the debugger mid-execution, change the code, whatever code you feel like, redo the execution after applying the changes for example.

The ultimate redo-eval-loop, with almost zero downtime.

They are Jupyter notebooks on steroids.

shmerl

With nvim-dap-ui you can evaluate an expression by selecting it, and it would try to evaluate anything custom you do in the editor that wasn't in the original code.

Try something like this:

    :lua require('dapui').eval()
For running to the current cursor:

    :lua require('dap').run_to_cursor()
Assign that to keys that you want.

It works with gdb's DAP adapter.

john-h-k

`b line` and `expr expr` both work fine in lldb. I agree the ergonomics are less excellent, but that doesn't seem a reason to completely abandon lldb/gdb to me. Maybe I am missing something

Moomoomoo309

If you're using IntelliJ, you can also right click the breakpoints and set conditions, or set a breakpoint to not suspend execution, but to activate another breakpoint so you can wait for a condition or line of code to be reached before the other breakpoint does anything. Super useful for debugging specific scenarios so you don't need to set up the context repeatedly.

null

[deleted]

nilskch

When writing Python in VSCode you get a REPL when you hit a break point and I think that's sweet.

jasonjmcghee

This isn't unique to vscode. It's standard in ides and clients of DAP for interpreted languages