MCPcopy Create free account
hub / github.com/SpartanJ/eepp / asyncRead

Method asyncRead

src/tools/ecode/plugins/debugger/dap/debuggerclientdap.cpp:245–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245void DebuggerClientDap::asyncRead( const char* bytes, size_t n, const SessionId& sessionId ) {
246 std::string_view read( bytes, n );
247 auto& buffer = mSessions[sessionId].buffer;
248 buffer += read;
249
250 while ( true ) {
251 const auto info = readHeader( buffer );
252 if ( !info )
253 break;
254 if ( info->payloadStart >= buffer.size() ) {
255 Log::debug( "DebuggerClientDap::asyncRead: Out of range payloadStart access. Current "
256 "buffer was:\n%s\nPayload started at %" PRIu64 "",
257 buffer.data(), info->payloadStart );
258 break;
259 }
260 const auto data = buffer.substr( info->payloadStart, info->payloadLength );
261 if ( data.size() < info->payloadLength )
262 break;
263 buffer.erase( 0, info->payloadStart + info->payloadLength );
264
265#ifndef EE_DEBUG
266 try {
267#endif
268 auto message = nlohmann::json::parse( data );
269 if ( mDebug ) {
270 Log::debug( "DebuggerClientDap::asyncRead:" );
271 Log::debug( message.dump() );
272 }
273 processProtocolMessage( message );
274#ifndef EE_DEBUG
275 } catch ( const nlohmann::json::exception& e ) {
276 Log::error( "DebuggerClientDap::asyncRead: JSON bad format: %s", e.what() );
277 }
278#endif
279 }
280}
281
282void DebuggerClientDap::processProtocolMessage( const nlohmann::json& msg ) {
283 const auto type = msg.value( DAP_TYPE, "" );

Callers

nothing calls this directly

Calls 6

debugFunction · 0.85
errorFunction · 0.85
substrMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected