pan/decode: Use common hexdump
Deduplicate the one I took from asahi. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Acked-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23088>
This commit is contained in:

committed by
Marge Bot

parent
e5867b0dca
commit
a15604e129
@@ -104,49 +104,6 @@ void pandecode_abort_on_fault_v9(mali_ptr jc_gpu_va);
|
||||
void pandecode_cs_v10(mali_ptr queue, uint32_t size, unsigned gpu_id,
|
||||
uint32_t *regs);
|
||||
|
||||
static inline void
|
||||
pan_hexdump(FILE *fp, const uint8_t *hex, size_t cnt, bool with_strings)
|
||||
{
|
||||
for (unsigned i = 0; i < cnt; ++i) {
|
||||
if ((i & 0xF) == 0)
|
||||
fprintf(fp, "%06X ", i);
|
||||
|
||||
uint8_t v = hex[i];
|
||||
|
||||
if (v == 0 && (i & 0xF) == 0) {
|
||||
/* Check if we're starting an aligned run of zeroes */
|
||||
unsigned zero_count = 0;
|
||||
|
||||
for (unsigned j = i; j < cnt; ++j) {
|
||||
if (hex[j] == 0)
|
||||
zero_count++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (zero_count >= 32) {
|
||||
fprintf(fp, "*\n");
|
||||
i += (zero_count & ~0xF) - 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(fp, "%02X ", hex[i]);
|
||||
if ((i & 0xF) == 0xF && with_strings) {
|
||||
fprintf(fp, " | ");
|
||||
for (unsigned j = i & ~0xF; j <= i; ++j) {
|
||||
uint8_t c = hex[j];
|
||||
fputc((c < 32 || c > 128) ? '.' : c, fp);
|
||||
}
|
||||
}
|
||||
|
||||
if ((i & 0xF) == 0xF)
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
/* Logging infrastructure */
|
||||
static void
|
||||
pandecode_make_indent(void)
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include "util/simple_mtx.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_dynarray.h"
|
||||
#include "util/u_hexdump.h"
|
||||
#include "decode.h"
|
||||
|
||||
#include "compiler/bifrost/disassemble.h"
|
||||
@@ -337,7 +338,7 @@ pandecode_dump_mappings(void)
|
||||
fprintf(pandecode_dump_stream, "Buffer: %s gpu %" PRIx64 "\n\n", it->name,
|
||||
it->gpu_va);
|
||||
|
||||
pan_hexdump(pandecode_dump_stream, it->addr, it->length, false);
|
||||
u_hexdump(pandecode_dump_stream, it->addr, it->length, false);
|
||||
fprintf(pandecode_dump_stream, "\n");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user