Only generate debug info when in --debug mode (or asked).

This commit is contained in:
Ben Vanik 2013-12-22 09:50:31 -08:00
parent c92142ca02
commit de6dc92663
10 changed files with 43 additions and 7 deletions

View File

@ -12,6 +12,11 @@
#include <alloy/core.h> #include <alloy/core.h>
#include <gflags/gflags.h>
DECLARE_bool(debug);
namespace alloy { namespace alloy {

23
src/alloy/alloy.cc Normal file
View File

@ -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 <alloy/alloy.h>
#include <alloy/alloy-private.h>
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.");

View File

@ -39,7 +39,7 @@ public:
virtual int DeclareFunction( virtual int DeclareFunction(
runtime::FunctionInfo* symbol_info) = 0; runtime::FunctionInfo* symbol_info) = 0;
virtual int DefineFunction( virtual int DefineFunction(
runtime::FunctionInfo* symbol_info, runtime::FunctionInfo* symbol_info, bool with_debug_info,
runtime::Function** out_function) = 0; runtime::Function** out_function) = 0;
protected: protected:

View File

@ -92,10 +92,11 @@ int PPCFrontend::DeclareFunction(
} }
int PPCFrontend::DefineFunction( int PPCFrontend::DefineFunction(
FunctionInfo* symbol_info, FunctionInfo* symbol_info, bool with_debug_info,
Function** out_function) { Function** out_function) {
PPCTranslator* translator = translator_pool_.Allocate(this); 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); translator_pool_.Release(translator);
return result; return result;
} }

View File

@ -32,7 +32,7 @@ public:
virtual int DeclareFunction( virtual int DeclareFunction(
runtime::FunctionInfo* symbol_info); runtime::FunctionInfo* symbol_info);
virtual int DefineFunction( virtual int DefineFunction(
runtime::FunctionInfo* symbol_info, runtime::FunctionInfo* symbol_info, bool with_debug_info,
runtime::Function** out_function); runtime::Function** out_function);
private: private:

View File

@ -9,6 +9,7 @@
#include <alloy/frontend/ppc/ppc_translator.h> #include <alloy/frontend/ppc/ppc_translator.h>
#include <alloy/alloy-private.h>
#include <alloy/compiler/passes.h> #include <alloy/compiler/passes.h>
#include <alloy/frontend/tracing.h> #include <alloy/frontend/tracing.h>
#include <alloy/frontend/ppc/ppc_frontend.h> #include <alloy/frontend/ppc/ppc_frontend.h>
@ -56,6 +57,7 @@ PPCTranslator::~PPCTranslator() {
int PPCTranslator::Translate( int PPCTranslator::Translate(
FunctionInfo* symbol_info, FunctionInfo* symbol_info,
bool with_debug_info,
Function** out_function) { Function** out_function) {
// Scan the function to find its extents. We only need to do this if we // 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. // 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. // 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. // Stash source.
if (debug_info) { if (debug_info) {

View File

@ -31,6 +31,7 @@ public:
~PPCTranslator(); ~PPCTranslator();
int Translate(runtime::FunctionInfo* symbol_info, int Translate(runtime::FunctionInfo* symbol_info,
bool with_debug_info,
runtime::Function** out_function); runtime::Function** out_function);
private: private:

View File

@ -225,7 +225,7 @@ int Runtime::DemandFunction(
if (symbol_status == SymbolInfo::STATUS_NEW) { if (symbol_status == SymbolInfo::STATUS_NEW) {
// Symbol is undefined, so define now. // Symbol is undefined, so define now.
Function* function = NULL; Function* function = NULL;
int result = frontend_->DefineFunction(symbol_info, &function); int result = frontend_->DefineFunction(symbol_info, false, &function);
if (result) { if (result) {
symbol_info->set_status(SymbolInfo::STATUS_FAILED); symbol_info->set_status(SymbolInfo::STATUS_FAILED);
return result; return result;

View File

@ -2,6 +2,7 @@
{ {
'sources': [ 'sources': [
'alloy-private.h', 'alloy-private.h',
'alloy.cc',
'alloy.h', 'alloy.h',
'arena.cc', 'arena.cc',
'arena.h', 'arena.h',

View File

@ -230,7 +230,7 @@ json_t* Processor::OnDebugRequest(
// If we ever wanted absolute x64 addresses/etc we could // If we ever wanted absolute x64 addresses/etc we could
// use the x64 from the function in the symbol table. // use the x64 from the function in the symbol table.
Function* fn; Function* fn;
if (runtime_->frontend()->DefineFunction(info, &fn)) { if (runtime_->frontend()->DefineFunction(info, true, &fn)) {
succeeded = false; succeeded = false;
return json_string("Unable to resolve function"); return json_string("Unable to resolve function");
} }