cpu::Processor now tracks a pointer to the emulator.

This commit is contained in:
Dr. Chat 2015-11-27 22:33:48 -06:00 committed by Ben Vanik
parent 7d59258839
commit 28468f8a18
5 changed files with 12 additions and 7 deletions

View File

@ -189,7 +189,7 @@ class TestRunner {
memory->Reset(); memory->Reset();
// Setup a fresh processor. // Setup a fresh processor.
processor.reset(new Processor(memory.get(), nullptr, nullptr)); processor.reset(new Processor(nullptr, memory.get(), nullptr, nullptr));
processor->Setup(); processor->Setup();
processor->set_debug_info_flags(DebugInfoFlags::kDebugInfoAll); processor->set_debug_info_flags(DebugInfoFlags::kDebugInfoAll);

View File

@ -55,9 +55,12 @@ class BuiltinModule : public Module {
std::string name_; std::string name_;
}; };
Processor::Processor(xe::Memory* memory, ExportResolver* export_resolver, Processor::Processor(xe::Emulator* emulator, xe::Memory* memory,
debug::Debugger* debugger) ExportResolver* export_resolver, debug::Debugger* debugger)
: memory_(memory), debugger_(debugger), export_resolver_(export_resolver) {} : emulator_(emulator),
memory_(memory),
debugger_(debugger),
export_resolver_(export_resolver) {}
Processor::~Processor() { Processor::~Processor() {
{ {

View File

@ -49,10 +49,11 @@ enum class Irql : uint32_t {
class Processor { class Processor {
public: public:
Processor(Memory* memory, ExportResolver* export_resolver, Processor(Emulator* emulator, Memory* memory, ExportResolver* export_resolver,
debug::Debugger* debugger); debug::Debugger* debugger);
~Processor(); ~Processor();
Emulator* emulator() const { return emulator_; }
Memory* memory() const { return memory_; } Memory* memory() const { return memory_; }
debug::Debugger* debugger() const { return debugger_; } debug::Debugger* debugger() const { return debugger_; }
StackWalker* stack_walker() const { return stack_walker_.get(); } StackWalker* stack_walker() const { return stack_walker_.get(); }
@ -105,6 +106,7 @@ class Processor {
bool DemandFunction(Function* function); bool DemandFunction(Function* function);
Emulator* emulator_ = nullptr;
Memory* memory_ = nullptr; Memory* memory_ = nullptr;
debug::Debugger* debugger_ = nullptr; debug::Debugger* debugger_ = nullptr;
std::unique_ptr<StackWalker> stack_walker_; std::unique_ptr<StackWalker> stack_walker_;

View File

@ -40,7 +40,7 @@ class TestFunction {
#if XENIA_TEST_X64 #if XENIA_TEST_X64
{ {
auto processor = auto processor =
std::make_unique<Processor>(memory.get(), nullptr, nullptr); std::make_unique<Processor>(nullptr, memory.get(), nullptr, nullptr);
processor->Setup(); processor->Setup();
processors.emplace_back(std::move(processor)); processors.emplace_back(std::move(processor));
} }

View File

@ -116,7 +116,7 @@ X_STATUS Emulator::Setup(
// Initialize the CPU. // Initialize the CPU.
processor_ = std::make_unique<xe::cpu::Processor>( processor_ = std::make_unique<xe::cpu::Processor>(
memory_.get(), export_resolver_.get(), debugger_.get()); this, memory_.get(), export_resolver_.get(), debugger_.get());
if (!processor_->Setup()) { if (!processor_->Setup()) {
return X_STATUS_UNSUCCESSFUL; return X_STATUS_UNSUCCESSFUL;
} }