diff options
author | Stuart Bennett <sb476@cam.ac.uk> | 2007-12-08 03:16:10 +0000 |
---|---|---|
committer | Stuart Bennett <sb476@cam.ac.uk> | 2007-12-08 03:16:10 +0000 |
commit | d39ea39b9d062321e6216e0f8ca30f69bdcdabd4 (patch) | |
tree | 535b2b707d70a6c485dcbba873ab51d16e972e3d | |
parent | 84243710588674e2b21773d7f932156a43f483a6 (diff) |
Add an instruction sanity checker to deloopify
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | deloopify.c | 9 |
2 files changed, 9 insertions, 1 deletions
@@ -1,3 +1,4 @@ *.o vbtracetool *.a +deloopify diff --git a/deloopify.c b/deloopify.c index 99a8547..6405758 100644 --- a/deloopify.c +++ b/deloopify.c @@ -50,6 +50,7 @@ int main(int argc, char *argv[]) long inlineno = 0, outlineno = -1; char sig[MAX_LOOP_LEN][100]; char loopsig[] = "Loop"; + bool borken = false; char outname[1024]; strcpy(outname, argv[1]); @@ -72,10 +73,16 @@ int main(int argc, char *argv[]) inlineno += 1; outlineno += 1; + /* sanity check trace - every fourth line should be an instruction */ + if (!borken && !(inlineno % 4) && line[4] != ':') { + printf("Oh dear, an opcode seems to have broken at line %ld -- that's bad iff the input trace file is unmodified vbtracetool output\n", inlineno); + borken = true; + } + /* append line number of input file to instructions */ if (line[4] == ':') { int instrstrlen = strlen(line) - 1; - memset(&line[instrstrlen], 0x20, 100 - instrstrlen); + memset(&line[instrstrlen], 0x20, 64 - instrstrlen); sprintf(&line[58], " l%08ld\n", inlineno); } fwrite(line, strlen(line), 1, outf); |