DECOMPILER: reassembler improved debugging

This commit is contained in:
Die4Ever
2022-12-20 00:49:23 -06:00
parent c187933e4e
commit d82948865d
2 changed files with 17 additions and 9 deletions
+5 -2
View File
@@ -435,8 +435,11 @@ void GroovieDisassembler::writeParameter(char type, std::vector<byte> &bytes, co
case '@': // Address
jumpAddrStart = bytes.size();
// if arg is in 0xF3DE format, convert to 0000f3de
if(arg.find("0x") == 0)
jumpToLabel = (boost::format("%08x") % std::stoul(arg, 0, 16)).str();
if(arg.find("0x") == 0) {
u32 = std::stoul(arg, 0, 16);
assert((boost::format("0x%X") % u32).str() == arg);
jumpToLabel = (boost::format("%08x") % u32).str();
}
else
jumpToLabel = arg;
bytes.push_back(0);
+12 -7
View File
@@ -55,7 +55,7 @@ void Reassembler::assemble() {
args.push_back(line.substr(s, len));
std::cout << args.back();
}
std::cout << "; " << comment << "\n";
std::cout << "; " << comment << " (" << (boost::format("0x%X") % _binary.size()) << ")\n";
// TODO: maybe parse the arguments into a ValueList of the Value subclasses
doAssembly(label, instruction, args, comment);
@@ -66,7 +66,13 @@ void Reassembler::assemble() {
if(j._label.empty())
continue;
size_t addr = _labels.at(j._label);
size_t addr = 0;
try {
addr = _labels.at(j._label);
} catch(...) {
std::cout << "\nfailed rewriting jump to " << j._label << ", from (" << j.start << ", " << j.len << ")\n";
throw;
}
uint16 u16;
uint32 u32;
@@ -103,11 +109,10 @@ std::string Reassembler::readLine() {
std::string line;
try {
while(!_f.eos()) {
char c = _f.readByte();
if(c == '\n')
break;
line += c;
char c = _f.readByte();
if(c == '\n')
break;
line += c;
}
} catch(Common::FileException &e) {
}