Removing JSON dumps.

This commit is contained in:
Ben Vanik 2014-01-23 00:00:59 -08:00
parent f93a21884c
commit f36e6cd820
5 changed files with 3 additions and 82 deletions

View File

@ -86,12 +86,6 @@ int PPCTranslator::Translate(
DumpSource(symbol_info, &string_buffer_);
debug_info->set_source_disasm(string_buffer_.ToString());
string_buffer_.Reset();
if (debug_info_flags & DEBUG_INFO_JSON) {
DumpSourceJson(symbol_info, &string_buffer_);
debug_info->set_source_json(string_buffer_.ToString());
string_buffer_.Reset();
}
}
// Emit function.
@ -181,68 +175,3 @@ void PPCTranslator::DumpSource(
string_buffer->Append("\n");
}
}
void PPCTranslator::DumpSourceJson(
runtime::FunctionInfo* symbol_info, StringBuffer* string_buffer) {
Memory* memory = frontend_->memory();
const uint8_t* p = memory->membase();
string_buffer->Append("{\n");
auto blocks = scanner_->FindBlocks(symbol_info);
string_buffer->Append("\"blocks\": [\n");
for (auto it = blocks.begin(); it != blocks.end(); ++it) {
string_buffer->Append("{ \"start\": %u, \"end\": %u }%c",
it->start_address, it->end_address,
(it + 1 != blocks.end()) ? ',' : ' ');
}
string_buffer->Append("],\n");
string_buffer->Append("\"lines\": [\n");
uint64_t start_address = symbol_info->address();
uint64_t end_address = symbol_info->end_address();
InstrData i;
auto block_it = blocks.begin();
for (uint64_t address = start_address, offset = 0; address <= end_address;
address += 4, offset++) {
i.address = address;
i.code = XEGETUINT32BE(p + address);
// TODO(benvanik): find a way to avoid using the opcode tables.
i.type = GetInstrType(i.code);
// Check labels.
if (block_it != blocks.end() &&
block_it->start_address == address) {
if (address != start_address) {
// Whitespace to pad blocks.
string_buffer->Append(
"[\"c\", %u, 0, \"\", \"\"],\n",
address);
}
string_buffer->Append(
"[\"l\", %u, 0, \"loc_%.8X:\", \"\"],\n",
address, address);
++block_it;
}
const char* disasm_str = "";
const char* comment_str = "";
std::string disasm;
if (!i.type) {
disasm_str = "?";
} else if (i.type->disassemble) {
ppc::InstrDisasm d;
i.type->disassemble(i, d);
d.Dump(disasm);
disasm_str = disasm.c_str();
} else {
disasm_str = i.type->name;
}
string_buffer->Append("[\"i\", %u, %u, \" %s\", \"%s\"]%c\n",
address, i.code, disasm_str, comment_str,
(address + 4 <= end_address) ? ',' : ' ');
}
string_buffer->Append("]\n");
string_buffer->Append("}\n");
}

View File

@ -37,8 +37,6 @@ public:
private:
void DumpSource(runtime::FunctionInfo* symbol_info,
StringBuffer* string_buffer);
void DumpSourceJson(runtime::FunctionInfo* symbol_info,
StringBuffer* string_buffer);
private:
PPCFrontend* frontend_;

View File

@ -14,7 +14,7 @@ using namespace alloy::runtime;
DebugInfo::DebugInfo() :
source_disasm_(0), source_json_(0),
source_disasm_(0),
raw_hir_disasm_(0),
hir_disasm_(0),
raw_lir_disasm_(0),
@ -24,7 +24,6 @@ DebugInfo::DebugInfo() :
DebugInfo::~DebugInfo() {
xe_free(source_disasm_);
xe_free(source_json_);
xe_free(raw_hir_disasm_);
xe_free(hir_disasm_);
xe_free(raw_lir_disasm_);

View File

@ -28,8 +28,6 @@ enum DebugInfoFlags {
DEBUG_INFO_MACHINE_CODE_DISASM = (1 << 6),
DEBUG_INFO_ALL_DISASM = 0xFFFF,
DEBUG_INFO_JSON = (1 << 16),
};
@ -40,8 +38,6 @@ public:
const char* source_disasm() const { return source_disasm_; }
void set_source_disasm(char* value) { source_disasm_ = value; }
const char* source_json() const { return source_json_; }
void set_source_json(char* value) { source_json_ = value; }
const char* raw_hir_disasm() const { return raw_hir_disasm_; }
void set_raw_hir_disasm(char* value) { raw_hir_disasm_ = value; }
const char* hir_disasm() const { return hir_disasm_; }
@ -60,7 +56,6 @@ public:
private:
char* source_disasm_;
char* source_json_;
char* raw_hir_disasm_;
char* hir_disasm_;
char* raw_lir_disasm_;

View File

@ -669,7 +669,7 @@ json_t* Processor::DumpFunction(uint64_t address, bool& succeeded) {
// use the x64 from the function in the symbol table.
Function* fn;
if (runtime_->frontend()->DefineFunction(
info, DEBUG_INFO_ALL_DISASM | DEBUG_INFO_JSON, &fn)) {
info, DEBUG_INFO_ALL_DISASM, &fn)) {
succeeded = false;
return json_string("Unable to resolve function");
}
@ -698,7 +698,7 @@ json_t* Processor::DumpFunction(uint64_t address, bool& succeeded) {
json_t* disasm_json = json_object();
json_t* disasm_str_json;
disasm_str_json = json_loads(debug_info->source_json(), 0, NULL);
disasm_str_json = json_loads(debug_info->source_disasm(), 0, NULL);
json_object_set_new(disasm_json, "source", disasm_str_json);
disasm_str_json = json_string(debug_info->raw_hir_disasm());
json_object_set_new(disasm_json, "rawHir", disasm_str_json);