--trace_functions and --trace_function_coverage

This commit is contained in:
Ben Vanik
2015-05-05 22:44:36 -07:00
parent ade5388728
commit 94c62b91d0
24 changed files with 365 additions and 82 deletions

View File

@@ -9,11 +9,16 @@
#include "xenia/debug/debugger.h"
#include <gflags/gflags.h>
#include <mutex>
#include "xenia/base/string.h"
#include "xenia/cpu/function.h"
#include "xenia/cpu/processor.h"
DEFINE_string(debug_session_path, "", "Debug output path.");
namespace xe {
namespace debug {
@@ -28,6 +33,34 @@ Debugger::Debugger(cpu::Processor* processor) : processor_(processor) {}
Debugger::~Debugger() = default;
bool Debugger::StartSession() {
std::wstring session_path = xe::to_wstring(FLAGS_debug_session_path);
std::wstring trace_functions_path =
xe::join_paths(session_path, L"trace.functions");
trace_functions_ = ChunkedMappedMemoryWriter::Open(trace_functions_path,
32 * 1024 * 1024, true);
return true;
}
void Debugger::StopSession() {
FlushSession();
trace_functions_.reset();
}
void Debugger::FlushSession() {
if (trace_functions_) {
trace_functions_->Flush();
}
}
uint8_t* Debugger::AllocateTraceFunctionData(size_t size) {
if (!trace_functions_) {
return nullptr;
}
return trace_functions_->Allocate(size);
}
int Debugger::SuspendAllThreads(uint32_t timeout_ms) {
std::lock_guard<std::mutex> guard(threads_lock_);