Removing alloy::tracing, as it's unused.

This commit is contained in:
Ben Vanik 2014-07-13 21:25:58 -07:00
parent 9437d0b564
commit 29e4c35c38
47 changed files with 17 additions and 872 deletions

View File

@ -16,6 +16,5 @@
#include <alloy/runtime/module.h>
#include <alloy/runtime/runtime.h>
#include <alloy/runtime/thread_state.h>
#include <alloy/tracing/tracing.h>
#endif // ALLOY_ALLOY_H_

View File

@ -9,8 +9,6 @@
#include <alloy/backend/assembler.h>
#include <alloy/backend/tracing.h>
namespace alloy {
namespace backend {

View File

@ -9,8 +9,6 @@
#include <alloy/backend/backend.h>
#include <alloy/backend/tracing.h>
namespace alloy {
namespace backend {

View File

@ -12,7 +12,6 @@
#include <alloy/backend/backend.h>
#include <alloy/backend/ivm/ivm_intcode.h>
#include <alloy/backend/ivm/ivm_function.h>
#include <alloy/backend/ivm/tracing.h>
#include <alloy/hir/hir_builder.h>
#include <alloy/hir/label.h>
#include <alloy/runtime/runtime.h>
@ -28,9 +27,7 @@ using alloy::runtime::FunctionInfo;
IVMAssembler::IVMAssembler(Backend* backend)
: Assembler(backend), source_map_arena_(128 * 1024) {}
IVMAssembler::~IVMAssembler() {
alloy::tracing::WriteEvent(EventType::AssemblerDeinit({}));
}
IVMAssembler::~IVMAssembler() = default;
int IVMAssembler::Initialize() {
int result = Assembler::Initialize();
@ -38,8 +35,6 @@ int IVMAssembler::Initialize() {
return result;
}
alloy::tracing::WriteEvent(EventType::AssemblerInit({}));
return result;
}

View File

@ -11,7 +11,6 @@
#include <alloy/backend/ivm/ivm_assembler.h>
#include <alloy/backend/ivm/ivm_stack.h>
#include <alloy/backend/ivm/tracing.h>
namespace alloy {
namespace backend {
@ -21,7 +20,7 @@ using alloy::runtime::Runtime;
IVMBackend::IVMBackend(Runtime* runtime) : Backend(runtime) {}
IVMBackend::~IVMBackend() { alloy::tracing::WriteEvent(EventType::Deinit({})); }
IVMBackend::~IVMBackend() = default;
int IVMBackend::Initialize() {
int result = Backend::Initialize();
@ -38,8 +37,6 @@ int IVMBackend::Initialize() {
16,
};
alloy::tracing::WriteEvent(EventType::Init({}));
return result;
}

View File

@ -10,7 +10,6 @@
#include <alloy/backend/ivm/ivm_function.h>
#include <alloy/backend/ivm/ivm_stack.h>
#include <alloy/backend/tracing.h>
#include <alloy/runtime/runtime.h>
#include <alloy/runtime/thread_state.h>

View File

@ -10,6 +10,5 @@
'ivm_function.cc',
'ivm_stack.cc',
'ivm_stack.h',
'tracing.h',
],
}

View File

@ -1,50 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_BACKEND_IVM_TRACING_H_
#define ALLOY_BACKEND_IVM_TRACING_H_
#include <alloy/backend/tracing.h>
namespace alloy {
namespace backend {
namespace ivm {
const uint32_t ALLOY_BACKEND_IVM = alloy::backend::EventType::ALLOY_BACKEND_IVM;
class EventType {
public:
enum {
ALLOY_BACKEND_IVM_INIT = ALLOY_BACKEND_IVM | (1),
ALLOY_BACKEND_IVM_DEINIT = ALLOY_BACKEND_IVM | (2),
ALLOY_BACKEND_IVM_ASSEMBLER = ALLOY_BACKEND_IVM | (1 << 20),
ALLOY_BACKEND_IVM_ASSEMBLER_INIT = ALLOY_BACKEND_IVM_ASSEMBLER | (1),
ALLOY_BACKEND_IVM_ASSEMBLER_DEINIT = ALLOY_BACKEND_IVM_ASSEMBLER | (2),
};
typedef struct Init_s {
static const uint32_t event_type = ALLOY_BACKEND_IVM_INIT;
} Init;
typedef struct Deinit_s {
static const uint32_t event_type = ALLOY_BACKEND_IVM_DEINIT;
} Deinit;
typedef struct AssemblerInit_s {
static const uint32_t event_type = ALLOY_BACKEND_IVM_ASSEMBLER_INIT;
} AssemblerInit;
typedef struct AssemblerDeinit_s {
static const uint32_t event_type = ALLOY_BACKEND_IVM_ASSEMBLER_DEINIT;
} AssemblerDeinit;
};
} // namespace ivm
} // namespace backend
} // namespace alloy
#endif // ALLOY_BACKEND_IVM_TRACING_H_

View File

@ -6,7 +6,6 @@
'backend.cc',
'backend.h',
'machine_info.h',
'tracing.h',
],
'includes': [

View File

@ -1,32 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_BACKEND_TRACING_H_
#define ALLOY_BACKEND_TRACING_H_
#include <alloy/tracing/tracing.h>
#include <alloy/tracing/event_type.h>
namespace alloy {
namespace backend {
const uint32_t ALLOY_BACKEND = alloy::tracing::EventType::ALLOY_BACKEND;
class EventType {
public:
enum {
ALLOY_BACKEND_IVM = ALLOY_BACKEND | (1 << 24),
ALLOY_BACKEND_X64 = ALLOY_BACKEND | (2 << 24),
};
};
} // namespace backend
} // namespace alloy
#endif // ALLOY_BACKEND_TRACING_H_

View File

@ -1,7 +1,6 @@
# Copyright 2013 Ben Vanik. All Rights Reserved.
{
'sources': [
'tracing.h',
'x64_assembler.cc',
'x64_assembler.h',
'x64_backend.cc',

View File

@ -1,50 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_BACKEND_X64_TRACING_H_
#define ALLOY_BACKEND_X64_TRACING_H_
#include <alloy/backend/tracing.h>
namespace alloy {
namespace backend {
namespace x64 {
const uint32_t ALLOY_BACKEND_X64 = alloy::backend::EventType::ALLOY_BACKEND_X64;
class EventType {
public:
enum {
ALLOY_BACKEND_X64_INIT = ALLOY_BACKEND_X64 | (1),
ALLOY_BACKEND_X64_DEINIT = ALLOY_BACKEND_X64 | (2),
ALLOY_BACKEND_X64_ASSEMBLER = ALLOY_BACKEND_X64 | (1 << 20),
ALLOY_BACKEND_X64_ASSEMBLER_INIT = ALLOY_BACKEND_X64_ASSEMBLER | (1),
ALLOY_BACKEND_X64_ASSEMBLER_DEINIT = ALLOY_BACKEND_X64_ASSEMBLER | (2),
};
typedef struct Init_s {
static const uint32_t event_type = ALLOY_BACKEND_X64_INIT;
} Init;
typedef struct Deinit_s {
static const uint32_t event_type = ALLOY_BACKEND_X64_DEINIT;
} Deinit;
typedef struct AssemblerInit_s {
static const uint32_t event_type = ALLOY_BACKEND_X64_ASSEMBLER_INIT;
} AssemblerInit;
typedef struct AssemblerDeinit_s {
static const uint32_t event_type = ALLOY_BACKEND_X64_ASSEMBLER_DEINIT;
} AssemblerDeinit;
};
} // namespace x64
} // namespace backend
} // namespace alloy
#endif // ALLOY_BACKEND_X64_TRACING_H_

View File

@ -9,7 +9,6 @@
#include <alloy/backend/x64/x64_assembler.h>
#include <alloy/backend/x64/tracing.h>
#include <alloy/backend/x64/x64_backend.h>
#include <alloy/backend/x64/x64_emitter.h>
#include <alloy/backend/x64/x64_function.h>
@ -37,8 +36,6 @@ X64Assembler::X64Assembler(X64Backend* backend)
: Assembler(backend), x64_backend_(backend), emitter_(0), allocator_(0) {}
X64Assembler::~X64Assembler() {
alloy::tracing::WriteEvent(EventType::AssemblerDeinit({}));
delete emitter_;
delete allocator_;
}
@ -52,8 +49,6 @@ int X64Assembler::Initialize() {
allocator_ = new XbyakAllocator();
emitter_ = new X64Emitter(x64_backend_, allocator_);
alloy::tracing::WriteEvent(EventType::AssemblerInit({}));
return result;
}

View File

@ -9,7 +9,6 @@
#include <alloy/backend/x64/x64_backend.h>
#include <alloy/backend/x64/tracing.h>
#include <alloy/backend/x64/x64_assembler.h>
#include <alloy/backend/x64/x64_code_cache.h>
#include <alloy/backend/x64/x64_sequences.h>
@ -23,10 +22,7 @@ using alloy::runtime::Runtime;
X64Backend::X64Backend(Runtime* runtime) : Backend(runtime), code_cache_(0) {}
X64Backend::~X64Backend() {
alloy::tracing::WriteEvent(EventType::Deinit({}));
delete code_cache_;
}
X64Backend::~X64Backend() { delete code_cache_; }
int X64Backend::Initialize() {
int result = Backend::Initialize();
@ -58,8 +54,6 @@ int X64Backend::Initialize() {
delete thunk_emitter;
delete allocator;
alloy::tracing::WriteEvent(EventType::Init({}));
return result;
}

View File

@ -9,8 +9,6 @@
#include <alloy/backend/x64/x64_code_cache.h>
#include <alloy/backend/x64/tracing.h>
namespace alloy {
namespace backend {
namespace x64 {

View File

@ -9,7 +9,6 @@
#include <alloy/backend/x64/x64_function.h>
#include <alloy/backend/x64/tracing.h>
#include <alloy/backend/x64/x64_backend.h>
#include <alloy/runtime/runtime.h>
#include <alloy/runtime/thread_state.h>
@ -24,7 +23,7 @@ using alloy::runtime::FunctionInfo;
using alloy::runtime::ThreadState;
X64Function::X64Function(FunctionInfo* symbol_info)
: Function(symbol_info), machine_code_(NULL), code_size_(0) {}
: Function(symbol_info), machine_code_(nullptr), code_size_(0) {}
X64Function::~X64Function() {
// machine_code_ is freed by code cache.

View File

@ -10,7 +10,6 @@
#include <alloy/compiler/compiler.h>
#include <alloy/compiler/compiler_pass.h>
#include <alloy/compiler/tracing.h>
namespace alloy {
namespace compiler {
@ -20,8 +19,6 @@ using alloy::runtime::Runtime;
Compiler::Compiler(Runtime* runtime) : runtime_(runtime) {
scratch_arena_ = new Arena();
alloy::tracing::WriteEvent(EventType::Init({}));
}
Compiler::~Compiler() {
@ -33,8 +30,6 @@ Compiler::~Compiler() {
}
delete scratch_arena_;
alloy::tracing::WriteEvent(EventType::Deinit({}));
}
void Compiler::AddPass(CompilerPass* pass) {

View File

@ -6,7 +6,6 @@
'compiler_pass.cc',
'compiler_pass.h',
'compiler_passes.h',
'tracing.h',
],
'includes': [

View File

@ -1,39 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_COMPILER_TRACING_H_
#define ALLOY_COMPILER_TRACING_H_
#include <alloy/tracing/tracing.h>
#include <alloy/tracing/event_type.h>
namespace alloy {
namespace compiler {
const uint32_t ALLOY_COMPILER = alloy::tracing::EventType::ALLOY_COMPILER;
class EventType {
public:
enum {
ALLOY_COMPILER_INIT = ALLOY_COMPILER | (1),
ALLOY_COMPILER_DEINIT = ALLOY_COMPILER | (2),
};
typedef struct Init_s {
static const uint32_t event_type = ALLOY_COMPILER_INIT;
} Init;
typedef struct Deinit_s {
static const uint32_t event_type = ALLOY_COMPILER_DEINIT;
} Deinit;
};
} // namespace compiler
} // namespace alloy
#endif // ALLOY_COMPILER_TRACING_H_

View File

@ -9,7 +9,6 @@
#include <alloy/frontend/frontend.h>
#include <alloy/frontend/tracing.h>
#include <alloy/runtime/runtime.h>
namespace alloy {

View File

@ -9,7 +9,6 @@
#include <alloy/frontend/ppc/ppc_frontend.h>
#include <alloy/frontend/tracing.h>
#include <alloy/frontend/ppc/ppc_context.h>
#include <alloy/frontend/ppc/ppc_disasm.h>
#include <alloy/frontend/ppc/ppc_emit.h>
@ -56,8 +55,6 @@ PPCFrontend::PPCFrontend(Runtime* runtime) : Frontend(runtime) {
PPCFrontend::~PPCFrontend() {
// Force cleanup now before we deinit.
translator_pool_.Reset();
alloy::tracing::WriteEvent(EventType::Deinit({}));
}
int PPCFrontend::Initialize() {
@ -66,8 +63,6 @@ int PPCFrontend::Initialize() {
return result;
}
alloy::tracing::WriteEvent(EventType::Init({}));
return result;
}

View File

@ -10,7 +10,6 @@
#include <alloy/frontend/ppc/ppc_hir_builder.h>
#include <alloy/alloy-private.h>
#include <alloy/frontend/tracing.h>
#include <alloy/frontend/ppc/ppc_context.h>
#include <alloy/frontend/ppc/ppc_disasm.h>
#include <alloy/frontend/ppc/ppc_frontend.h>

View File

@ -11,7 +11,6 @@
#include <map>
#include <alloy/frontend/tracing.h>
#include <alloy/frontend/ppc/ppc_frontend.h>
#include <alloy/frontend/ppc/ppc_instr.h>
#include <alloy/runtime/runtime.h>

View File

@ -11,7 +11,6 @@
#include <alloy/alloy-private.h>
#include <alloy/compiler/compiler_passes.h>
#include <alloy/frontend/tracing.h>
#include <alloy/frontend/ppc/ppc_disasm.h>
#include <alloy/frontend/ppc/ppc_frontend.h>
#include <alloy/frontend/ppc/ppc_hir_builder.h>

View File

@ -5,7 +5,6 @@
'context_info.h',
'frontend.cc',
'frontend.h',
'tracing.h',
],
'includes': [

View File

@ -1,39 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_FRONTEND_TRACING_H_
#define ALLOY_FRONTEND_TRACING_H_
#include <alloy/tracing/tracing.h>
#include <alloy/tracing/event_type.h>
namespace alloy {
namespace frontend {
const uint32_t ALLOY_FRONTEND = alloy::tracing::EventType::ALLOY_FRONTEND;
class EventType {
public:
enum {
ALLOY_FRONTEND_INIT = ALLOY_FRONTEND | (1),
ALLOY_FRONTEND_DEINIT = ALLOY_FRONTEND | (2),
};
typedef struct Init_s {
static const uint32_t event_type = ALLOY_FRONTEND_INIT;
} Init;
typedef struct Deinit_s {
static const uint32_t event_type = ALLOY_FRONTEND_DEINIT;
} Deinit;
};
} // namespace frontend
} // namespace alloy
#endif // ALLOY_FRONTEND_TRACING_H_

View File

@ -11,7 +11,6 @@
'opcodes.cc',
'opcodes.h',
'opcodes.inl',
'tracing.h',
'value.cc',
'value.h',
],

View File

@ -1,31 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_HIR_TRACING_H_
#define ALLOY_HIR_TRACING_H_
#include <alloy/tracing/tracing.h>
#include <alloy/tracing/event_type.h>
namespace alloy {
namespace hir {
const uint32_t ALLOY_HIR = alloy::tracing::EventType::ALLOY_HIR;
class EventType {
public:
enum {
ALLOY_HIR_FOO = ALLOY_HIR | (0),
};
};
} // namespace hir
} // namespace alloy
#endif // ALLOY_HIR_TRACING_H_

View File

@ -12,7 +12,6 @@
#include <gflags/gflags.h>
#include <alloy/runtime/module.h>
#include <alloy/runtime/tracing.h>
// TODO(benvanik): based on compiler support
#include <alloy/backend/ivm/ivm_backend.h>
@ -26,9 +25,7 @@ namespace runtime {
using alloy::backend::Backend;
using alloy::frontend::Frontend;
Runtime::Runtime(Memory* memory) : memory_(memory) {
tracing::Initialize();
}
Runtime::Runtime(Memory* memory) : memory_(memory) {}
Runtime::~Runtime() {
{
@ -43,8 +40,6 @@ Runtime::~Runtime() {
debugger_.reset();
frontend_.reset();
backend_.reset();
tracing::Flush();
}
int Runtime::Initialize(std::unique_ptr<Frontend> frontend,

View File

@ -21,7 +21,6 @@
'symbol_info.h',
'thread_state.cc',
'thread_state.h',
'tracing.h',
],
'includes': [

View File

@ -1,88 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_RUNTIME_TRACING_H_
#define ALLOY_RUNTIME_TRACING_H_
#include <alloy/tracing/tracing.h>
#include <alloy/tracing/event_type.h>
namespace alloy {
namespace runtime {
const uint32_t ALLOY_RUNTIME = alloy::tracing::EventType::ALLOY_RUNTIME;
class EventType {
public:
enum {
ALLOY_RUNTIME_INIT = ALLOY_RUNTIME | (1),
ALLOY_RUNTIME_DEINIT = ALLOY_RUNTIME | (2),
ALLOY_RUNTIME_THREAD = ALLOY_RUNTIME | (1 << 25),
ALLOY_RUNTIME_THREAD_INIT = ALLOY_RUNTIME_THREAD | (1),
ALLOY_RUNTIME_THREAD_DEINIT = ALLOY_RUNTIME_THREAD | (2),
ALLOY_RUNTIME_MEMORY = ALLOY_RUNTIME | (2 << 25),
ALLOY_RUNTIME_MEMORY_INIT = ALLOY_RUNTIME_MEMORY | (1),
ALLOY_RUNTIME_MEMORY_DEINIT = ALLOY_RUNTIME_MEMORY | (2),
ALLOY_RUNTIME_MEMORY_HEAP = ALLOY_RUNTIME_MEMORY | (1000),
ALLOY_RUNTIME_MEMORY_HEAP_INIT = ALLOY_RUNTIME_MEMORY_HEAP | (1),
ALLOY_RUNTIME_MEMORY_HEAP_DEINIT = ALLOY_RUNTIME_MEMORY | (2),
ALLOY_RUNTIME_MEMORY_HEAP_ALLOC = ALLOY_RUNTIME_MEMORY | (3),
ALLOY_RUNTIME_MEMORY_HEAP_FREE = ALLOY_RUNTIME_MEMORY | (4),
};
typedef struct Init_s {
static const uint32_t event_type = ALLOY_RUNTIME_INIT;
} Init;
typedef struct Deinit_s {
static const uint32_t event_type = ALLOY_RUNTIME_DEINIT;
} Deinit;
typedef struct ThreadInit_s {
static const uint32_t event_type = ALLOY_RUNTIME_THREAD_INIT;
} ThreadInit;
typedef struct ThreadDeinit_s {
static const uint32_t event_type = ALLOY_RUNTIME_THREAD_DEINIT;
} ThreadDeinit;
typedef struct MemoryInit_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_INIT;
// map of memory, etc?
} MemoryInit;
typedef struct MemoryDeinit_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_DEINIT;
} MemoryDeinit;
typedef struct MemoryHeapInit_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_INIT;
uint32_t heap_id;
uint64_t low_address;
uint64_t high_address;
uint32_t is_physical;
} MemoryHeapInit;
typedef struct MemoryHeapDeinit_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_DEINIT;
uint32_t heap_id;
} MemoryHeapDeinit;
typedef struct MemoryHeapAlloc_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_ALLOC;
uint32_t heap_id;
uint32_t flags;
uint64_t address;
size_t size;
} MemoryHeapAlloc;
typedef struct MemoryHeapFree_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_FREE;
uint32_t heap_id;
uint64_t address;
} MemoryHeapFree;
};
} // namespace runtime
} // namespace alloy
#endif // ALLOY_RUNTIME_TRACING_H_

View File

@ -40,6 +40,5 @@
'frontend/sources.gypi',
'hir/sources.gypi',
'runtime/sources.gypi',
'tracing/sources.gypi',
],
}

View File

@ -1,20 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include <alloy/tracing/channel.h>
namespace alloy {
namespace tracing {
Channel::Channel() = default;
Channel::~Channel() = default;
} // namespace tracing
} // namespace alloy

View File

@ -1,31 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_TRACING_CHANNEL_H_
#define ALLOY_TRACING_CHANNEL_H_
#include <alloy/core.h>
namespace alloy {
namespace tracing {
class Channel {
public:
Channel();
virtual ~Channel();
virtual void Write(size_t buffer_count, size_t buffer_lengths[],
const uint8_t* buffers[]) = 0;
virtual void Flush() = 0;
};
} // namespace tracing
} // namespace alloy
#endif // ALLOY_TRACING_CHANNEL_H_

View File

@ -1,47 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include <alloy/tracing/channels/file_channel.h>
namespace alloy {
namespace tracing {
namespace channels {
FileChannel::FileChannel(const std::string& path) : path_(path) {
file_ = fopen(path_.c_str(), "wb");
}
FileChannel::~FileChannel() {
std::lock_guard<std::mutex> guard(lock_);
if (file_) {
fclose(file_);
file_ = nullptr;
}
}
void FileChannel::Write(size_t buffer_count, size_t buffer_lengths[],
const uint8_t* buffers[]) {
std::lock_guard<std::mutex> guard(lock_);
if (file_) {
for (size_t n = 0; n < buffer_count; n++) {
fwrite(buffers[n], buffer_lengths[n], 1, file_);
}
}
}
void FileChannel::Flush() {
std::lock_guard<std::mutex> guard(lock_);
if (file_) {
fflush(file_);
}
}
} // namespace channels
} // namespace tracing
} // namespace alloy

View File

@ -1,43 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_TRACING_CHANNELS_FILE_CHANNEL_H_
#define ALLOY_TRACING_CHANNELS_FILE_CHANNEL_H_
#include <mutex>
#include <alloy/core.h>
#include <alloy/tracing/channel.h>
namespace alloy {
namespace tracing {
namespace channels {
class FileChannel : public Channel {
public:
FileChannel(const std::string& path);
~FileChannel() override;
void Write(size_t buffer_count, size_t buffer_lengths[],
const uint8_t* buffers[]) override;
void Flush() override;
private:
std::string path_;
FILE* file_;
std::mutex lock_;
};
} // namespace channels
} // namespace tracing
} // namespace alloy
#endif // ALLOY_TRACING_CHANNELS_FILE_CHANNEL_H_

View File

@ -1,7 +0,0 @@
# Copyright 2013 Ben Vanik. All Rights Reserved.
{
'sources': [
'file_channel.cc',
'file_channel.h',
],
}

View File

@ -1,43 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_TRACING_EVENT_TYPES_H_
#define ALLOY_TRACING_EVENT_TYPES_H_
#include <alloy/core.h>
namespace alloy {
namespace tracing {
class EventType {
public:
enum {
ALLOY = (0 << 31),
ALLOY_TRACE_INIT = ALLOY | (1),
ALLOY_TRACE_EOF = ALLOY | (2),
ALLOY_BACKEND = ALLOY | (1 << 26),
ALLOY_COMPILER = ALLOY | (2 << 26),
ALLOY_HIR = ALLOY | (3 << 26),
ALLOY_FRONTEND = ALLOY | (4 << 26),
ALLOY_RUNTIME = ALLOY | (5 << 26),
USER = (1 << 31),
};
typedef struct TraceInit_s {
static const uint32_t event_type = ALLOY_TRACE_INIT;
} TraceInit;
typedef struct TraceEOF_s {
static const uint32_t event_type = ALLOY_TRACE_EOF;
} TraceEOF;
};
} // namespace tracing
} // namespace alloy
#endif // ALLOY_TRACING_EVENT_TYPES_H_

View File

@ -1,16 +0,0 @@
# Copyright 2013 Ben Vanik. All Rights Reserved.
{
'sources': [
'channel.cc',
'channel.h',
'event_type.h',
'tracer.cc',
'tracer.h',
'tracing.cc',
'tracing.h',
],
'includes': [
'channels/sources.gypi',
],
}

View File

@ -1,44 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include <alloy/tracing/tracer.h>
#include <atomic>
#include <alloy/tracing/channel.h>
namespace alloy {
namespace tracing {
std::atomic<int> next_thread_id_(0x10000000);
Tracer::Tracer(Channel* channel) : channel_(channel) {
thread_id_ = ++next_thread_id_;
}
Tracer::~Tracer() = default;
void Tracer::WriteEvent(uint32_t event_type, size_t size, const uint8_t* data) {
uint32_t header[] = {
event_type, (uint32_t)thread_id_,
0, // time in us
(uint32_t)size,
};
size_t buffer_count = size ? 2 : 1;
size_t buffer_lengths[] = {
sizeof(header), size,
};
const uint8_t* buffers[] = {
(const uint8_t*)header, data,
};
channel_->Write(buffer_count, buffer_lengths, buffers);
}
} // namespace tracing
} // namespace alloy

View File

@ -1,39 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_TRACING_TRACER_H_
#define ALLOY_TRACING_TRACER_H_
#include <alloy/core.h>
namespace alloy {
namespace tracing {
class Channel;
class Tracer {
public:
Tracer(Channel* channel);
~Tracer();
int thread_id() const { return thread_id_; }
void set_thread_id(int value) { thread_id_ = value; }
void WriteEvent(uint32_t event_type, size_t size = 0,
const uint8_t* data = nullptr);
private:
Channel* channel_;
int thread_id_;
};
} // namespace tracing
} // namespace alloy
#endif // ALLOY_TRACING_TRACER_H_

View File

@ -1,87 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include <alloy/tracing/tracing.h>
#include <thread>
#include <gflags/gflags.h>
#include <alloy/tracing/channel.h>
#include <alloy/tracing/event_type.h>
#include <alloy/tracing/tracer.h>
#include <alloy/tracing/channels/file_channel.h>
DEFINE_string(trace_file, "", "Traces to the given file path.");
// trace shared memory
// trace socket
namespace alloy {
namespace tracing {
Channel* shared_channel = nullptr;
thread_local Tracer* thread_tracer = nullptr;
void CleanupTracing() {
if (shared_channel) {
alloy::tracing::WriteEvent(EventType::TraceEOF({}));
shared_channel->Flush();
shared_channel = nullptr;
}
}
bool Initialize(Channel* channel) {
if (shared_channel) {
return false;
}
if (!channel) {
// Create from flags.
if (FLAGS_trace_file.size()) {
channel = new channels::FileChannel(FLAGS_trace_file.c_str());
}
if (!channel) {
// Tracing disabled.
return true;
}
}
shared_channel = channel;
alloy::tracing::WriteEvent(EventType::TraceInit({}));
channel->Flush();
atexit(CleanupTracing);
return true;
}
void Shutdown() {
// ?
}
void Flush() {
if (shared_channel) {
shared_channel->Flush();
}
}
Tracer* GetThreadTracer() {
if (!shared_channel) {
return nullptr;
}
if (!thread_tracer) {
thread_tracer = new Tracer(shared_channel);
}
return thread_tracer;
}
void WriteEvent(uint32_t event_type, size_t size, const void* data) {
Tracer* t = GetThreadTracer();
if (t) {
t->WriteEvent(event_type, size, (const uint8_t*)data);
}
}
} // namespace tracing
} // namespace alloy

View File

@ -1,44 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef ALLOY_TRACING_TRACING_H_
#define ALLOY_TRACING_TRACING_H_
#include <alloy/core.h>
#include <alloy/tracing/event_type.h>
namespace alloy {
namespace tracing {
class Channel;
class Tracer;
bool Initialize(Channel* channel = nullptr);
void Shutdown();
void Flush();
Tracer* GetThreadTracer();
void WriteEvent(uint32_t event_type, size_t size = 0,
const void* data = nullptr);
template <typename T>
void WriteEvent(const T& ev) {
if (sizeof(T) > 1) {
alloy::tracing::WriteEvent(T::event_type, sizeof(T), &ev);
} else {
alloy::tracing::WriteEvent(T::event_type);
}
}
} // namespace tracing
} // namespace alloy
#endif // ALLOY_TRACING_TRACING_H_

View File

@ -11,12 +11,9 @@
#include <mutex>
#include <alloy/runtime/tracing.h>
#include <gflags/gflags.h>
using namespace alloy;
using namespace alloy::runtime;
using namespace xe::cpu;
// TODO(benvanik): move xbox.h out
@ -267,9 +264,6 @@ XenonMemory::~XenonMemory() {
CloseHandle(mapping_);
mapping_base_ = 0;
mapping_ = 0;
alloy::tracing::WriteEvent(EventType::MemoryDeinit({
}));
}
}
@ -311,9 +305,6 @@ int XenonMemory::Initialize() {
}
membase_ = mapping_base_;
alloy::tracing::WriteEvent(EventType::MemoryInit({
}));
// Prepare heaps.
virtual_heap_->Initialize(
XENON_MEMORY_VIRTUAL_HEAP_LOW, XENON_MEMORY_VIRTUAL_HEAP_HIGH);
@ -542,10 +533,6 @@ uint64_t XenonMemory::HeapAlloc(
xe_zero_struct(pv, size);
}
alloy::tracing::WriteEvent(EventType::MemoryHeapAlloc({
0, flags, base_address, size,
}));
return base_address;
}
}
@ -559,9 +546,6 @@ int XenonMemory::HeapFree(uint64_t address, size_t size) {
return physical_heap_->Free(address, size) ? 0 : 1;
} else {
// A placed address. Decommit.
alloy::tracing::WriteEvent(EventType::MemoryHeapFree({
0, address,
}));
uint8_t* p = Translate(address);
return VirtualFree(p, size, MEM_DECOMMIT) ? 0 : 1;
}
@ -628,10 +612,6 @@ XenonMemoryHeap::~XenonMemoryHeap() {
if (ptr_) {
XEIGNORE(VirtualFree(ptr_, 0, MEM_RELEASE));
alloy::tracing::WriteEvent(EventType::MemoryHeapDeinit({
heap_id_,
}));
}
}
@ -648,10 +628,6 @@ int XenonMemoryHeap::Initialize(uint64_t low, uint64_t high) {
}
space_ = create_mspace_with_base(ptr_, size_, 0);
alloy::tracing::WriteEvent(EventType::MemoryHeapInit({
heap_id_, low, high, is_physical_,
}));
return 0;
}
@ -719,10 +695,6 @@ uint64_t XenonMemoryHeap::Alloc(
uint64_t address =
(uint64_t)((uintptr_t)p - (uintptr_t)memory_->mapping_base_);
alloy::tracing::WriteEvent(EventType::MemoryHeapAlloc({
heap_id_, flags, address, size,
}));
return address;
}
@ -775,10 +747,6 @@ uint64_t XenonMemoryHeap::Free(uint64_t address, size_t size) {
MEM_DECOMMIT);
}
alloy::tracing::WriteEvent(EventType::MemoryHeapFree({
heap_id_, address,
}));
return (uint64_t)real_size;
}

View File

@ -10,7 +10,6 @@
#include <xenia/cpu/xenon_runtime.h>
#include <alloy/frontend/ppc/ppc_frontend.h>
#include <alloy/runtime/tracing.h>
#include <xenia/cpu/xenon_thread_state.h>
@ -27,10 +26,7 @@ XenonRuntime::XenonRuntime(
export_resolver_(export_resolver) {
}
XenonRuntime::~XenonRuntime() {
alloy::tracing::WriteEvent(EventType::Deinit({
}));
}
XenonRuntime::~XenonRuntime() = default;
int XenonRuntime::Initialize(std::unique_ptr<backend::Backend> backend) {
std::unique_ptr<PPCFrontend> frontend(new PPCFrontend(this));
@ -41,8 +37,5 @@ int XenonRuntime::Initialize(std::unique_ptr<backend::Backend> backend) {
return result;
}
alloy::tracing::WriteEvent(EventType::Init({
}));
return result;
}

View File

@ -9,8 +9,6 @@
#include <xenia/cpu/xenon_thread_state.h>
#include <alloy/runtime/tracing.h>
#include <xenia/cpu/xenon_runtime.h>
using namespace alloy;
@ -19,15 +17,13 @@ using namespace alloy::frontend::ppc;
using namespace alloy::runtime;
using namespace xe::cpu;
XenonThreadState::XenonThreadState(
XenonRuntime* runtime, uint32_t thread_id,
size_t stack_size, uint64_t thread_state_address) :
ThreadState(runtime, thread_id),
XenonThreadState::XenonThreadState(XenonRuntime* runtime, uint32_t thread_id,
size_t stack_size,
uint64_t thread_state_address)
: ThreadState(runtime, thread_id),
stack_size_(stack_size),
thread_state_address_(thread_state_address) {
stack_address_ = memory_->HeapAlloc(
0, stack_size, MEMORY_FLAG_ZERO);
stack_address_ = memory_->HeapAlloc(0, stack_size, MEMORY_FLAG_ZERO);
// Allocate with 64b alignment.
context_ = (PPCContext*)xe_malloc_aligned(sizeof(PPCContext));
@ -50,18 +46,12 @@ XenonThreadState::XenonThreadState(
raw_context_ = context_;
alloy::tracing::WriteEvent(EventType::ThreadInit({
}));
runtime_->debugger()->OnThreadCreated(this);
}
XenonThreadState::~XenonThreadState() {
runtime_->debugger()->OnThreadDestroyed(this);
alloy::tracing::WriteEvent(EventType::ThreadDeinit({
}));
xe_free_aligned(context_);
memory_->HeapFree(stack_address_, stack_size_);
}

View File

@ -9,7 +9,6 @@
#include <xenia/cpu/xex_module.h>
#include <alloy/runtime/tracing.h>
#include <xenia/cpu/cpu-private.h>
#include <xenia/cpu/xenon_runtime.h>
#include <xenia/export_resolver.h>