载入中...
搜索中...
未找到
DevTool.hpp
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
9
10#include <string>
11#include <unordered_map>
12#include <vector>
13#include <chrono>
14
15struct SQVM;
16typedef struct SQVM* HSQUIRRELVM;
17
18namespace ssq {
19class VM;
20}
21
22namespace eve::dev {
23
24class McpServer;
25class AiPanel;
26class ConsolePanel;
27
44public:
45 static DevTool& instance();
46
47 DevTool(const DevTool&) = delete;
48 DevTool& operator=(const DevTool&) = delete;
49
51 void attach(ssq::VM& vm, bool sampleLocals = true);
52 void attach(HSQUIRRELVM vm, bool sampleLocals = true);
54 void enableRenderTrace(bool on = true);
55 void detach();
56
58 void exposeScriptApi(ssq::VM& vm);
59
61 int startDap(uint16_t port);
62 void stopDap();
64 int startMcp(uint16_t port);
65 void stopMcp();
66 void poll();
67
69 void drawAiPanel();
71 void drawConsolePanel();
72
73 bool isAttached() const { return vm_ != nullptr; }
74 bool renderTraceEnabled() const { return renderTraceEnabled_; }
75 bool sampleLocals() const { return sampleLocals_; }
76 void setSampleLocals(bool on) { sampleLocals_ = on; }
77
78 CallGraph& graph() { return graph_; }
79 const CallGraph& graph() const { return graph_; }
80 RenderFlow& renderFlow() { return renderFlow_; }
81 const RenderFlow& renderFlow() const { return renderFlow_; }
82 Debugger& debugger() { return Debugger::instance(); }
83 Snapshot& snapshot() { return Snapshot::instance(); }
84 DebugAdapter& dap() { return DebugAdapter::instance(); }
85 McpServer& mcp();
86 AiPanel& ai();
87 ConsolePanel& console();
88
89 SliceResult analyzeError(const std::string& errorMessage,
90 const std::vector<std::string>& hintVars = {}) const;
91
92 std::string formatError(const std::string& errorMessage,
93 const std::vector<std::string>& hintVars = {}) const;
94
95 const std::string& lastReport() const { return lastReport_; }
96 const std::string& lastError() const { return lastError_; }
97
99 struct ProfileEntry {
100 int calls = 0;
101 int lines = 0;
102 long long ns = 0;
103 };
104 const std::unordered_map<std::string, ProfileEntry>& profile() const { return profile_; }
106 profile_.clear();
107 profStack_.clear();
108 }
109 std::string formatProfileReport() const;
110
112 std::string notifyError(const std::string& errorMessage,
113 const std::vector<std::string>& hintVars = {});
114
115 void handleDebugEvent(HSQUIRRELVM vm, int type, const char* source, int line,
116 const char* funcname);
117
118private:
119 DevTool() = default;
120
121 void sampleFrameLocals(HSQUIRRELVM vm, const SourceLoc& loc);
122 void markErrorUses(const SourceLoc& loc, const std::vector<std::string>& hintVars);
123 void installRenderTracer();
124 void uninstallRenderTracer();
126 void pumpWhilePaused();
127 void handleDebugHotkey(const std::string& key);
128 void profileLine(const std::string& func);
129 void profileCall(const std::string& func);
130 void profileReturn();
131
132 HSQUIRRELVM vm_ = nullptr;
133 bool sampleLocals_ = true;
134 bool renderTraceEnabled_ = false;
135 CallGraph graph_;
136 RenderFlow renderFlow_;
137 std::string lastReport_;
138 std::string lastError_;
139 std::unordered_map<std::string, ProfileEntry> profile_;
140 std::vector<std::pair<std::string, std::chrono::steady_clock::time_point>> profStack_;
141
142 std::unordered_map<int, std::unordered_map<std::string, std::string>> localSnap_;
143};
144
145} // namespace eve::dev
struct SQVM * HSQUIRRELVM
struct SQVM * HSQUIRRELVM
Definition DevTool.hpp:16
int line
HSQUIRRELVM vm
Definition ECS.cpp:20
std::string type
#define EVENGINE_API
宿主(eve / libmain)导出宏;插件从进程导入同一批符号。
Definition Export.h:16
In-engine AI / MCP session surface for DevTools.
Definition AiPanel.hpp:27
Runtime call graph + dynamic data-flow tracer with backward slicing.
Definition CallGraph.hpp:81
In-engine runtime console / log ring buffer for DevTools.
Minimal Debug Adapter Protocol (DAP) server for VS Code.
Script + frame debugger: pause/step, breakpoints, watches.
Definition Debugger.hpp:83
Platform-level script + render debugger / dynamic slicer front-end.
Definition DevTool.hpp:43
const std::string & lastReport() const
Definition DevTool.hpp:95
bool renderTraceEnabled() const
Definition DevTool.hpp:74
Debugger & debugger()
Definition DevTool.hpp:82
RenderFlow & renderFlow()
Definition DevTool.hpp:80
const std::unordered_map< std::string, ProfileEntry > & profile() const
Definition DevTool.hpp:104
const std::string & lastError() const
Definition DevTool.hpp:96
Snapshot & snapshot()
Definition DevTool.hpp:83
CallGraph & graph()
Definition DevTool.hpp:78
bool sampleLocals() const
Definition DevTool.hpp:75
DevTool(const DevTool &)=delete
void setSampleLocals(bool on)
Definition DevTool.hpp:76
const CallGraph & graph() const
Definition DevTool.hpp:79
bool isAttached() const
Definition DevTool.hpp:73
DevTool & operator=(const DevTool &)=delete
DebugAdapter & dap()
Definition DevTool.hpp:84
const RenderFlow & renderFlow() const
Definition DevTool.hpp:81
Embedded Model Context Protocol (MCP) server for AI-assisted game development.
Definition McpServer.hpp:35
Render-pipeline flow tracer with a Weiser-style backward slice.
Script + native state snapshot for state hot reload.
Definition Snapshot.hpp:28
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
Definition ECS.h:12
Per-function script profile (line-hook timing).
Definition DevTool.hpp:99