[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Writing a debugger: line breakpoints
- From: "Dan Posluns" <dposluns@...>
- Date: Mon, 7 Jul 2008 17:53:49 -0700
I'm currently trying to write a C-side Lua debugger using line hooks.
The problem I've encountered is attempting to set a breakpoint for a
certain line in a file, and then matching that line up to an actual line
that Lua's line hook will stop on.
I can retrieve a table of valid lines using lua_getinfo, but the problem
is that table excludes lines from inside of function definitions. I
could inspect the functions themselves using lua_getinfo, except the
functions don't get defined until the code is actually *run*, at which
point it's kind of late.
Further example... let's say I have the following Lua file:
01- x = "Hello world"
03- function PrintHello()
04- print x
The table of valid lines will include 1, 3, 5 and 7, but not 4 (as it is
inside a function definition).
I could inspect the PrintHello() function, but only *after* the code
defining it has run.
If the user puts a breakpoint on line 4, I could temporarily snap it to
line 5, but that code *needs* to run in order for me to ever know that 4
is a valid line, which means I'm going to erroneously trigger a
breakpoint on line 5. It's a whole chicken-and-egg problem...
Has anyone dealt with this problem in the past? Is there *any* way to
get the *complete* set of valid lines in a file without actually running
the code first?