2021-12-07 22:47:57 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex/helpers/socket.hpp>
|
|
|
|
#include <hex/providers/provider.hpp>
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
#include <string_view>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
namespace hex::plugin::builtin::prv {
|
|
|
|
|
|
|
|
class GDBProvider : public hex::prv::Provider {
|
|
|
|
public:
|
|
|
|
explicit GDBProvider();
|
|
|
|
~GDBProvider() override;
|
|
|
|
|
2021-12-12 00:41:44 +01:00
|
|
|
[[nodiscard]] bool isAvailable() const override;
|
|
|
|
[[nodiscard]] bool isReadable() const override;
|
|
|
|
[[nodiscard]] bool isWritable() const override;
|
|
|
|
[[nodiscard]] bool isResizable() const override;
|
|
|
|
[[nodiscard]] bool isSavable() const override;
|
2021-12-07 22:47:57 +01:00
|
|
|
|
|
|
|
void read(u64 offset, void *buffer, size_t size, bool overlays) override;
|
|
|
|
void write(u64 offset, const void *buffer, size_t size) override;
|
|
|
|
void resize(ssize_t newSize) override;
|
|
|
|
|
|
|
|
void readRaw(u64 offset, void *buffer, size_t size) override;
|
|
|
|
void writeRaw(u64 offset, const void *buffer, size_t size) override;
|
2021-12-12 00:41:44 +01:00
|
|
|
[[nodiscard]] size_t getActualSize() const override;
|
2021-12-07 22:47:57 +01:00
|
|
|
|
|
|
|
void save() override;
|
|
|
|
void saveAs(const std::string &path) override;
|
|
|
|
|
|
|
|
[[nodiscard]] std::string getName() const override;
|
|
|
|
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataInformation() const override;
|
|
|
|
|
2021-12-12 00:41:44 +01:00
|
|
|
[[nodiscard]] bool open() override;
|
|
|
|
void close() override;
|
2021-12-07 22:47:57 +01:00
|
|
|
|
2021-12-12 00:41:44 +01:00
|
|
|
[[nodiscard]] bool isConnected() const;
|
|
|
|
|
|
|
|
[[nodiscard]] bool hasLoadInterface() const override { return true; }
|
|
|
|
void drawLoadInterface() override;
|
|
|
|
|
|
|
|
protected:
|
2021-12-07 22:47:57 +01:00
|
|
|
hex::Socket m_socket;
|
|
|
|
|
|
|
|
std::string m_ipAddress;
|
2021-12-12 00:41:44 +01:00
|
|
|
int m_port;
|
|
|
|
|
|
|
|
constexpr static size_t CacheLineSize = 0x1000;
|
2021-12-07 22:47:57 +01:00
|
|
|
|
|
|
|
struct CacheLine {
|
|
|
|
u64 address;
|
|
|
|
|
2021-12-12 00:41:44 +01:00
|
|
|
std::array<u8, CacheLineSize> data;
|
2021-12-07 22:47:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
std::list<CacheLine> m_cache;
|
|
|
|
|
2021-12-07 23:36:28 +01:00
|
|
|
std::thread m_cacheUpdateThread;
|
2021-12-07 22:47:57 +01:00
|
|
|
std::mutex m_cacheLock;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|