lua-users home
lua-l archive

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


I've used WinDbg and gdb to pick Lua stack traces out of a native debugger (usually 
from memory dumps) by inspecting the CallInfo structures directly to determine the
source, function, and line number (mapped by opcode offset).

That said, I haven't turned that into something fully automatic at this point. 

Especially with release builds that are stripped and optimized, I've definitely found
that sometimes the debugger has a great deal of trouble getting coherent values 
for the Lua state's fields depending on where it paused/crashed. I can generally
either find a frame where things do look sane or look at the disassembly to find the
registers with the pointers into the structure, though.

I'd be curious to hear more if you have luck extracting a co-mingled C/Lua stack
reliably. I've considered taking a crack at that myself.

DT

________________________________________
From: lua-l-bounces@lists.lua.org [lua-l-bounces@lists.lua.org] On Behalf Of Richter, Jörg [Joerg.Richter@pdv-FS.de]
Sent: Friday, April 27, 2012 8:26 AM
To: lua-l@lists.lua.org
Subject: Intermixing C-stack with Lua-stack

Dear list,

Suppose I have some function to walk up the C-stack to print the C-backtrace.

Now my goal is to intermix this C-backtrace with the corresponding Lua-backtrace.
This means I have to identify a known function from the Lua interpreter. Somehow
find the L pointer and then use the regular lua_* functions to query the stack.

I think luaV_execute is the function to look for in the C-stack.
Then look in the c-stack of this stack frame to find something that looks like a lua_State*.
Some basic verfications of the lua_State invariants should be necessary.
Then call lua_getstack & co.

Has anyone done this before? Is this hopeless?
Or are there any other methods to achieve my goal?


   Jörg