Jump to content
  • entries
    945
  • comments
    5,899
  • views
    930,076

Even Deeper


Josh

3,254 views

 Share

Lua's debug hooks are a little funny, because they don't appear to allow line-by-line calling of your own function. The description here is pretty vague:

http://pgl.yoyo.org/luai/i/lua_sethook

 

The line and count hooks look like they might be what I wanted, but the docs have one big caveat:

(This event only happens while Lua is executing a Lua function.)

This makes me wonder what the point of these hooks even is. The way I have it set up now, "Step" continues to either the next Debug:Stop() call, or to the next point where a Lua function is called. Not C++ functions, Lua functions only, as shown in the code below.

blogentry-1-0-54389400-1330390282_thumb.jpg

 

Additionally, I found that each time the hook was actually being called twice. No idea why, but I added a flag to discard every other call. I'm not too happy with the documentation of this or it's design, but the important thing is that the Debug:Stop() function be usable to set a program breakpoint, which it can. I sent a query to the Lua mailing list, and I'll work on it some more if anyone indicates that it's supposed to be able to do line-by-line stepping.

 

I did some additional work on the shader editor, adding a few ideas I got from the script editor. The tabs for errors and warnings will show a number indicating how many items each tab has. I also made it so the compiler output gets printed even when the shader is successfully compiled, which wasn't the case before. As you can see in the screenshot below, the shader editor can be very useful for catching problems that might occur on other cards. I have an NVidia GEForce 480 in right now, but I can see from the warnings list this shader probably would not work on other hardware! This is becoming very useful as a diagnostic tool.

blogentry-1-0-53225800-1330390271_thumb.jpg

 

Well, that was my day today. What did you accomplish today?

 Share

6 Comments


Recommended Comments

I don't know, the guys on the mailing list are saying it should be able to step through each line, but that doesn't seem to be happening. I'll spend some more time on it and see...

Link to comment

Got it working now. The problem was that most of the hooks never get called if the DEBUG macro is not defined. I object to having this embedded in the Lua source code, since a competent programmer can use a macro to only set a hook in debug mode, if desired.

Link to comment

I accomplished ... er... something to do with calculating exhaust gas temperature for turboshafts based on an 1983 NASA paper (not as eggheady as it sounds) sad.png

 

Everyone else is having more fun than me. It's not fair.

 

Will the LUA debug work for scripts called during normal program execution? e.g. C# LE3D program loads a model with a LUA script

Link to comment

Yes, you can debug the Lua state of any application that is built with the debug Leadwerks3D library.

  • Upvote 1
Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...