MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / UpdateStackLevel

Method UpdateStackLevel

emmy_debugger/src/debugger/hook_state.cpp:51–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void StackLevelBasedState::UpdateStackLevel(std::shared_ptr<Debugger> debugger, lua_State* L, lua_Debug* ar)
52{
53 if (L != currentStateL)
54 {
55 return;
56 }
57 // this is needed to check if the stack got shorter or longer.
58 // unfortunately counting call/return calls is not reliable.
59 // the discrepancy may happen when "pcall(load, '')" call is made
60 // or when "error()" is called in a function.
61 // in either case there are more "call" than "return" events reported.
62 // this validation is done for every "line" event, but should be "cheap"
63 // as it checks for the stack to get shorter (or longer by one call).
64 // start from one level higher just in case we need to grow the stack.
65 // this may happen after coroutine.resume call to a function that doesn't
66 // have any other instructions to execute. it triggers three returns:
67 // "return, tail return, return", which needs to be accounted for.
68
69 newStackLevel = debugger->GetStackLevel(false);
70
71 // "cheap" version
72 // lua_Debug ar2{};
73 // for (int i = newStackLevel + 1; i >= 0; --i)
74 // {
75 // if (lua_getstack(L, i, &ar2))
76 // {
77 // newStackLevel = i + 1;
78 // break;
79 // }
80 // }
81}
82
83bool HookStateStepIn::Start(std::shared_ptr<Debugger> debugger, lua_State* current)
84{

Callers

nothing calls this directly

Calls 1

GetStackLevelMethod · 0.80

Tested by

no test coverage detected