From ff66064275fd7fa6ad41874623489de7c682c7f6 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 6 Jan 2014 22:46:21 -0800 Subject: [PATCH] Making --debug = false work. --- src/alloy/alloy.cc | 2 +- src/alloy/frontend/ppc/ppc_hir_builder.cc | 23 +++++++++++------------ src/alloy/frontend/ppc/ppc_hir_builder.h | 3 ++- src/alloy/frontend/ppc/ppc_translator.cc | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/alloy/alloy.cc b/src/alloy/alloy.cc index 7453d2c6d..2d718b614 100644 --- a/src/alloy/alloy.cc +++ b/src/alloy/alloy.cc @@ -13,7 +13,7 @@ using namespace alloy; -#if DEBUG +#if 0 && DEBUG #define DEFAULT_DEBUG_FLAG true #else #define DEFAULT_DEBUG_FLAG false diff --git a/src/alloy/frontend/ppc/ppc_hir_builder.cc b/src/alloy/frontend/ppc/ppc_hir_builder.cc index e83675c84..3be8296c7 100644 --- a/src/alloy/frontend/ppc/ppc_hir_builder.cc +++ b/src/alloy/frontend/ppc/ppc_hir_builder.cc @@ -35,12 +35,11 @@ void PPCHIRBuilder::Reset() { start_address_ = 0; instr_offset_list_ = NULL; label_list_ = NULL; + with_debug_info_ = false; HIRBuilder::Reset(); } -const bool FLAGS_annotate_disassembly = true; - -int PPCHIRBuilder::Emit(FunctionInfo* symbol_info) { +int PPCHIRBuilder::Emit(FunctionInfo* symbol_info, bool with_debug_info) { Memory* memory = frontend_->memory(); const uint8_t* p = memory->membase(); @@ -49,10 +48,13 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info) { instr_count_ = (symbol_info->end_address() - symbol_info->address()) / 4 + 1; - Comment("%s fn %.8X-%.8X %s", - symbol_info->module()->name(), - symbol_info->address(), symbol_info->end_address(), - symbol_info->name()); + with_debug_info_ = with_debug_info; + if (with_debug_info_) { + Comment("%s fn %.8X-%.8X %s", + symbol_info->module()->name(), + symbol_info->address(), symbol_info->end_address(), + symbol_info->name()); + } // Allocate offset list. // This is used to quickly map labels to instructions. @@ -90,7 +92,7 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info) { } Instr* first_instr = 0; - if (FLAGS_annotate_disassembly) { + if (with_debug_info_) { if (label) { AnnotateLabel(address, label); } @@ -139,9 +141,6 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info) { Comment("UNIMPLEMENTED!"); //DebugBreak(); //TraceInvalidInstruction(i); - - // This printf is handy for sort/uniquify to find instructions. - printf("unimplinstr %s\n", i.type->name); } } @@ -192,7 +191,7 @@ Label* PPCHIRBuilder::LookupLabel(uint64_t address) { } // Annotate the label, as we won't do it later. - if (FLAGS_annotate_disassembly) { + if (with_debug_info_) { AnnotateLabel(address, label); } } diff --git a/src/alloy/frontend/ppc/ppc_hir_builder.h b/src/alloy/frontend/ppc/ppc_hir_builder.h index 6b85b8c1a..ba9b6c4da 100644 --- a/src/alloy/frontend/ppc/ppc_hir_builder.h +++ b/src/alloy/frontend/ppc/ppc_hir_builder.h @@ -33,7 +33,7 @@ public: virtual void Reset(); - int Emit(runtime::FunctionInfo* symbol_info); + int Emit(runtime::FunctionInfo* symbol_info, bool with_debug_info); runtime::FunctionInfo* LookupFunction(uint64_t address); Label* LookupLabel(uint64_t address); @@ -73,6 +73,7 @@ private: PPCFrontend* frontend_; // Reset each Emit: + bool with_debug_info_; runtime::FunctionInfo* symbol_info_; uint64_t start_address_; uint64_t instr_count_; diff --git a/src/alloy/frontend/ppc/ppc_translator.cc b/src/alloy/frontend/ppc/ppc_translator.cc index 5f4810049..c4121fb13 100644 --- a/src/alloy/frontend/ppc/ppc_translator.cc +++ b/src/alloy/frontend/ppc/ppc_translator.cc @@ -90,7 +90,7 @@ int PPCTranslator::Translate( } // Emit function. - int result = builder_->Emit(symbol_info); + int result = builder_->Emit(symbol_info, debug_info != NULL); XEEXPECTZERO(result); // Stash raw HIR.