46 int listen(uint16_t port);
49 int port()
const {
return port_.load(); }
50 bool hasClient()
const {
return hasClient_.load(); }
53 void setSourceRoot(std::string
root);
54 const std::string&
sourceRoot()
const {
return sourceRoot_; }
56 void registerSource(std::string
name, std::string content);
69 bool waitUntilConfigured(
int timeoutMs = 15000);
74 void notifyContinued();
75 void notifyTerminated();
84 void acceptNonBlocking();
85 void readAndDispatch();
86 bool sendMessage(
const std::string& json);
87 void handleRequest(
const std::string& json);
88 std::string makeResponse(
int seq,
int requestSeq,
const std::string& command,
bool ok,
89 const std::string& bodyJson,
const std::string&
message = {});
90 std::string makeEvent(
const std::string& event,
const std::string& bodyJson);
91 static std::string reasonString(PauseReason
r);
93 std::string resolveSourcePath(std::string
source)
const;
95 void rememberSourcePath(
const std::string&
path);
97 void discoverEngineScriptAliases();
99 void handleBreakpointEvent(
int id,
const std::string&
source,
int line,
bool verified);
101 int varRefForFrame(
int frameId);
103 int allocVarRef(
int kind,
int frame, std::vector<std::string>
path);
105 Poco::SharedPtr<Poco::JSON::Object> makeSourceObject(
const std::string&
source)
const;
110 std::vector<std::string>
path;
113 std::atomic<bool> listening_{
false};
114 std::atomic<bool> hasClient_{
false};
115 std::atomic<int> port_{0};
116 std::atomic<int> seq_{1};
117 std::recursive_mutex ioMu_;
118 std::unique_ptr<Poco::Net::ServerSocket> server_;
119 std::unique_ptr<Poco::Net::StreamSocket> client_;
120 std::string recvBuf_;
121 std::string sourceRoot_;
123 std::unordered_map<std::string, std::string> sourceAliases_;
124 bool configured_ =
false;
125 bool stopOnEntry_ =
false;
126 int varRefLocals_ = 1;
127 int varRefWatches_ = 2;
128 int varRefGlobals_ = 5000;
129 int varRefFrameBase_ = 1000;
130 int nextVarRef_ = 10000;
131 std::vector<VariableInfo> varCache_;
132 std::unordered_map<int, VarScope> varScopes_;
133 std::string lastException_;
134 std::unordered_map<std::string, std::string> sourceContents_;
135 std::unordered_map<int, std::string> sourceRefContents_;