Deleting old debugger code.

This commit is contained in:
Ben Vanik 2013-12-22 00:23:00 -08:00
parent 80d8dc02aa
commit 284e8a92e6
7 changed files with 1 additions and 340 deletions

View File

@ -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 <xenia/dbg/client.h>
#include <xenia/dbg/debugger.h>
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);
}

View File

@ -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 <xenia/common.h>
#include <xenia/core.h>
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_

View File

@ -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 <xenia/dbg/content_source.h>
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_;
}

View File

@ -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 <xenia/common.h>
#include <xenia/core.h>
#include <xenia/dbg/client.h>
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_

View File

@ -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 <xenia/dbg/debugger.h>
#include <gflags/gflags.h>
#include <xenia/emulator.h>
#include <xenia/dbg/content_source.h>
#include <xenia/dbg/listener.h>
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<Listener>(new WsListener(this, FLAGS_remote_debug_port));
}
Debugger::~Debugger() {
std::vector<Client*> clients(clients_.begin(), clients_.end());
clients_.clear();
for (std::vector<Client*>::iterator it = clients.begin();
it != clients.end(); ++it) {
delete *it;
}
for (std::map<uint32_t, ContentSource*>::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<uint32_t, ContentSource*>(
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<Client*>::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<Client*>::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<uint32_t, ContentSource*>::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);
}

View File

@ -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 <xenia/common.h>
#include <xenia/core.h>
#include <map>
#include <vector>
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> listener_;
std::vector<Client*> clients_;
std::map<uint32_t, ContentSource*> content_sources_;
};
} // namespace dbg
} // namespace xe
#endif // XENIA_DBG_DEBUGGER_H_

View File

@ -17,7 +17,7 @@
#include <xenia/apu/apu.h>
#include <xenia/cpu/cpu.h>
#include <xenia/dbg/debugger.h>
#include <xenia/debug/debug_server.h>
#include <xenia/gpu/gpu.h>
#include <xenia/kernel/kernel.h>