Mostly complete tracing. Probably a lot of bugs.

This commit is contained in:
Ben Vanik
2014-08-14 20:28:44 -07:00
parent cebf595958
commit c275562594
54 changed files with 1052 additions and 161 deletions

View File

@@ -24,6 +24,8 @@ XKernelModule::XKernelModule(KernelState* kernel_state, const char* path) :
emulator_ = kernel_state->emulator();
memory_ = emulator_->memory();
export_resolver_ = kernel_state->emulator()->export_resolver();
OnLoad();
}
XKernelModule::~XKernelModule() {

View File

@@ -9,6 +9,8 @@
#include <xenia/kernel/objects/xmodule.h>
#include <xdb/protocol.h>
using namespace xe;
using namespace xe::cpu;
@@ -32,6 +34,23 @@ XModule::XModule(KernelState* kernel_state, const char* path) :
}
XModule::~XModule() {
auto ev = xdb::protocol::ModuleUnloadEvent::Append(memory()->trace_base());
if (ev) {
ev->type = xdb::protocol::EventType::MODULE_UNLOAD;
ev->module_id = handle();
}
kernel_state_->UnregisterModule(this);
}
void XModule::OnLoad() {
auto ev = xdb::protocol::ModuleLoadEvent::Append(memory()->trace_base());
if (ev) {
ev->type = xdb::protocol::EventType::MODULE_LOAD;
ev->module_id = handle();
}
kernel_state_->RegisterModule(this);
}
X_STATUS XModule::GetSection(

View File

@@ -33,6 +33,8 @@ public:
uint32_t* out_section_data, uint32_t* out_section_size);
protected:
void OnLoad();
char name_[256];
char path_[poly::max_path];
};

View File

@@ -11,6 +11,7 @@
#include <poly/math.h>
#include <xdb/protocol.h>
#include <xenia/cpu/cpu.h>
#include <xenia/kernel/native_list.h>
#include <xenia/kernel/xboxkrnl_threading.h>
@@ -70,6 +71,12 @@ XThread::XThread(KernelState* kernel_state,
}
XThread::~XThread() {
auto ev = xdb::protocol::ThreadExitEvent::Append(memory()->trace_base());
if (ev) {
ev->type = xdb::protocol::EventType::THREAD_EXIT;
ev->thread_id = handle();
}
// Unregister first to prevent lookups while deleting.
kernel_state_->UnregisterThread(this);
@@ -254,6 +261,13 @@ X_STATUS XThread::Create() {
SetAffinity(proc_mask);
}
auto ev = xdb::protocol::ThreadCreateEvent::Append(memory()->trace_base());
if (ev) {
ev->type = xdb::protocol::EventType::THREAD_CREATE;
ev->thread_id = handle();
thread_state_->WriteRegisters(&ev->registers);
}
module->Release();
return X_STATUS_SUCCESS;
}

View File

@@ -122,6 +122,8 @@ X_STATUS XUserModule::LoadFromMemory(const void* addr, const size_t length) {
return X_STATUS_UNSUCCESSFUL;
}
OnLoad();
return X_STATUS_SUCCESS;
}