diff --git a/bin/debugger.cpp b/bin/debugger.cpp index 4d1fb4a..44cf241 100644 --- a/bin/debugger.cpp +++ b/bin/debugger.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include @@ -54,6 +54,7 @@ #include #include +#include #include @@ -83,6 +84,8 @@ namespace { std::map GlobalTable; std::map TrapTable; + std::unordered_multimap ErrorTableInvert; + struct BackTraceInfo { uint32_t a[8]; @@ -1058,7 +1061,6 @@ void Info(uint32_t address) } -#if 0 // 4 as an error // almost all are negative 16-bit values, // but may also be a positive 16-bit value. @@ -1068,10 +1070,21 @@ void Info(uint32_t address) if (error) { const char *cp = ErrorName(error); - if (cp) - printf("Error: %s\n", cp); + + + + // find returns an iterator to the hash bucket, which may contain + // other errors. + auto range = ErrorTableInvert.equal_range(error); + + for(auto iter = range.first; iter != range.second; ++iter) { + + printf("Error: %s", iter->second.c_str()); + if (cp) printf(" %s", cp); + printf("\n"); + cp = nullptr; + } } -#endif } namespace { @@ -1192,6 +1205,12 @@ void Shell() LoadTrapFile(MPW::RootDirPathForFile("Globals.text"), GlobalTable); LoadTrapFile(MPW::RootDirPathForFile("Traps.text"), TrapTable); + + // load the error code to error mnemonic + for (const auto kv : ErrorTable) { + ErrorTableInvert.emplace(std::make_pair(kv.second, kv.first)); + } + // start it up printf("MPW Debugger shell\n\n"); disasm(cpuGetPC());