lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


i like it when i can answer my own questions ;)

after some poking around, i found that i could just call debug.getinfo the
LuaInterface way:

public void Callback()
{
	object[] tInfo = lua.GetFunction("debug.getinfo").Call(2);
	button1.Text = "i just called, to say, hellooo-ho!";
	luaThread.Suspend();
}

Also, i was able to work around the thread problem by using a callback
function which i call from the hook function, and doing the Suspend on C#
side. The callback is registered like this:

lua.RegisterFunction("Callback", this, typeof(Form1).GetMethod("Callback"));


-----Ursprüngliche Nachricht-----
Von: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] Im Auftrag von steffenj
Gesendet: Samstag, 20. August 2005 18:26
An: lua@bazar2.conectiva.com.br
Betreff: LuaInterface & threads

I intend to write a Lua debugger in C# via LuaInterface. I don't see the
debug facility exposed to C# programs, is this correct?

Currently, i'm trying to debug by using debug.sethook from within the lua
script. When the hook (a lua function) gets called, i want to suspend the
thread that does the lua.DoString("...") call, the thread is created like
this:

luaThread = new Thread(new ThreadStart(LuaDoStringThread));
luaThread.Start()

But when i do

luaThread:Suspend() -- in lua's hook function
(note that luaThread.Suspend() raises a "invalid arguments to method call"
exception)

and call

luaThread.Resume() -- in C#

i get an exception that the thread hasn't been suspended manually or so.


I also looked into luaThread.Sleep() but oddly, in Lua this method is a
table with the following member:

[".fqn"] = value;

Correspondingly, when i try to call it, all i get is the exception:
[string "chunk"]:23: No such type: value


So far, i can only slow down the script by adding a "for" loop in the hook
function. The textbox i write to is correctly updated, so i can see what
happens when the script runs. But i want to be able to actually set a
breakpoint and suspend the script, while inspecting variables, call stack,
etc. How would i go about this?

I would appreciate any help or hints!
Steffenj