From 9fb5344bab2540e3d12a7d3a94c2a3801a6fec36 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 12 Nov 2017 11:46:37 +0000 Subject: tools/error_decode: Print ASCII user buffers Look at the first 16 characters of the user buffer and if they are all printable, assume that user buffer contains ASCII data (e.g. a debug log) that we want to simply print out. Otherwise, we treat it as a binary data and hexdump as before. Tvrtko: you know you could just write this as a printf (d'oh) Signed-off-by: Chris Wilson Reviewed-by: Tvrtko Ursulin --- tools/intel_error_decode.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tools') diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c index cdef3b18..8924026a 100644 --- a/tools/intel_error_decode.c +++ b/tools/intel_error_decode.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "intel_chipset.h" #include "intel_io.h" @@ -434,6 +435,16 @@ print_fault_data(unsigned devid, uint32_t data1, uint32_t data0) #define MAX_RINGS 10 /* I really hope this never... */ +static bool maybe_ascii(const void *data, int check) +{ + const char *c = data; + while (check--) { + if (!isprint(*c++)) + return false; + } + return true; +} + static void decode(struct drm_intel_decode *ctx, const char *buffer_name, const char *ring_name, @@ -458,6 +469,8 @@ static void decode(struct drm_intel_decode *ctx, drm_intel_decode_set_batch_pointer(ctx, data, gtt_offset, *count); drm_intel_decode(ctx); + } else if (maybe_ascii(data, 16)) { + printf("%*s\n", 4 * *count, (char *)data); } else { for (int i = 0; i + 4 <= *count; i += 4) printf("[%04x] %08x %08x %08x %08x\n", -- cgit v1.2.3