42 static LuaDebugger*
Get();
44 void Install(lua_State* L);
52 bool IsInstalled()
const {
return mInstalled; }
57 static bool LoadActivePreference();
58 static void SaveActivePreference(
bool active);
63 void LoadBreakpoints();
64 void SaveBreakpoints();
68 void ToggleBreakpoint(
const std::string& sourceFile,
int line);
69 void SetBreakpoint(
const std::string& sourceFile,
int line);
70 void ClearBreakpoint(
const std::string& sourceFile,
int line);
71 void ClearAllBreakpoints();
72 bool HasBreakpoint(
const std::string& sourceFile,
int line)
const;
73 std::set<int> GetBreakpointsForFile(
const std::string& sourceFile)
const;
76 struct BreakpointEntry { std::string mFile;
int mLine; };
77 std::vector<BreakpointEntry> GetAllBreakpoints()
const;
81 bool IsPaused()
const {
return mPaused.load(); }
82 const std::string& GetPauseMessage()
const {
return mPauseMessage; }
83 const std::string& GetPauseFile()
const {
return mPauseFile; }
84 int GetPauseLine()
const {
return mPauseLine; }
86 void RequestContinue();
91 void ResetTransientState();
96 static int LuaBreakBinding(lua_State* L);
101 static int LuaSnapshotBinding(lua_State* L);
108 std::string mFuncName;
110 int mCurrentLine = -1;
116 std::string mTypeStr;
117 std::string mValueStr;
119 void CaptureSnapshot(lua_State* L,
int startLevel = 0);
121 const std::vector<StackFrame>& GetCallStack()
const {
return mCallStack; }
125 enum class VarKind {
Local, Upvalue };
126 std::vector<LocalVar> GetSnapshotVars(
int frameIndex, VarKind kind)
const;
130 static void OnHookTrampoline(lua_State* L, lua_Debug* ar);
136 static const char* GetPauseSentinel();
139 static std::string NormalizeSource(
const char* luaSource);
143 static bool IsLuaPandaActive(lua_State* L);
146 LuaDebugger() =
default;
148 void OnHook(lua_State* L, lua_Debug* ar);
153 void EnterPaused(lua_State* L, lua_Debug* ar,
const char* optionalMessage,
int snapshotStartLevel = 0);
159 void EnterPausedSoft(lua_State* L, lua_Debug* ar,
const char* optionalMessage,
int snapshotStartLevel = 0);
162 static std::string FormatLuaValue(lua_State* L,
int idx);
164 static LuaDebugger* sInstance;
166 bool mInstalled =
false;
167 bool mFirstHookLogged =
false;
168 lua_State* mL =
nullptr;
176 bool mSavedCursorShown =
true;
177 bool mSavedCursorLocked =
false;
178 bool mSavedCursorTrapped =
false;
179 bool mSavedGamePreviewCapture =
false;
180 bool mSavedCursorValid =
false;
182 void FreeCursorForInspection();
183 void RestoreCursor();
185 mutable std::mutex mBreakpointMutex;
186 std::map<std::string, std::set<int>> mBreakpoints;
188 std::atomic<bool> mPaused{
false};
189 std::string mPauseMessage;
190 std::string mPauseFile;
194 std::vector<StackFrame> mCallStack;
196 std::vector<std::vector<LocalVar>> mFrameLocals;
197 std::vector<std::vector<LocalVar>> mFrameUpvalues;
201 bool mSkipOnceArmed =
false;
202 std::string mSkipOnceFile;
203 int mSkipOnceLine = -1;
209 bool mSkipBreakOnceArmed =
false;
210 std::string mSkipBreakFile;
211 int mSkipBreakLine = -1;
bool IsPaused()
Definition Engine.cpp:1473