lua-users home
lua-l archive

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


Sorry for the previous problem--corporate email is such a pain sometimes.

Any ways, I am writing a simple Lua coverage script to gauge the coverage of my Lua source code.  I have found that it works fairly well when I have a simple test file that executes without coroutines.  When I run the same tool against more complex code that has coroutines I find the sethook callbacks ends.  Is there a way to use sethook that will work across coroutines without modifying my original source code?  I'd prefer not to modify the code I am profiling.  Or is there anyway to get this to work?

Basically the code does the following:

> lua lcov.lua main.lua

lcov.lua:
...
local f = assert( loadfile(fileToExec) ) -- execute main.lua
debug.sethook(covHandler, "l" )
f()   -- run the main program

(I've also tried just: dofile( fileToExec ) for what it's worth)

main.lua does the following:
function calledInt( fmt, ... )

    local msg = string.format(fmt, unpack(arg))
    print("calledInt: "..msg)

end

local function main()
    calledInt("Value: %d", 0)
end

local co = coroutine.create( main )
coroutine.resume( co )

Once the coroutine starts my sethook callback (covHandler) is no longer hit.  I see no callbacks for calls inside of "calledInt()".  Any help or suggestions would be MUCH appreciated.

Tysen