diff --git a/src/kits/debugger/Jamfile b/src/kits/debugger/Jamfile index 36f0956bdc..eb7113ac43 100644 --- a/src/kits/debugger/Jamfile +++ b/src/kits/debugger/Jamfile @@ -59,6 +59,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) source_language c_family ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) source_language x86 ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) target_host_interface ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) target_host_interface local ] ; +SEARCH_SOURCE += [ FDirName $(SUBDIR) target_host_interface network ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) types ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) user_interface ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) user_interface util ] ; @@ -266,6 +267,10 @@ local sources = LocalTargetHostInterface.cpp LocalTargetHostInterfaceInfo.cpp + # target_host_interface/network + NetworkTargetHostInterface.cpp + NetworkTargetHostInterfaceInfo.cpp + # types ArrayIndexPath.cpp TargetAddressRangeList.cpp diff --git a/src/kits/debugger/target_host_interface/TargetHostInterfaceRoster.cpp b/src/kits/debugger/target_host_interface/TargetHostInterfaceRoster.cpp index 460e3b448d..f96076a9f5 100644 --- a/src/kits/debugger/target_host_interface/TargetHostInterfaceRoster.cpp +++ b/src/kits/debugger/target_host_interface/TargetHostInterfaceRoster.cpp @@ -10,6 +10,7 @@ #include #include "LocalTargetHostInterfaceInfo.h" +#include "NetworkTargetHostInterfaceInfo.h" #include "TargetHostInterfaceInfo.h" @@ -100,6 +101,7 @@ TargetHostInterfaceRoster::RegisterInterfaceInfos() interfaceReference.Detach(); REGISTER_INTERFACE_INFO(Local) + REGISTER_INTERFACE_INFO(Network) return B_OK; } diff --git a/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterface.cpp b/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterface.cpp new file mode 100644 index 0000000000..021b505eb3 --- /dev/null +++ b/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterface.cpp @@ -0,0 +1,99 @@ +/* + * Copyright 2016, Rene Gollent, rene@gollent.com. + * Copyright 2016, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "NetworkTargetHostInterface.h" + +#include +#include +#include +#include + +#include "debug_utils.h" + +#include "TargetHost.h" + + +NetworkTargetHostInterface::NetworkTargetHostInterface() + : + TargetHostInterface() +{ + SetName("Network"); +} + + +NetworkTargetHostInterface::~NetworkTargetHostInterface() +{ + Close(); + + if (fTargetHost != NULL) + fTargetHost->ReleaseReference(); +} + + +status_t +NetworkTargetHostInterface::Init(Settings* settings) +{ + return B_NOT_SUPPORTED; +} + + +void +NetworkTargetHostInterface::Close() +{ +} + + +bool +NetworkTargetHostInterface::IsLocal() const +{ + return false; +} + + +bool +NetworkTargetHostInterface::Connected() const +{ + return false; +} + + +TargetHost* +NetworkTargetHostInterface::GetTargetHost() +{ + return fTargetHost; +} + + +status_t +NetworkTargetHostInterface::Attach(team_id teamID, thread_id threadID, + DebuggerInterface*& _interface) const +{ + return B_NOT_SUPPORTED; +} + + +status_t +NetworkTargetHostInterface::CreateTeam(int commandLineArgc, + const char* const* arguments, team_id& _teamID) const +{ + return B_NOT_SUPPORTED; +} + + +status_t +NetworkTargetHostInterface::LoadCore(const char* coreFilePath, + DebuggerInterface*& _interface, thread_id& _thread) const +{ + return B_NOT_SUPPORTED; +} + + +status_t +NetworkTargetHostInterface::FindTeamByThread(thread_id thread, + team_id& _teamID) const +{ + return B_NOT_SUPPORTED; +} diff --git a/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterface.h b/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterface.h new file mode 100644 index 0000000000..eccfe761aa --- /dev/null +++ b/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterface.h @@ -0,0 +1,40 @@ +/* + * Copyright 2016, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#ifndef NETWORK_TARGET_HOST_INTERFACE_H +#define NETWORK_TARGET_HOST_INTERFACE_H + +#include "TargetHostInterface.h" + + +class NetworkTargetHostInterface : public TargetHostInterface { +public: + NetworkTargetHostInterface(); + virtual ~NetworkTargetHostInterface(); + + virtual status_t Init(Settings* settings); + virtual void Close(); + + virtual bool IsLocal() const; + virtual bool Connected() const; + + virtual TargetHost* GetTargetHost(); + + virtual status_t Attach(team_id id, thread_id threadID, + DebuggerInterface*& _interface) const; + virtual status_t CreateTeam(int commandLineArgc, + const char* const* arguments, + team_id& _teamID) const; + virtual status_t LoadCore(const char* coreFilePath, + DebuggerInterface*& _interface, + thread_id& _thread) const; + + virtual status_t FindTeamByThread(thread_id thread, + team_id& _teamID) const; + +private: + TargetHost* fTargetHost; +}; + +#endif // NETWORK_TARGET_HOST_INTERFACE_H diff --git a/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterfaceInfo.cpp b/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterfaceInfo.cpp new file mode 100644 index 0000000000..30d30c369b --- /dev/null +++ b/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterfaceInfo.cpp @@ -0,0 +1,100 @@ +/* + * Copyright 2016, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#include "NetworkTargetHostInterfaceInfo.h" + +#include + +#include "NetworkTargetHostInterface.h" +#include "SettingsDescription.h" +#include "Setting.h" + + +static const char* kHostnameSetting = "hostname"; +static const char* kPortSetting = "port"; + + +NetworkTargetHostInterfaceInfo::NetworkTargetHostInterfaceInfo() + : + TargetHostInterfaceInfo("Network"), + fDescription(NULL) +{ +} + + +NetworkTargetHostInterfaceInfo::~NetworkTargetHostInterfaceInfo() +{ + delete fDescription; +} + + +status_t +NetworkTargetHostInterfaceInfo::Init() +{ + fDescription = new(std::nothrow) SettingsDescription; + if (fDescription == NULL) + return B_NO_MEMORY; + + Setting* setting = new(std::nothrow) StringSettingImpl(kHostnameSetting, + "Hostname", ""); + if (setting == NULL) + return B_NO_MEMORY; + ObjectDeleter settingDeleter(setting); + if (!fDescription->AddSetting(setting)) + return B_NO_MEMORY; + + settingDeleter.Detach(); + setting = new(std::nothrow) BoundedSettingImpl(kPortSetting, "Port", + (uint16)0, (uint16)65535, (uint16)8305); + if (setting == NULL) + return B_NO_MEMORY; + if (!fDescription->AddSetting(setting)) { + delete setting; + return B_NO_MEMORY; + } + + return B_OK; +} + + +bool +NetworkTargetHostInterfaceInfo::IsLocal() const +{ + return false; +} + + +bool +NetworkTargetHostInterfaceInfo::IsConfigured(Settings* settings) const +{ + return true; +} + + +SettingsDescription* +NetworkTargetHostInterfaceInfo::GetSettingsDescription() const +{ + return fDescription; +} + + +status_t +NetworkTargetHostInterfaceInfo::CreateInterface(Settings* settings, + TargetHostInterface*& _interface) const +{ + NetworkTargetHostInterface* interface + = new(std::nothrow) NetworkTargetHostInterface; + if (interface == NULL) + return B_NO_MEMORY; + + status_t error = interface->Init(settings); + if (error != B_OK) { + delete interface; + return error; + } + + _interface = interface; + return B_OK; +} + diff --git a/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterfaceInfo.h b/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterfaceInfo.h new file mode 100644 index 0000000000..e3c7a5d153 --- /dev/null +++ b/src/kits/debugger/target_host_interface/network/NetworkTargetHostInterfaceInfo.h @@ -0,0 +1,30 @@ +/* + * Copyright 2016, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#ifndef NETWORK_TARGET_HOST_INTERFACE_INFO_H +#define NETWORK_TARGET_HOST_INTERFACE_INFO_H + +#include "TargetHostInterfaceInfo.h" + + +class NetworkTargetHostInterfaceInfo : public TargetHostInterfaceInfo { +public: + NetworkTargetHostInterfaceInfo(); + virtual ~NetworkTargetHostInterfaceInfo(); + + virtual status_t Init(); + + virtual bool IsLocal() const; + virtual bool IsConfigured(Settings* settings) const; + virtual SettingsDescription* GetSettingsDescription() const; + + virtual status_t CreateInterface(Settings* settings, + TargetHostInterface*& _interface) const; + +private: + BString fName; + SettingsDescription* fDescription; +}; + +#endif // NETWORK_TARGET_HOST_INTERFACE_INFO_H