From 284e8a92e6e264902a14d85c26a2abb1e6c045f6 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 22 Dec 2013 00:23:00 -0800 Subject: [PATCH] Deleting old debugger code. --- src/xenia/dbg/client.cc | 36 --------- src/xenia/dbg/client.h | 44 ----------- src/xenia/dbg/content_source.cc | 26 ------- src/xenia/dbg/content_source.h | 43 ----------- src/xenia/dbg/debugger.cc | 128 -------------------------------- src/xenia/dbg/debugger.h | 62 ---------------- src/xenia/xenia.h | 2 +- 7 files changed, 1 insertion(+), 340 deletions(-) delete mode 100644 src/xenia/dbg/client.cc delete mode 100644 src/xenia/dbg/client.h delete mode 100644 src/xenia/dbg/content_source.cc delete mode 100644 src/xenia/dbg/content_source.h delete mode 100644 src/xenia/dbg/debugger.cc delete mode 100644 src/xenia/dbg/debugger.h diff --git a/src/xenia/dbg/client.cc b/src/xenia/dbg/client.cc deleted file mode 100644 index 32c109ebb..000000000 --- a/src/xenia/dbg/client.cc +++ /dev/null @@ -1,36 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#include - -#include - - -using namespace xe; -using namespace xe::dbg; - - -Client::Client(Debugger* debugger) : - debugger_(debugger) { - debugger_->AddClient(this); -} - -Client::~Client() { - debugger_->RemoveClient(this); -} - -void Client::OnMessage(const uint8_t* data, size_t length) { - debugger_->Dispatch(this, data, length); -} - -void Client::Write(uint8_t* buffer, size_t length) { - uint8_t* buffers[] = {buffer}; - size_t lengths[] = {length}; - Write(buffers, lengths, 1); -} diff --git a/src/xenia/dbg/client.h b/src/xenia/dbg/client.h deleted file mode 100644 index 0946334c7..000000000 --- a/src/xenia/dbg/client.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#ifndef XENIA_DBG_CLIENT_H_ -#define XENIA_DBG_CLIENT_H_ - -#include -#include - - -namespace xe { -namespace dbg { - - -class Debugger; - - -class Client { -public: - Client(Debugger* debugger); - virtual ~Client(); - - virtual int Setup() = 0; - - void OnMessage(const uint8_t* data, size_t length); - void Write(uint8_t* buffer, size_t length); - virtual void Write(uint8_t** buffers, size_t* lengths, size_t count) = 0; - -protected: - Debugger* debugger_; -}; - - -} // namespace dbg -} // namespace xe - - -#endif // XENIA_DBG_CLIENT_H_ diff --git a/src/xenia/dbg/content_source.cc b/src/xenia/dbg/content_source.cc deleted file mode 100644 index 01eb86dcd..000000000 --- a/src/xenia/dbg/content_source.cc +++ /dev/null @@ -1,26 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#include - - -using namespace xe; -using namespace xe::dbg; - - -ContentSource::ContentSource(Debugger* debugger, uint32_t source_id) : - debugger_(debugger), source_id_(source_id) { -} - -ContentSource::~ContentSource() { -} - -uint32_t ContentSource::source_id() { - return source_id_; -} diff --git a/src/xenia/dbg/content_source.h b/src/xenia/dbg/content_source.h deleted file mode 100644 index a063355b0..000000000 --- a/src/xenia/dbg/content_source.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#ifndef XENIA_DBG_CONTENT_SOURCE_H_ -#define XENIA_DBG_CONTENT_SOURCE_H_ - -#include -#include - -#include - - -namespace xe { -namespace dbg { - - -class ContentSource { -public: - ContentSource(Debugger* debugger, uint32_t source_id); - virtual ~ContentSource(); - - uint32_t source_id(); - - virtual int Dispatch(Client* client, uint8_t type, uint32_t request_id, - const uint8_t* data, size_t length) = 0; - -protected: - Debugger* debugger_; - uint32_t source_id_; -}; - - -} // namespace dbg -} // namespace xe - - -#endif // XENIA_DBG_CONTENT_SOURCE_H_ diff --git a/src/xenia/dbg/debugger.cc b/src/xenia/dbg/debugger.cc deleted file mode 100644 index 164c25f74..000000000 --- a/src/xenia/dbg/debugger.cc +++ /dev/null @@ -1,128 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#include - -#include - -#include -#include -#include - - -using namespace xe; -using namespace xe::dbg; - - -DEFINE_bool(wait_for_debugger, false, - "Whether to wait for the debugger to attach before launching."); -DEFINE_int32(remote_debug_port, 6200, - "Websocket port to listen for debugger connections on."); - - -Debugger::Debugger(Emulator* emulator) : - emulator_(emulator) { - //listener_ = auto_ptr(new WsListener(this, FLAGS_remote_debug_port)); -} - -Debugger::~Debugger() { - std::vector clients(clients_.begin(), clients_.end()); - clients_.clear(); - for (std::vector::iterator it = clients.begin(); - it != clients.end(); ++it) { - delete *it; - } - - for (std::map::iterator it = - content_sources_.begin(); it != content_sources_.end(); ++it) { - delete it->second; - } - content_sources_.clear(); -} - -void Debugger::RegisterContentSource(ContentSource* content_source) { - content_sources_.insert(std::pair( - content_source->source_id(), content_source)); -} - -int Debugger::Startup() { - // HACK(benvanik): say we are ok even if we have no listener. - if (!listener_.get()) { - return 0; - } - - // Start listener. - // This may launch a thread and such. - if (listener_->Setup()) { - return 1; - } - - // If desired, wait until the first client connects. - if (FLAGS_wait_for_debugger) { - XELOGI("Waiting for debugger on port %d...", FLAGS_remote_debug_port); - if (listener_->WaitForClient()) { - return 1; - } - XELOGI("Debugger attached, continuing..."); - } - - return 0; -} - -void Debugger::Broadcast(uint32_t source_id, - const uint8_t* data, size_t length) { - uint32_t header[] = { - 0x00000001, - source_id, - 0, - (uint32_t)length, - }; - uint8_t* buffers[] = { - (uint8_t*)header, - (uint8_t*)data, - }; - size_t lengths[] = { - sizeof(header), - length, - }; - for (std::vector::iterator it = clients_.begin(); - it != clients_.end(); ++it) { - Client* client = *it; - client->Write(buffers, lengths, XECOUNT(buffers)); - } -} - -void Debugger::AddClient(Client* client) { - clients_.push_back(client); -} - -void Debugger::RemoveClient(Client* client) { - for (std::vector::iterator it = clients_.begin(); - it != clients_.end(); ++it) { - if (*it == client) { - clients_.erase(it); - return; - } - } -} - -int Debugger::Dispatch(Client* client, const uint8_t* data, size_t length) { - uint32_t type = XEGETUINT32LE(data + 0); - uint32_t source_id = XEGETUINT32LE(data + 4); - uint32_t request_id = XEGETUINT32LE(data + 8); - uint32_t size = XEGETUINT32LE(data + 12); - - std::map::iterator it = - content_sources_.find(source_id); - if (it == content_sources_.end()) { - XELOGW("Content source %d not found, ignoring message", source_id); - return 1; - } - return it->second->Dispatch(client, type, request_id, data + 16, size); -} diff --git a/src/xenia/dbg/debugger.h b/src/xenia/dbg/debugger.h deleted file mode 100644 index aad92c9dc..000000000 --- a/src/xenia/dbg/debugger.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#ifndef XENIA_DBG_DEBUGGER_H_ -#define XENIA_DBG_DEBUGGER_H_ - -#include -#include - -#include -#include - - -XEDECLARECLASS1(xe, Emulator); - - -namespace xe { -namespace dbg { - - -class Client; -class ContentSource; -class Listener; - - -class Debugger { -public: - Debugger(Emulator* emulator); - virtual ~Debugger(); - - void RegisterContentSource(ContentSource* content_source); - - int Startup(); - - void Broadcast(uint32_t source_id, const uint8_t* data, size_t length); - -private: - void AddClient(Client* client); - void RemoveClient(Client* client); - int Dispatch(Client* client, const uint8_t* data, size_t length); - - friend class Client; - -private: - Emulator* emulator_; - auto_ptr listener_; - std::vector clients_; - std::map content_sources_; -}; - - -} // namespace dbg -} // namespace xe - - -#endif // XENIA_DBG_DEBUGGER_H_ diff --git a/src/xenia/xenia.h b/src/xenia/xenia.h index 853d6e335..9b18233d9 100644 --- a/src/xenia/xenia.h +++ b/src/xenia/xenia.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include