Debugger stuff, and changing to vcproj's/sln.
This commit is contained in:
@@ -36,29 +36,44 @@ 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);
|
||||
std::wstring functions_path = xe::join_paths(session_path, L"functions");
|
||||
functions_file_ =
|
||||
ChunkedMappedMemoryWriter::Open(functions_path, 32 * 1024 * 1024, false);
|
||||
|
||||
std::wstring functions_trace_path =
|
||||
xe::join_paths(session_path, L"functions.trace");
|
||||
functions_trace_file_ = ChunkedMappedMemoryWriter::Open(
|
||||
functions_trace_path, 32 * 1024 * 1024, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Debugger::StopSession() {
|
||||
FlushSession();
|
||||
trace_functions_.reset();
|
||||
functions_file_.reset();
|
||||
functions_trace_file_.reset();
|
||||
}
|
||||
|
||||
void Debugger::FlushSession() {
|
||||
if (trace_functions_) {
|
||||
trace_functions_->Flush();
|
||||
if (functions_file_) {
|
||||
functions_file_->Flush();
|
||||
}
|
||||
if (functions_trace_file_) {
|
||||
functions_trace_file_->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t* Debugger::AllocateTraceFunctionData(size_t size) {
|
||||
if (!trace_functions_) {
|
||||
uint8_t* Debugger::AllocateFunctionData(size_t size) {
|
||||
if (!functions_file_) {
|
||||
return nullptr;
|
||||
}
|
||||
return trace_functions_->Allocate(size);
|
||||
return functions_file_->Allocate(size);
|
||||
}
|
||||
|
||||
uint8_t* Debugger::AllocateFunctionTraceData(size_t size) {
|
||||
if (!functions_trace_file_) {
|
||||
return nullptr;
|
||||
}
|
||||
return functions_trace_file_->Allocate(size);
|
||||
}
|
||||
|
||||
int Debugger::SuspendAllThreads(uint32_t timeout_ms) {
|
||||
|
||||
@@ -71,7 +71,8 @@ class Debugger {
|
||||
void StopSession();
|
||||
void FlushSession();
|
||||
|
||||
uint8_t* AllocateTraceFunctionData(size_t size);
|
||||
uint8_t* AllocateFunctionData(size_t size);
|
||||
uint8_t* AllocateFunctionTraceData(size_t size);
|
||||
|
||||
int SuspendAllThreads(uint32_t timeout_ms = UINT_MAX);
|
||||
int ResumeThread(uint32_t thread_id);
|
||||
@@ -100,7 +101,8 @@ class Debugger {
|
||||
private:
|
||||
cpu::Processor* processor_;
|
||||
|
||||
std::unique_ptr<ChunkedMappedMemoryWriter> trace_functions_;
|
||||
std::unique_ptr<ChunkedMappedMemoryWriter> functions_file_;
|
||||
std::unique_ptr<ChunkedMappedMemoryWriter> functions_trace_file_;
|
||||
|
||||
std::mutex threads_lock_;
|
||||
std::unordered_map<uint32_t, cpu::ThreadState*> threads_;
|
||||
|
||||
81
src/xenia/debug/function_data.h
Normal file
81
src/xenia/debug/function_data.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_DEBUG_FUNCTION_DATA_H_
|
||||
#define XENIA_DEBUG_FUNCTION_DATA_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "xenia/base/memory.h"
|
||||
|
||||
namespace xe {
|
||||
namespace debug {
|
||||
|
||||
class FunctionData {
|
||||
public:
|
||||
struct Header {
|
||||
// Format is used by tooling, changes must be made across all targets.
|
||||
// + 0 4b (data size)
|
||||
// + 4 4b start_address
|
||||
// + 8 4b end_address
|
||||
// +12 4b type (user, external, etc)
|
||||
// +16 4b source_map_entry_count
|
||||
//
|
||||
// +20 4b source_disasm_length
|
||||
// +20 4b raw_hir_disasm_length
|
||||
// +20 4b hir_disasm_length
|
||||
// +20 4b machine_code_disasm_length
|
||||
// +20 12b* source_map_entries
|
||||
uint32_t data_size;
|
||||
uint32_t start_address;
|
||||
uint32_t end_address;
|
||||
uint32_t type;
|
||||
/*
|
||||
source_map_count
|
||||
source_map[] : {ppc_address, hir_offset, code_offset}
|
||||
raw_hir_disasm_ (len + chars)
|
||||
hir_disasm_ (len + chars)
|
||||
machine_code_ (len + bytes) (without tracing? regen?)
|
||||
*/
|
||||
};
|
||||
|
||||
FunctionData() : header_(nullptr) {}
|
||||
|
||||
void Reset(uint8_t* trace_data, size_t trace_data_size,
|
||||
uint32_t start_address, uint32_t end_address) {
|
||||
header_ = reinterpret_cast<Header*>(trace_data);
|
||||
header_->data_size = uint32_t(trace_data_size);
|
||||
header_->start_address = start_address;
|
||||
header_->end_address = end_address;
|
||||
header_->type = 0;
|
||||
// Clear any remaining.
|
||||
std::memset(trace_data + sizeof(Header), 0,
|
||||
trace_data_size - sizeof(Header));
|
||||
}
|
||||
|
||||
bool is_valid() const { return header_ != nullptr; }
|
||||
|
||||
uint32_t start_address() const { return header_->start_address; }
|
||||
uint32_t end_address() const { return header_->end_address; }
|
||||
uint32_t instruction_count() const {
|
||||
return (header_->end_address - header_->start_address) / 4 + 1;
|
||||
}
|
||||
|
||||
Header* header() const { return header_; }
|
||||
|
||||
static size_t SizeOfHeader() { return sizeof(Header); }
|
||||
|
||||
private:
|
||||
Header* header_;
|
||||
};
|
||||
|
||||
} // namespace debug
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_DEBUG_FUNCTION_DATA_H_
|
||||
@@ -7,8 +7,8 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_DEBUG_TRACE_DATA_H_
|
||||
#define XENIA_DEBUG_TRACE_DATA_H_
|
||||
#ifndef XENIA_DEBUG_FUNCTION_TRACE_DATA_H_
|
||||
#define XENIA_DEBUG_FUNCTION_TRACE_DATA_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -89,4 +89,4 @@ class FunctionTraceData {
|
||||
} // namespace debug
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_DEBUG_TRACE_DATA_H_
|
||||
#endif // XENIA_DEBUG_FUNCTION_TRACE_DATA_H_
|
||||
@@ -1,10 +0,0 @@
|
||||
# Copyright 2015 Ben Vanik. All Rights Reserved.
|
||||
{
|
||||
'sources': [
|
||||
'debug_server.cc',
|
||||
'debug_server.h',
|
||||
'debugger.cc',
|
||||
'debugger.h',
|
||||
'trace_data.h',
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user