This commit is contained in:
Martín Lucas Golini
2024-12-15 20:56:41 -03:00
parent 6e458c8297
commit d2dabdf92c
7 changed files with 132 additions and 11 deletions

View File

@@ -8,6 +8,8 @@ class Bus {
public:
typedef std::function<void( const char* bytes, size_t n )> ReadFn;
virtual bool start() = 0;
virtual void startAsyncRead( ReadFn readFn ) = 0;
virtual size_t write( const char* buffer, const size_t& size ) = 0;

View File

@@ -2,11 +2,14 @@
namespace ecode {
BusProcess::BusProcess( const Command& command ) :
mProcess( command.command, command.arguments,
Process::getDefaultOptions() | Process::Options::EnableAsync |
Process::Options::CombinedStdoutStderr,
command.environment ) {}
BusProcess::BusProcess( const Command& command ) : mCommand( command ), mProcess() {}
bool BusProcess::start() {
return mProcess.create( mCommand.command, mCommand.arguments,
Process::getDefaultOptions() | Process::Options::EnableAsync |
Process::Options::CombinedStdoutStderr,
mCommand.environment );
}
void BusProcess::startAsyncRead( ReadFn readFn ) {
mProcess.startAsyncRead( readFn, readFn );

View File

@@ -9,11 +9,14 @@ class BusProcess : public Bus {
public:
BusProcess( const Command& command );
virtual void startAsyncRead( ReadFn readFn );
bool start() override;
virtual size_t write( const char* buffer, const size_t& size );
void startAsyncRead( ReadFn readFn ) override;
size_t write( const char* buffer, const size_t& size ) override;
protected:
Command mCommand;
Process mProcess;
};

View File

@@ -3,8 +3,11 @@
namespace ecode {
BusSocket::BusSocket( const Connection& connection ) {
mSocket.connect( IpAddress( connection.host ), connection.port );
BusSocket::BusSocket( const Connection& connection ) : mConnection( connection ) {}
bool BusSocket::start() {
return mSocket.connect( IpAddress( mConnection.host ), mConnection.port ) ==
Socket::Status::Done;
}
void BusSocket::startAsyncRead( ReadFn readFn ) {

View File

@@ -9,11 +9,14 @@ class BusSocket : public Bus {
public:
BusSocket( const Connection& connection );
void startAsyncRead( ReadFn readFn );
bool start() override;
size_t write( const char* buffer, const size_t& size );
void startAsyncRead( ReadFn readFn ) override;
size_t write( const char* buffer, const size_t& size ) override;
protected:
Connection mConnection;
TcpSocket mSocket;
};

View File

@@ -0,0 +1,63 @@
#include "debuggerclientdap.hpp"
namespace ecode {
DebuggerClientDap::DebuggerClientDap( std::unique_ptr<Bus>&& bus ) : mBus( std::move( bus ) ) {}
bool DebuggerClientDap::hasBreakpoint( const std::string& path, size_t line ) {
return false;
}
bool DebuggerClientDap::addBreakpoint( const std::string& path, size_t line ) {
return false;
}
bool DebuggerClientDap::removeBreakpoint( const std::string& path, size_t line ) {
return false;
}
bool DebuggerClientDap::start() {
return mBus->start();
}
bool DebuggerClientDap::attach() {
return false;
}
bool DebuggerClientDap::started() const {
return false;
}
bool DebuggerClientDap::cont() {
return false;
}
bool DebuggerClientDap::stepInto() {
return false;
}
bool DebuggerClientDap::stepOver() {
return false;
}
bool DebuggerClientDap::stepOut() {
return false;
}
bool DebuggerClientDap::halt() {
return false;
}
bool DebuggerClientDap::terminate() {
return false;
}
bool DebuggerClientDap::stopped() {
return false;
}
bool DebuggerClientDap::completed() {
return false;
}
} // namespace ecode

View File

@@ -0,0 +1,44 @@
#pragma once
#include "../bus.hpp"
#include "../debuggerclient.hpp"
namespace ecode {
class DebuggerClientDap : public DebuggerClient {
public:
DebuggerClientDap( std::unique_ptr<Bus>&& bus );
bool hasBreakpoint( const std::string& path, size_t line );
bool addBreakpoint( const std::string& path, size_t line );
bool removeBreakpoint( const std::string& path, size_t line );
bool start();
bool attach();
bool started() const;
bool cont();
bool stepInto();
bool stepOver();
bool stepOut();
bool halt();
bool terminate();
bool stopped();
bool completed();
protected:
std::unique_ptr<Bus> mBus;
};
} // namespace ecode