Whilst trying to debug one of my Plugins, I found that I really needed some automatic debugging ( rather than typing lprint statements everywhere ), so I looked through a book that I bought a while ago ( "Beginning Lua Programming" by Kurt Jung & Aaron Brown - Wiley Publishing Inc, 2007 ) and came across the attached gem.
Basically, all you have to do is place the attached lua file in the relevant Skyline folder, and use the following commands:
- Code: Select all
sky.include "calltrace.lua"
Trace ( ) -- Turns on tracing.
Untrace ( ) -- Turns off tracing.
The output is saved to a file in your Skyline Data folder as "Trace.txt".
IMPORTANT - as my modified code writes to a .txt file it is vital that you have an easy way of calling Untrace ( ) (e.g. just call Trace ( ) at the beginning of your block of code, and Untrace ( ) at the end). ALSO, multiple calls to Trace ( )/Untrace ( ) will overwrite the contents of the file, so best to ensure you only call it once for your block of code (use a Boolean to prevent multiple calls).
The output looks something like this, which may take a bit of getting used to, but it does mean you can analyse it in Excel etc.:
- Code: Select all
calling Lua function from nowhere
calling getCurrentIndex from Lua function ( line: 310 )
returning from getCurrentIndex to Lua function ( line: 310 )
calling getComboItemText from Lua function ( line: 310 )
returning from getComboItemText to Lua function ( line: 310 )
calling setTableItemText from Lua function ( line: 311 )
returning from setTableItemText to Lua function ( line: 311 )
calling getCurrentIndex from Lua function ( line: 313 )
returning from getCurrentIndex to Lua function ( line: 313 )
calling getComboItemText from Lua function ( line: 313 )
returning from getComboItemText to Lua function ( line: 313 )
calling setTableItemText from Lua function ( line: 314 )
returning from setTableItemText to Lua function ( line: 314 )
calling getValue from Lua function ( line: 316 )
returning from getValue to Lua function ( line: 316 )
calling toString from Lua function ( line: 317 )
returning from toString to Lua function ( line: 317 )
calling setTableItemText from Lua function ( line: 317 )
returning from setTableItemText to Lua function ( line: 317 )
calling setTableItemTextAlign from Lua function ( line: 319 )
returning from setTableItemTextAlign to Lua function ( line: 319 )
calling setTableItemTextAlign from Lua function ( line: 320 )
returning from setTableItemTextAlign to Lua function ( line: 320 )
calling setTableItemTextAlign from Lua function ( line: 321 )
returning from setTableItemTextAlign to Lua function ( line: 321 )
calling updateTable from Lua function ( line: 323 )
calling getNumTableRows from updateTable ( line: 118 )
returning from getNumTableRows to updateTable ( line: 118 )
calling getTableItemText from updateTable ( line: 119 )
returning from getTableItemText to updateTable ( line: 119 )
calling getTableItemText from updateTable ( line: 120 )
returning from getTableItemText to updateTable ( line: 120 )
calling getTableItemText from updateTable ( line: 121 )
returning from getTableItemText to updateTable ( line: 121 )
calling insert from updateTable ( line: 124 )
returning from insert to updateTable ( line: 124 )
calling getTableItemText from updateTable ( line: 127 )
returning from getTableItemText to updateTable ( line: 127 )
calling getTableItemText from updateTable ( line: 128 )
returning from getTableItemText to updateTable ( line: 128 )
calling getTableItemText from updateTable ( line: 129 )
returning from getTableItemText to updateTable ( line: 129 )
calling populateCombos from updateTable ( line: 131 )
calling getTableLength from populateCombos ( line: 257 )
calling pairs from getTableLength ( line: 88 )
returning from pairs to getTableLength ( line: 88 )
calling (for generator) from getTableLength ( line: 88 )
returning from (for generator) to getTableLength ( line: 88 )
calling (for generator) from getTableLength ( line: 88 )
returning from (for generator) to getTableLength ( line: 88 )
calling (for generator) from getTableLength ( line: 88 )
returning from (for generator) to getTableLength ( line: 88 )
calling (for generator) from getTableLength ( line: 88 )
returning from (for generator) to getTableLength ( line: 88 )
calling (for generator) from getTableLength ( line: 88 )
returning from (for generator) to getTableLength ( line: 88 )
returning from getTableLength to populateCombos ( line: 257 )
Hope it helps some of you until the Devs find time to implement something in the Lua Editor.
Regards
Shando
PS: This will also show all standard Lua calls (for example "for generator" above). I haven't found an easy way to stop this as Lua treats all functions the same whether standard Lua or not