[Intel-gfx] [PATCH igt v2] tools/error_decode: Print ASCII user buffers
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Thu Nov 16 14:53:23 UTC 2017
On 16/11/2017 14:35, Chris Wilson wrote:
> 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 <chris at chris-wilson.co.uk>
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
> tools/intel_error_decode.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> 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 <assert.h>
> #include <intel_bufmgr.h>
> #include <zlib.h>
> +#include <ctype.h>
>
> #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",
>
My r-b on the previous version was one of the disappeared e-mails from
yesterday. Anyway, this is even better.
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Regards,
Tvrtko
More information about the Intel-gfx
mailing list