lua-users home
lua-l archive

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


I get an error using the luatrace library from my code

In my script file scriptfuncs.lua I have luatrace = require"luatrace" at the top

In C++ I do the following:

lua_State *L = luaL_newstate();
luaL_openlibs(L);
luaL_dofile(L, "lua_script/scriptfuncs.lua");
start_profiler(L);

<various lua and c++ calls>

stop_profiler(L);
lua_close(L);

where

int own_lua_call(lua_State* L, int nargs, int nresults)
{
int nErrorCode = 0;
nErrorCode = lua_pcall( L, nargs, nresults, 0 );
if( nErrorCode != 0 )
HandleLuaError(L);

return nErrorCode;
}

void start_profiler(lua_State* L){
lua_getfield(L, LUA_GLOBALSINDEX, "luatrace");
lua_getfield(L, -1, "tron");
lua_remove(L, -2);
own_lua_call(L, 0, 0);
}

void stop_profiler(lua_State* L){
lua_getfield(L, LUA_GLOBALSINDEX, "luatrace");
lua_getfield(L, -1, "troff");
lua_remove(L, -2);
own_lua_call(L, 0, 0);
}

I get the error: luatrace.lua:351: attempt to index upvalue 'recorder' (a nil value)'

I don't have any own references to recorder in any of my lua code

are there any parameters I should pass to tron for this to work which I miss?

On Mon, Oct 10, 2011 at 11:16 AM, steve donovan <steve.j.donovan@gmail.com> wrote:
On Mon, Oct 10, 2011 at 11:00 AM, Oskar Forsslund
<matrixsmurfen@googlemail.com> wrote:
> If I rewrite the command in luatrace.profile.bat from
> lua -e 'require("luatrace.profile").go()'
> to
> lua -e "require('luatrace.profile').go()"
> everything works fine.

Yes, that's how it must be with Windows, where double-quote is always
used for command-line arguments.

steve d.