diff --git a/src/alloy/alloy-private.h b/src/alloy/alloy-private.h index 11e849cee..fb0c8561c 100644 --- a/src/alloy/alloy-private.h +++ b/src/alloy/alloy-private.h @@ -12,6 +12,11 @@ #include +#include + + +DECLARE_bool(debug); + namespace alloy { diff --git a/src/alloy/alloy.cc b/src/alloy/alloy.cc new file mode 100644 index 000000000..7453d2c6d --- /dev/null +++ b/src/alloy/alloy.cc @@ -0,0 +1,23 @@ +/** + ****************************************************************************** + * 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 +#include + +using namespace alloy; + + +#if DEBUG +#define DEFAULT_DEBUG_FLAG true +#else +#define DEFAULT_DEBUG_FLAG false +#endif + +DEFINE_bool(debug, DEFAULT_DEBUG_FLAG, + "Allow debugging and retain debug information."); diff --git a/src/alloy/frontend/frontend.h b/src/alloy/frontend/frontend.h index 4de31e222..1686dbf06 100644 --- a/src/alloy/frontend/frontend.h +++ b/src/alloy/frontend/frontend.h @@ -39,7 +39,7 @@ public: virtual int DeclareFunction( runtime::FunctionInfo* symbol_info) = 0; virtual int DefineFunction( - runtime::FunctionInfo* symbol_info, + runtime::FunctionInfo* symbol_info, bool with_debug_info, runtime::Function** out_function) = 0; protected: diff --git a/src/alloy/frontend/ppc/ppc_frontend.cc b/src/alloy/frontend/ppc/ppc_frontend.cc index 2a01e82a2..eb416927d 100644 --- a/src/alloy/frontend/ppc/ppc_frontend.cc +++ b/src/alloy/frontend/ppc/ppc_frontend.cc @@ -92,10 +92,11 @@ int PPCFrontend::DeclareFunction( } int PPCFrontend::DefineFunction( - FunctionInfo* symbol_info, + FunctionInfo* symbol_info, bool with_debug_info, Function** out_function) { PPCTranslator* translator = translator_pool_.Allocate(this); - int result = translator->Translate(symbol_info, out_function); + int result = translator->Translate( + symbol_info, with_debug_info, out_function); translator_pool_.Release(translator); return result; } diff --git a/src/alloy/frontend/ppc/ppc_frontend.h b/src/alloy/frontend/ppc/ppc_frontend.h index ca0f60903..14a3b31e3 100644 --- a/src/alloy/frontend/ppc/ppc_frontend.h +++ b/src/alloy/frontend/ppc/ppc_frontend.h @@ -32,7 +32,7 @@ public: virtual int DeclareFunction( runtime::FunctionInfo* symbol_info); virtual int DefineFunction( - runtime::FunctionInfo* symbol_info, + runtime::FunctionInfo* symbol_info, bool with_debug_info, runtime::Function** out_function); private: diff --git a/src/alloy/frontend/ppc/ppc_translator.cc b/src/alloy/frontend/ppc/ppc_translator.cc index 46c69d3cc..cd652af93 100644 --- a/src/alloy/frontend/ppc/ppc_translator.cc +++ b/src/alloy/frontend/ppc/ppc_translator.cc @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -56,6 +57,7 @@ PPCTranslator::~PPCTranslator() { int PPCTranslator::Translate( FunctionInfo* symbol_info, + bool with_debug_info, Function** out_function) { // Scan the function to find its extents. We only need to do this if we // haven't already been provided with them from some other source. @@ -70,7 +72,10 @@ int PPCTranslator::Translate( } // NOTE: we only want to do this when required, as it's expensive to build. - DebugInfo* debug_info = new DebugInfo(); + DebugInfo* debug_info = NULL; + if (FLAGS_debug || with_debug_info) { + debug_info = new DebugInfo(); + } // Stash source. if (debug_info) { diff --git a/src/alloy/frontend/ppc/ppc_translator.h b/src/alloy/frontend/ppc/ppc_translator.h index 79e40aaf9..9a2f0a0d4 100644 --- a/src/alloy/frontend/ppc/ppc_translator.h +++ b/src/alloy/frontend/ppc/ppc_translator.h @@ -31,6 +31,7 @@ public: ~PPCTranslator(); int Translate(runtime::FunctionInfo* symbol_info, + bool with_debug_info, runtime::Function** out_function); private: diff --git a/src/alloy/runtime/runtime.cc b/src/alloy/runtime/runtime.cc index de3627311..dbf9c0825 100644 --- a/src/alloy/runtime/runtime.cc +++ b/src/alloy/runtime/runtime.cc @@ -225,7 +225,7 @@ int Runtime::DemandFunction( if (symbol_status == SymbolInfo::STATUS_NEW) { // Symbol is undefined, so define now. Function* function = NULL; - int result = frontend_->DefineFunction(symbol_info, &function); + int result = frontend_->DefineFunction(symbol_info, false, &function); if (result) { symbol_info->set_status(SymbolInfo::STATUS_FAILED); return result; diff --git a/src/alloy/sources.gypi b/src/alloy/sources.gypi index ca4c5fa1d..144246165 100644 --- a/src/alloy/sources.gypi +++ b/src/alloy/sources.gypi @@ -2,6 +2,7 @@ { 'sources': [ 'alloy-private.h', + 'alloy.cc', 'alloy.h', 'arena.cc', 'arena.h', diff --git a/src/xenia/cpu/processor.cc b/src/xenia/cpu/processor.cc index aeea7374c..42e381295 100644 --- a/src/xenia/cpu/processor.cc +++ b/src/xenia/cpu/processor.cc @@ -230,7 +230,7 @@ json_t* Processor::OnDebugRequest( // If we ever wanted absolute x64 addresses/etc we could // use the x64 from the function in the symbol table. Function* fn; - if (runtime_->frontend()->DefineFunction(info, &fn)) { + if (runtime_->frontend()->DefineFunction(info, true, &fn)) { succeeded = false; return json_string("Unable to resolve function"); }