[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Writing a debugger: line breakpoints
- From: "Patrick J. O'Leary Jr." <polearyjr@...>
- Date: Tue, 8 Jul 2008 09:29:30 -0700
Hi Dan,
It's not too difficult to hack around in the parser to pull out this kind of
information on a per script file basis before starting the actual debugging.
I have a modified Lua 5.1.1 .dll I pass the scripts to and it gets
information and sends it back to the debugger app.
Some of the things I pull out are variable names & line numbers (to be able
to "goto variables" by double clicking them on a GUI, function names & line
numbers [defined & last line defined] (again to be able to "goto function"
by double clicking an item on a GUI, and valid breakpoint lines (to do
Visual Studio-ish highlighting of breakpoints that will get hit and those
that will not get hit - I don't do any shuffling to move invalid breakpoints
to valid lines [yet]).
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Dan Posluns
Sent: Monday, July 07, 2008 17:54
To: lua@bazar2.conectiva.com.br
Subject: Writing a debugger: line breakpoints
Hi there,
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"
02-
03- function PrintHello()
04- print x
05- end
06-
07- PrintHello()
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?
Thanks,
Dan.