intel/tools/error: Do ascii85 decode first.

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>
This commit is contained in:
Kenneth Graunke 2017-11-11 20:57:42 -08:00
parent 8f9d9ddcae
commit 53586f88d7
1 changed files with 29 additions and 31 deletions

View 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;