[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: LUA Debugger Addin (Visual Studio)
- From: "Zulfiqar Malik" <zulfiqar.malik@...>
- Date: Thu, 29 Sep 2005 10:41:26 +0500
Thanks for the info Rici.
You certainly have confused me a lot :(. However I have another problem and
I have tried to find an answer to that, looking into docs and searching
online but can't seem to find a solution.
Support I have a C structure or a C++ class registered with LUA using some
library such as luabind. How can I get the members of this variable.
Querying the type of such a variable from lua returns LUA_TUSERDATA, but I
can't seem to find a way to enumerate the member variables of this user
data. Can someone point me to a link or article.
Thanks,
Zulfiqar Inayat Malik.
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Rici Lake
Sent: Thursday, September 29, 2005 7:54 AM
To: Lua list
Subject: Re: LUA Debugger Addin (Visual Studio)
On 27-Sep-05, at 12:39 AM, Zulfiqar Malik wrote:
> How can i determine whether a symbol is local or global (when a user
> specifies a variable to be watched in the watch window), and whether
> its a
> lua function, C function or something else?
There is no real way to answer this question, particularly since two
local variables might have the same name. Consider:
do
local i = 1
--- lots of stuff using i
end
do
-- this is a different 'i'
local i = "foo"
end
If the program being debugged is halted at some execution point, you
can enumerate the various possible local variables with the debug
interface. However, the Lua API does not give you a practical way
to identify a local variable "i" so that it can be correlated with
a local variable "i" visible at a different point of the program.
(The information can be derived by analysing Lua internal structures,
or can be gleaned by reparsing the Lua source code, which is what I
did with LuaParse.)
> Is there anyway to add breakpoints to lua_State because otherwise i
> will
> have to handle it manually and that is bound to be more error prone.
I believe the intended solution to breakpoints is to install a linehook
and then, inside the hook function, compare the line number with a table
of breakpoints.
> I added the source code snippet in lua reference manual (5.0) about
> enumerating local variables, but it doesn't work. lua_getstack(...)
> always
> returns 0. The stack level being passed is the top of the stack.
The 'level' in question here is the execution level, counting backwards
from the current function. This has no relationship whatsoever with the
value returned by lua_gettop(). If you think of the internal execution
stack as a stack of stack-frames, where only the top stack-frame is
visible to the executing function (aside from the use of the debugging
interface), this might make more sense, although you have to remember
that indices inside a stack frame count *upwards* from 1 and *downwards*
from -1, whereas stack-frame levels themselves count *downwards* from 1
(and no absolute index is available.) I've probably confused you more
by that answer.
> I would be thankful if someone would answer these questions. Any
> comments
> about whether this is the right approach or not are most welcome.