lua-users home
lua-l archive

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

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

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)


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

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.


XSe Logo

XS Embedded LLC
28850 Cabot Drive, Suite 1000
Novi, MI 48377

Phone +1 (248) 209 - 6613
Fax +1 (248) 281 - 7020

:::::::::: based.on.visions ::::::::::

XS Embedded LLC
Managing Director: Joachim Kobinger

Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.