45 int listen(uint16_t port);
48 int port()
const {
return port_.load(); }
49 bool hasClient()
const {
return hasClient_.load(); }
52 void setSourceRoot(std::string root);
53 const std::string&
sourceRoot()
const {
return sourceRoot_; }
55 void registerSource(std::string
name, std::string content);
68 bool waitUntilConfigured(
int timeoutMs = 15000);
72 const std::string& description = {});
73 void notifyContinued();
74 void notifyTerminated();
83 void acceptNonBlocking();
84 void readAndDispatch();
85 bool sendMessage(
const std::string& json);
86 void handleRequest(
const std::string& json);
87 std::string makeResponse(
int seq,
int requestSeq,
const std::string& command,
bool ok,
88 const std::string& bodyJson,
const std::string& message = {});
89 std::string makeEvent(
const std::string& event,
const std::string& bodyJson);
90 static std::string reasonString(PauseReason r);
92 std::string resolveSourcePath(std::string source)
const;
94 void rememberSourcePath(
const std::string& path);
96 void discoverEngineScriptAliases();
98 void handleBreakpointEvent(
int id,
const std::string& source,
int line,
bool verified);
100 int varRefForFrame(
int frameId);
102 int allocVarRef(
int kind,
int frame, std::vector<std::string> path);
104 Poco::SharedPtr<Poco::JSON::Object> makeSourceObject(
const std::string& source)
const;
109 std::vector<std::string> path;
112 std::atomic<bool> listening_{
false};
113 std::atomic<bool> hasClient_{
false};
114 std::atomic<int> port_{0};
115 std::atomic<int> seq_{1};
116 std::recursive_mutex ioMu_;
117 std::unique_ptr<Poco::Net::ServerSocket> server_;
118 std::unique_ptr<Poco::Net::StreamSocket> client_;
119 std::string recvBuf_;
120 std::string sourceRoot_;
122 std::unordered_map<std::string, std::string> sourceAliases_;
123 bool configured_ =
false;
124 bool stopOnEntry_ =
false;
125 int varRefLocals_ = 1;
126 int varRefWatches_ = 2;
127 int varRefGlobals_ = 5000;
128 int varRefFrameBase_ = 1000;
129 int nextVarRef_ = 10000;
130 std::vector<VariableInfo> varCache_;
131 std::unordered_map<int, VarScope> varScopes_;
132 std::string lastException_;
133 std::unordered_map<std::string, std::string> sourceContents_;
134 std::unordered_map<int, std::string> sourceRefContents_;