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 <gflags/gflags.h>
DECLARE_bool(debug);
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(
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:

View File

@ -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;
}

View File

@ -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:

View File

@ -9,6 +9,7 @@
#include <alloy/frontend/ppc/ppc_translator.h>
#include <alloy/alloy-private.h>
#include <alloy/compiler/passes.h>
#include <alloy/frontend/tracing.h>
#include <alloy/frontend/ppc/ppc_frontend.h>
@ -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) {

View File

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

View File

@ -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;

View File

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

View File

@ -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");
}