Reconcile debugger and save state stuff into a single implementation.

Fixes #497 and fixes #496.
Still rough edges, but at least less duplication.
This commit is contained in:
Ben Vanik
2016-01-18 11:48:21 -08:00
parent ca135eb0e7
commit 6777ce6668
51 changed files with 1687 additions and 2250 deletions

View File

@@ -41,7 +41,7 @@ bool PPCScanner::IsRestGprLr(uint32_t address) {
return function && function->behavior() == Function::Behavior::kEpilogReturn;
}
bool PPCScanner::Scan(GuestFunction* function, DebugInfo* debug_info) {
bool PPCScanner::Scan(GuestFunction* function, FunctionDebugInfo* debug_info) {
// This is a simple basic block analyizer. It walks the start address to the
// end address looking for branches. Each span of instructions between
// branches is considered a basic block. When the last blr (that has no

View File

@@ -12,8 +12,8 @@
#include <vector>
#include "xenia/cpu/debug_info.h"
#include "xenia/cpu/function.h"
#include "xenia/cpu/function_debug_info.h"
namespace xe {
namespace cpu {
@@ -31,7 +31,7 @@ class PPCScanner {
explicit PPCScanner(PPCFrontend* frontend);
~PPCScanner();
bool Scan(GuestFunction* function, DebugInfo* debug_info);
bool Scan(GuestFunction* function, FunctionDebugInfo* debug_info);
std::vector<BlockInfo> FindBlocks(GuestFunction* function);

View File

@@ -23,7 +23,6 @@
#include "xenia/cpu/ppc/ppc_opcode_info.h"
#include "xenia/cpu/ppc/ppc_scanner.h"
#include "xenia/cpu/processor.h"
#include "xenia/debug/debugger.h"
namespace xe {
namespace cpu {
@@ -118,9 +117,9 @@ bool PPCTranslator::Translate(GuestFunction* function,
if (FLAGS_trace_function_data) {
debug_info_flags |= DebugInfoFlags::kDebugInfoTraceFunctionData;
}
std::unique_ptr<DebugInfo> debug_info;
std::unique_ptr<FunctionDebugInfo> debug_info;
if (debug_info_flags) {
debug_info.reset(new DebugInfo());
debug_info.reset(new FunctionDebugInfo());
}
// Scan the function to find its extents and gather debug data.
@@ -128,25 +127,24 @@ bool PPCTranslator::Translate(GuestFunction* function,
return false;
}
auto debugger = frontend_->processor()->debugger();
if (!debugger) {
debug_info_flags &= ~DebugInfoFlags::kDebugInfoAllTracing;
}
// Setup trace data, if needed.
if (debug_info_flags & DebugInfoFlags::kDebugInfoTraceFunctions) {
// Base trace data.
size_t trace_data_size = debug::FunctionTraceData::SizeOfHeader();
size_t trace_data_size = FunctionTraceData::SizeOfHeader();
if (debug_info_flags & DebugInfoFlags::kDebugInfoTraceFunctionCoverage) {
// Additional space for instruction coverage counts.
trace_data_size += debug::FunctionTraceData::SizeOfInstructionCounts(
trace_data_size += FunctionTraceData::SizeOfInstructionCounts(
function->address(), function->end_address());
}
uint8_t* trace_data = debugger->AllocateFunctionTraceData(trace_data_size);
uint8_t* trace_data =
frontend_->processor()->AllocateFunctionTraceData(trace_data_size);
if (trace_data) {
function->trace_data().Reset(trace_data, trace_data_size,
function->address(),
function->end_address());
} else {
debug_info_flags &= ~(DebugInfoFlags::kDebugInfoTraceFunctions |
DebugInfoFlags::kDebugInfoTraceFunctionCoverage);
}
}

View File

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

View File

@@ -14,7 +14,6 @@ project("xenia-cpu-ppc-tests")
"xenia-cpu-backend-x64",
-- TODO(benvanik): remove these dependencies.
"xenia-debug",
"xenia-kernel"
})
files({