intel/tools/error: Do ascii85 decode first.
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 12 Nov 2017 04:57:42 +0000 (20:57 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 14 Nov 2017 01:10:38 +0000 (17:10 -0800)
The dashes "---" may occur within an ascii85 block, but only an ascii85
block starts with ':' or '~'.

Ported from Chris Wilson's intel-gpu-tools commit:
bceec7e1d8a160226b783c6344eae8cbf4ece144

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
src/intel/tools/aubinator_error_decode.c

index 2322bac839157b72a094deb856d603cfd2818339..72919c1c9e4ae5e136f3e1b47e1265115a39a632 100644 (file)
@@ -507,6 +507,35 @@ read_data_file(FILE *file)
          ring_name = new_ring_name;
       }
 
+      if (line[0] == ':' || line[0] == '~') {
+         count = ascii85_decode(line+1, &data, line[0] == ':');
+         if (count == 0) {
+            fprintf(stderr, "ASCII85 decode failed.\n");
+            exit(EXIT_FAILURE);
+         }
+
+         if (strcmp(buffer_name, "user") == 0) {
+            printf("Disassembly of programs in instruction buffer at "
+                   "0x%08"PRIx64":\n", gtt_offset);
+            for (int i = 0; i < num_programs; i++) {
+               int idx = (idx_program + i) % MAX_NUM_PROGRAMS;
+               if (programs[idx].instruction_base_address == gtt_offset) {
+                    printf("\n%s (specified by %s at batch offset "
+                           "0x%08"PRIx64") at offset 0x%08"PRIx64"\n",
+                           programs[idx].type,
+                           programs[idx].command,
+                           programs[idx].command_offset,
+                           programs[idx].ksp);
+                    gen_disasm_disassemble(disasm, data, programs[idx].ksp,
+                                           stdout);
+               }
+            }
+         } else {
+            decode(spec, buffer_name, ring_name, gtt_offset, data, &count);
+         }
+         continue;
+      }
+
       dashes = strstr(line, "---");
       if (dashes) {
          uint32_t lo, hi;
@@ -590,37 +619,6 @@ read_data_file(FILE *file)
          }
       }
 
-      if (line[0] == ':' || line[0] == '~') {
-         count = ascii85_decode(line+1, &data, line[0] == ':');
-         if (count == 0) {
-            fprintf(stderr, "ASCII85 decode failed.\n");
-            exit(EXIT_FAILURE);
-         }
-
-         if (strcmp(buffer_name, "user") == 0) {
-            printf("Disassembly of programs in instruction buffer at "
-                   "0x%08"PRIx64":\n", gtt_offset);
-            for (int i = 0; i < num_programs; i++) {
-               int idx = (idx_program + i) % MAX_NUM_PROGRAMS;
-               if (programs[idx].instruction_base_address == gtt_offset) {
-                    printf("\n%s (specified by %s at batch offset "
-                           "0x%08"PRIx64") at offset 0x%08"PRIx64"\n",
-                           programs[idx].type,
-                           programs[idx].command,
-                           programs[idx].command_offset,
-                           programs[idx].ksp);
-                    gen_disasm_disassemble(disasm, data, programs[idx].ksp,
-                                           stdout);
-               }
-            }
-         } else {
-            decode(spec,
-                   buffer_name, ring_name,
-                   gtt_offset, data, &count);
-         }
-         continue;
-      }
-
       matched = sscanf(line, "%08x : %08x", &offset, &value);
       if (matched != 2) {
          uint32_t reg, reg2;