Tweaking output.

This commit is contained in:
Ben Vanik
2013-02-01 00:21:59 -08:00
parent 44b39c797b
commit b6a9dfe7e0
6 changed files with 110 additions and 13 deletions

View File

@@ -24,6 +24,8 @@ using namespace xe::cpu::sdb;
DEFINE_bool(memory_address_verification, false,
"Whether to add additional checks to generated memory load/stores.");
DEFINE_bool(log_codegen, false,
"Log codegen to stdout.");
/**
@@ -75,6 +77,10 @@ FunctionGenerator::FunctionGenerator(
for (size_t n = 0; n < XECOUNT(locals_.gpr); n++) {
locals_.gpr[n] = NULL;
}
if (FLAGS_log_codegen) {
printf("%s:\n", fn->name);
}
}
FunctionGenerator::~FunctionGenerator() {
@@ -269,7 +275,9 @@ void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block) {
BasicBlock* bb = GetBasicBlock(block->start_address);
XEASSERTNOTNULL(bb);
printf(" bb %.8X-%.8X:\n", block->start_address, block->end_address);
if (FLAGS_log_codegen) {
printf(" bb %.8X-%.8X:\n", block->start_address, block->end_address);
}
fn_block_ = block;
bb_ = bb;
@@ -311,14 +319,16 @@ void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block) {
continue;
}
if (i.type->disassemble) {
ppc::InstrDisasm d;
i.type->disassemble(i, d);
std::string disasm;
d.Dump(disasm);
printf(" %.8X: %.8X %s\n", ia, i.code, disasm.c_str());
} else {
printf(" %.8X: %.8X %s ???\n", ia, i.code, i.type->name);
if (FLAGS_log_codegen) {
if (i.type->disassemble) {
ppc::InstrDisasm d;
i.type->disassemble(i, d);
std::string disasm;
d.Dump(disasm);
printf(" %.8X: %.8X %s\n", ia, i.code, disasm.c_str());
} else {
printf(" %.8X: %.8X %s ???\n", ia, i.code, i.type->name);
}
}
// TODO(benvanik): debugging information? source/etc?

View File

@@ -301,8 +301,6 @@ void ModuleGenerator::PrepareFunction(FunctionSymbol* fn) {
void ModuleGenerator::BuildFunction(CodegenFunction* cgf) {
FunctionSymbol* fn = cgf->symbol;
printf("%s:\n", fn->name);
// Setup the generation context.
FunctionGenerator fgen(
memory_, sdb_, fn, context_, gen_module_, cgf->function);

View File

@@ -120,8 +120,11 @@ void* XModule::GetProcAddressByOrdinal(uint16_t ordinal) {
X_STATUS XModule::Launch(uint32_t flags) {
const xe_xex2_header_t* header = xex_header();
XELOGI(XT("Launching module..."));
// Set as the main module, while running.
kernel_state()->SetExecutableModule(this);
fflush(stdout);
// Create a thread to run in.
XThread* thread = new XThread(