lua-users home
lua-l archive

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


I forgot to mention I am currently using Lua 5.1.4.

Tysen

From: Moore, Tysen
Sent: Friday, February 15, 2013 7:25 PM
To: lua-l@lists.lua.org
Subject: Using debug.sethook() across coroutines

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


XSe Logo

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

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

www.xs-embedded.com
Tysen.Moore@xs-embedded.com

:::::::::: 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.