// log-readable.cpp // A simple utility which makes the runtime log files into a more readable // format by adding commented code lines from wozmon. #include #include #include #include #include using namespace std; int main() { ifstream RomLine ("rom-hex-positions"); ifstream Code ("rom-code-lines"); map Convert; string x; string y; for (int i = 0; i < 128; i++) { getline (RomLine, x); getline (Code, y, (char)0x0d); if (i != 0) y.erase(0,1); Convert[x] = y; cout << x << " : " << Convert[x] << endl; } RomLine.close(); Code.close(); ifstream Log("log.raw"); ofstream Output("log.new"); Output << "Time PC Label Instruction Comment\n" << endl; while(!Log.eof()) { string t; // Expects time counter, and prints. Log >> t; Output << t; // Expecting a delimiter surrounded with space. Log >> t; Output << " : "; // Expecting program counter Log >> t; Output << t; // If a mapping exists, print out the program counter and line code. try { string s = Convert[t]; Output << t << " : "; Output << s; } // Otherwise, don't do anything. catch (out_of_range) { } // Newline Output << endl; } Log.close(); Output.close(); return 0; }