Tracerestrict: Improve program validator

Check all instruction subtypes and valid enum values
Return failure instead of asserting for invalid instruction subtypes
Identify which instruction triggered validation failure
This commit is contained in:
Jonathan G Rennison
2023-03-09 03:01:20 +00:00
parent 5b788dcb97
commit f13f8cd740
2 changed files with 293 additions and 19 deletions

View File

@@ -77,12 +77,12 @@ static void Load_TRRP()
char str[4096];
char *strend = str + seprintf(str, lastof(str), "Trace restrict program %d: %s\nProgram dump:",
index, GetStringPtr(validation_result.GetErrorMessage()));
for (unsigned int i = 0; i < prog->items.size(); i++) {
if (i % 3) {
strend += seprintf(strend, lastof(str), " %08X", prog->items[i]);
} else {
strend += seprintf(strend, lastof(str), "\n%4u: %08X", i, prog->items[i]);
uint fail_offset = validation_result.GetResultData() ^ (1 << 31);
for (uint i = 0; i < (uint)prog->items.size(); i++) {
if ((i % 3) == 0) {
strend += seprintf(strend, lastof(str), "\n%4u:", i);
}
strend += seprintf(strend, lastof(str), (i == fail_offset) ? " [%08X]" : " %08X", prog->items[i]);
}
SlErrorCorrupt(str);
}