[Solved] Want better debugging of lua scripts

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

earthsruler
Quite a regular
Quite a regular
Posts: 74
Joined: Mon Apr 28, 2008 23:21
Location: Australia

Postby earthsruler » Mon Dec 01, 2008 00:31

Currently, I have to lean towards saying - if I might be so bold - that I believe there might be an issue in your lua code somewhere


**GASP**

Well we are calling stored lua functions...

This code pretty much queries a message queue to see if it has any messages and passes them around to the subscribed lua functions. Keep in mind that this is working flawlessly in the current version.

Code: Select all

--Needs to take the name of the function and the name of the event to wait for
function MessageTracker.SubscribeMethod( eventName, functionName )

   --Create a table for this event name if it doesnt already exist
   if Handlers[eventName] == nil then
      Handlers[eventName] = {}
   end
         
   Handlers[eventName][functionName] = true
   
end


--------------------------------------------------------------------------------------------------------------------------
--Used to unsubscribe a function from the lua event thing
function MessageTracker.UnsubscribeMethod( eventName, functionName )
   
   if Handlers[eventName] then
      Handlers[eventName][functionName] = nil
   end
   
end


--------------------------------------------------------------------------------------------------------------------------
--Used to unsubscribe a function from the lua event thing
function MessageTracker.DoUpdate( args )

   --Go through the recieved events/messages and call any of the recievers waiting for it
   if MessageTracker.tool then
      
      while MessageTracker.tool:gotMail() do
         
         smartPointer = MessageTracker.tool:handleMessage()
      
         if Handlers[smartPointer:getPtr().mIdentifier] ~= nil then
            for i,k in pairs(Handlers[smartPointer:getPtr().mIdentifier]) do
               if k == true then
                  i( smartPointer )
               end
            end
         end
      end
   end
end

--------------------------------------------------------------------------------------------------------------------------
function MessageTracker:Initialise()

   MessageTracker.tool = circus.CastFunctions.toMessageTrackerTool(circus.ToolSystem:getSingleton():getTool( "MessageTrackerTool" ))
   
   globalEventManager:subscribeEvent( "Window/WindowUpdate", MessageTracker.DoUpdate, MessageTracker)   

end

MessageTracker.Initialise();



-Also there isn't anywhere that is overriding MessageTracker.DoUpdate symbol to some other value.
-MessageTracker.lua isn't getting "included" twice (which could override its table and make the DoUpdate function have a different "value")
-There were no other "errors" logged with insane logging

Seeing you are trying to have a nice stable version released this week, i might stay at work a little later to try one more time to update and see if i can be of any more help.

HTH.

ER.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Dec 01, 2008 10:20

Hi,

earthsruler wrote:There were no other "errors" logged with insane logging

This is with the old version that worked?

earthsruler wrote:Seeing you are trying to have a nice stable version released this week, i might stay at work a little later to try one more time to update and see if i can be of any more help.

The 0.6.2 release is pretty much a done deal as of this past weekend - due to time constraints we have to say "this is it" at some stage - otherwise the release might not get done until maybe next year. While the "release" might be actually made available for example on Wednesday, the fact is that the component packages will have been built over a period of many days leading up to that (currently I have some of the packages on my hard drive, and scriptkid is working on some others). Because I couldn't easily reproduce this issue and thus prove it's a CEGUI issue, I made the decision to proceed with the release (time will tell if that was the right call ;) ).

I would certainly appreciate any assistance in tracking the issue down, because as of right now I have no ideas at all :?

Currently my suggestion, which is basically to try and aid in tracking down the cause, is to add some diagnostics to the lua code in order to better see what is (or is not) happening. So, would it be possible to add a line that prints or logs the functions being called in MessageTracker.DoUpdate, just something simple like:

Code: Select all

print ( tostring( i ) )

prior to actually calling 'i'? (and maybe on the other calls in there also. This is suggested basically because the name of the function causing the error is not logged, so we have to find out what it is by other means). The output, or lack of output, would also determine whether the lua event handler is actually getting called at all, or if the issue occurs somewhere before hand (basically meaning whether it occurs on the CEGUI side or the app side).

Dazed and confused,

CE

earthsruler
Quite a regular
Quite a regular
Posts: 74
Joined: Mon Apr 28, 2008 23:21
Location: Australia

Postby earthsruler » Wed Dec 03, 2008 23:58

Hi. I haven't checked it yet as I am refusing to do overtime until we again have aircon (it died on monday and I have been sweating and doing no more than 7.6 hours ever since).

When the A\C is back up I'll look into it.

ER.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Dec 04, 2008 11:11

earthsruler wrote:I haven't checked it yet as I am refusing to do overtime until we again have aircon

Sticking it to the man, cool! (or in your case apparently not cool :P).

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Dec 11, 2008 19:30

Ok, unless anyone missed it, the issue reported here by earthsruler is almost certainly the same issue that caused the 0.6.2 release to be withdrawn and replaced with 0.6.2b - as discussed in this topic.

So, what do we learn from this? Should I have delayed the 0.6.2 release to fix the issue as originally reported here? The thing was that it was seemingly impossible to reproduce this issue on linux - which is what I use as the primary development platform for CEGUI - so while the withdrawal and reissue was hugely regrettable, given the same set of circumstances I'd probably do exactly the same again ;)

Perhaps the lesson here is that if you can't reproduce an issue, try a different OS!

CE.

earthsruler
Quite a regular
Quite a regular
Posts: 74
Joined: Mon Apr 28, 2008 23:21
Location: Australia

Postby earthsruler » Fri Dec 12, 2008 00:07

That is intense. I cant help but feel a little guilty for not being able to help contribute more.

Any way its great that the issue was found and fixed.

I wonder when ogre are going to start including a more up-to-date version.


PS A/C went up on Tuesday :). Bliss.


ER.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Dec 12, 2008 09:51

Hey, no problemo ;) Once I was able to reproduce the issue I found the cause reasonably quickly - which was surprising due to the fact it was hidden within code that otherwise looked totally reasonable.

Congrats on the A/C 8)

CE.

User avatar
ErikHjortsberg
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Sun Jan 23, 2005 12:45
Location: Sweden
Contact:

Postby ErikHjortsberg » Wed Mar 04, 2009 12:15

This feature works excellently, but one issue is that if none of the execute* methods are called the error function will never be set up.

For example, in Ember I load the lua files directly, without using the execute* methods, which causes the d_activeErrFuncName variable never to be set up correctly for the functor calls. The solution is to just call executeString("") however.
Ember, a client for the Worldforge system.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Mar 05, 2009 09:30

Hi,

Thanks for the feedback. I may look and see if a fix can be affected for this (admittedly minor) issue :)

CE.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 1 guest