载入中...
搜索中...
未找到
DevTool.hpp
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
10
11#include <string>
12#include <unordered_map>
13#include <vector>
14#include <chrono>
15
16struct SQVM;
17typedef struct SQVM* HSQUIRRELVM;
18
19namespace ssq {
20class VM;
21}
22
23namespace eve {
24class Runtime;
25}
26
27namespace eve::dev {
28
29class McpServer;
30class AiPanel;
31class ConsolePanel;
32class FrameStatsPanel;
33
51public:
52 static DevTool& instance();
53
54 DevTool(const DevTool&) = delete;
55 DevTool& operator=(const DevTool&) = delete;
56
58 void attach(ssq::VM& vm, bool sampleLocals = true);
59 void attach(HSQUIRRELVM vm, bool sampleLocals = true);
67 void attach(eve::Runtime& runtime, bool sampleLocals = true);
69 void enableRenderTrace(bool on = true);
70 void detach();
71
73 void exposeScriptApi(ssq::VM& vm);
74
76 int startDap(uint16_t port);
77 void stopDap();
79 int startMcp(uint16_t port);
80 void stopMcp();
81 void poll();
82
84 void drawAiPanel();
86 void drawConsolePanel();
88 void drawFrameStatsPanel();
89
90 bool isAttached() const { return vm_ != nullptr; }
92 bool isRuntimeBound() const { return runtime_ != nullptr; }
93 bool renderTraceEnabled() const { return renderTraceEnabled_; }
94 bool sampleLocals() const { return sampleLocals_; }
95 void setSampleLocals(bool on) { sampleLocals_ = on; }
96
97 CallGraph& graph() { return graph_; }
98 const CallGraph& graph() const { return graph_; }
99 RenderFlow& renderFlow() { return renderFlow_; }
100 const RenderFlow& renderFlow() const { return renderFlow_; }
101 Debugger& debugger() { return Debugger::instance(); }
102 Snapshot& snapshot() { return Snapshot::instance(); }
103 ScenarioRecorder& scenario() { return ScenarioRecorder::instance(); }
104 DebugAdapter& dap() { return DebugAdapter::instance(); }
105 McpServer& mcp();
106 AiPanel& ai();
107 ConsolePanel& console();
108 FrameStatsPanel& frameStats();
109
110 SliceResult analyzeError(const std::string& errorMessage,
111 const std::vector<std::string>& hintVars = {}) const;
112
113 std::string formatError(const std::string& errorMessage,
114 const std::vector<std::string>& hintVars = {}) const;
115
116 const std::string& lastReport() const { return lastReport_; }
117 const std::string& lastError() const { return lastError_; }
119 const SliceResult& lastSlice() const { return lastSlice_; }
120
123 int calls = 0;
124 int lines = 0;
125 long long ns = 0;
126 };
127 const std::unordered_map<std::string, ProfileEntry>& profile() const { return profile_; }
129 profile_.clear();
130 profStack_.clear();
131 }
132 std::string formatProfileReport() const;
133
135 std::string notifyError(const std::string& errorMessage,
136 const std::vector<std::string>& hintVars = {});
137
138 void handleDebugEvent(HSQUIRRELVM vm, int type, const char* source, int line,
139 const char* funcname);
140
141private:
142 DevTool() = default;
143
144 void sampleFrameLocals(HSQUIRRELVM vm, const SourceLoc& loc);
145 void markErrorUses(const SourceLoc& loc, const std::vector<std::string>& hintVars);
146 void installRenderTracer();
147 void uninstallRenderTracer();
149 void pumpWhilePaused();
150 void handleDebugHotkey(const std::string& key);
151 void profileLine(const std::string& func);
152 void profileCall(const std::string& func);
153 void profileReturn();
154
155 HSQUIRRELVM vm_ = nullptr;
156 bool sampleLocals_ = true;
157 bool renderTraceEnabled_ = false;
159 eve::Runtime* runtime_ = nullptr;
160 CallGraph graph_;
161 RenderFlow renderFlow_;
162 std::string lastReport_;
163 std::string lastError_;
164 SliceResult lastSlice_;
165 std::unordered_map<std::string, ProfileEntry> profile_;
166 std::vector<std::pair<std::string, std::chrono::steady_clock::time_point>> profStack_;
167
168 std::unordered_map<int, std::unordered_map<std::string, std::string>> localSnap_;
169};
170
171} // namespace eve::dev
struct SQVM * HSQUIRRELVM
struct SQVM * HSQUIRRELVM
Definition DevTool.hpp:17
HSQUIRRELVM vm
Definition ECS.cpp:20
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
std::uint32_t key
std::vector< std::string_view > lines
const UnitySourceAsset & source
EVENGINE_API_FOUNDATION public API.
Definition Runtime.h:189
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:86
Platform-level script + render debugger / dynamic slicer front-end.
Definition DevTool.hpp:50
const std::string & lastReport() const
Definition DevTool.hpp:116
bool renderTraceEnabled() const
Definition DevTool.hpp:93
Debugger & debugger()
Definition DevTool.hpp:101
RenderFlow & renderFlow()
Definition DevTool.hpp:99
const std::unordered_map< std::string, ProfileEntry > & profile() const
Definition DevTool.hpp:127
const std::string & lastError() const
Definition DevTool.hpp:117
Snapshot & snapshot()
Definition DevTool.hpp:102
CallGraph & graph()
Definition DevTool.hpp:97
bool sampleLocals() const
Definition DevTool.hpp:94
DevTool(const DevTool &)=delete
void setSampleLocals(bool on)
Definition DevTool.hpp:95
const CallGraph & graph() const
Definition DevTool.hpp:98
ScenarioRecorder & scenario()
Definition DevTool.hpp:103
bool isAttached() const
Definition DevTool.hpp:90
bool isRuntimeBound() const
True when errors also flow through Runtime::setErrorHandler.
Definition DevTool.hpp:92
DevTool & operator=(const DevTool &)=delete
const SliceResult & lastSlice() const
Script-side slice from the last notifyError (empty if none).
Definition DevTool.hpp:119
DebugAdapter & dap()
Definition DevTool.hpp:104
const RenderFlow & renderFlow() const
Definition DevTool.hpp:100
Lightweight FPS / frame-time overlay for DevTools (0.6 closeout).
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.
A state-driven bug scenario: baseline snapshot + ordered per-frame inputs.
Script + native state snapshot for state hot reload.
Definition Snapshot.hpp:29
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
Definition ECS.h:14
Per-function script profile (line-hook timing).
Definition DevTool.hpp:122