ignacio / StackTracePlus

StackTracePlus provides enhanced stack traces for Lua.
MIT License
195 stars 27 forks source link

Dump locals of C functions #10

Open devurandom opened 9 years ago

devurandom commented 9 years ago

STP currently does not dump locals of C functions. When debugging those written using the Lua C API, it sometimes happens that the stacks looks different from what I expected. In these cases I would love to use STP to tell me about the stack.

The fix is simple:

--- a/src/StackTracePlus.lua
+++ b/src/StackTracePlus.lua
@@ -355,6 +355,7 @@ Stack Traceback
                        local function_name = m_user_known_functions[info.func] or m_known_functions[info.func] or info.name or tostring(info.func)
                        dumper:add_f("(%d) %s C function '%s'\r\n", level_to_show, info.namewhat, function_name)
                        --dumper:add_f("%s%s = C %s\r\n", prefix, name, (m_known_functions[value] and ("function: " .. m_known_functions[value]) or tostring(value)))
+                       dumper:DumpLocals(level)
                elseif info.what == "tail" then
                        --print("tail")
                        --for k,v in pairs(info) do print(k,v, type(v)) end--print(info.namewhat, info.name)
ignacio commented 9 years ago

Locals of C functions? Do you have an example of this change in action? I don't really understand how would that work.