lua_Debug issue with source and short_src

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

lua_Debug issue with source and short_src

arioch82
Hi guys,

I was trying to use the lua_getstack and lua_getinfo(...,"Sln",...) to get debug infos and print a call stack trace but it doesn't seem to get all the right informations for some reason... the currentline, linedefined, lastlinedefined work just fine but the "source" field always contains the entire file and the short_src the "whatever" characters on the first line (also "name" sometimes contains some weird characters).

I am using a vanilla version of lua integrated in my C++ project, creating a new state with lua_newstate, using luaL_openlibs right after it and running the code with luaL_loadstring using a zero terminated text source plus a separate lua_pcall to run the script.

I have also tried printing the trace using the debug module straight in lua but i have the same issue with source/short_src.

Any thoughts?
I will really appreciate any help.

Thank you
Reply | Threaded
Open this post in threaded view
|

Re: lua_Debug issue with source and short_src

Luiz Henrique de Figueiredo
> I was trying to use the lua_getstack and lua_getinfo(...,"Sln",...) to get
> debug infos and print a call stack trace but it doesn't seem to get all the
> right informations for some reason... the currentline, linedefined,
> lastlinedefined work just fine but the "source" field always contains the
> entire file and the short_src the "whatever" characters on the first line
> (also "name" sometimes contains some weird characters).

What did you expect instead of what you're getting?

BTW, "source" contains the entire file etc because you're using luaL_loadstring.
You can choose what "source" and "short_src" contain if you use luaL_loadbuffer.

Reply | Threaded
Open this post in threaded view
|

Re: lua_Debug issue with source and short_src

arioch82
thank you, that's exactly what i was looking for :)