Re: LuaProbe — small source-level debugger for Lua 5.1 / LuaJIT (two files, no C deps)

António Cardoso <[email protected]> Wed, 29 Apr 2026 07:17:05 -0700 (PDT)
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>
Hi Martin,

Added now a way to do what you want (more or less). This repo will never 
allow you to add something like LuaProbe:PrintState because one of the 
reasons for its creation was to avoid injecting code in the codebase.
Instead you can run like this 2 examples, where by setting up as log-only 
breakpoints by adding the ! simbol to the expression. 

bin/luaprobe -b 'examples/demo.lua:7![locals,stack] if i == 2' examples/demo.lua 

luaprobe: launching: lua5.1 examples/demo.lua 
luaprobe:   breakpoint: examples/demo.lua:7![locals,stack] if i == 2 
luaprobe: waiting for events (Ctrl-C to quit) 
hello, world (1) 
hello, world (2) 
hello, world (3) 
luaprobe: child attached 

[LOG] examples/demo.lua:7  [main] 
 #1  greet                    examples/demo.lua:7 
 #2  <main>                   examples/demo.lua:11 
 #3  [C]                      =[C]:-1 
 locals: 
   name = "world" 
   times = 3 
   message = "hello, world" 
   i = 2


and here it is without any condition and just removing the stack

bin/luaprobe -b 'examples/demo.lua:7![-stack]' examples/demo.lua      
luaprobe: launching: lua5.1 examples/demo.lua 
luaprobe:   breakpoint: examples/demo.lua:7![-stack] 
luaprobe: waiting for events (Ctrl-C to quit) 
hello, world (1) 
hello, world (2) 
hello, world (3) 
luaprobe: child attached 

[LOG] examples/demo.lua:7  [main] 
 #1  greet                    examples/demo.lua:7 
 locals: 
   name = "world" 
   times = 3 
   message = "hello, world" 
   i = 1 

[LOG] examples/demo.lua:7  [main] 
 #1  greet                    examples/demo.lua:7 
 locals: 
   name = "world" 
   times = 3 
   message = "hello, world" 
   i = 2 

[LOG] examples/demo.lua:7  [main] 
 #1  greet                    examples/demo.lua:7 
 locals: 
   name = "world" 
   times = 3 
   message = "hello, world" 
   i = 3

You can of course then setup your own GUI or custom interface for whatever 
editor you choose, we will be also publishing in a near future a proper TUI 
using lua-curses and an emacs extension. bin/luaprobe is already a small 
CLI for it but a very mininal one and it might get in the way

-Antonio Cardoso
A quarta-feira, 29 de abril de 2026 à(s) 15:24:12 UTC+2, Martin Eden 
escreveu:

> On 2026-04-29 14:56, António Cardoso wrote:
> > Hi Martin,
> >
> > Two things regarding your question.
> >
> > First, keep in mind that LuaProbe is responsible for starting your Lua
> > program. Unlike some other debuggers that can be attached midway through
> > execution, LuaProbe must be enabled from the start. This means your
> > software must either run in debug mode or not at all. That’s important
> > because debugging can slow execution by a factor of two to four. If your
> > application has time-critical sections, this may cause issues.
> >
> > Second, and more directly related to your question: you don’t need to
> > insert anything into your code for this. LuaProbe supports both 
> traditional
> > breakpoints and log-only breakpoints. A log-only breakpoint will not halt
> > execution; it simply updates the output when reached. You can also attach
> > conditions to these breakpoints.
> >
> > For example:
> > foo.lua:42! if user.id == target_id
> >
> > The ! makes it a log-only breakpoint. Without it, the breakpoint behaves
> > like a normal stopping breakpoint.
> >
> > Best Regards
> > - Antonio Cardoso
>
> Hi Antonio,
>
> Its okay, that debugger will load program, not vice versa.
>
> What will be useful for my case is non-interactive debugger.
>
> So I won't spend calories on smashing keys in debugger's shell.
> Instead in code I'll add something like
>
>   local some_very_tricky_condition
>   -- [...]
>   if some_very_tricky_condition then
>     LuaProbe:PrintState(
>       {
>         Locals = true,
>         Stacktrace = false,
>         Upvalues = false,
>       }
>     )
>   end
>
> -- Martin
>
>

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/55000083-3a67-4383-90de-b5413c1a6307n%40googlegroups.com.