From ea0ec8c56284b1821711e5666571927489513b3e Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Wed, 22 Feb 2023 19:07:52 -0800 Subject: [PATCH] intel: Add extra zeros at the end of debug identifiers Add at least a full aligned uint64_t of zero padding at the end to make the identifiers easier to spot. Reviewed-by: Kenneth Graunke Part-of: --- src/intel/dev/intel_debug.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/intel/dev/intel_debug.c b/src/intel/dev/intel_debug.c index 7650a62956d..0c46c55d05c 100644 --- a/src/intel/dev/intel_debug.c +++ b/src/intel/dev/intel_debug.c @@ -37,6 +37,7 @@ #include "git_sha1.h" #include "util/macros.h" #include "util/u_debug.h" +#include "util/u_math.h" #include "c11/threads.h" uint64_t intel_debug = 0; @@ -286,6 +287,16 @@ intel_debug_write_identifiers(void *_output, assert(output < output_end); + /* Add at least a full aligned uint64_t of zero padding at the end + * to make the identifiers easier to spot. + */ + const unsigned unpadded_len = output - _output; + const unsigned padding = ALIGN(unpadded_len + 8, 8) - unpadded_len; + memset(output, 0, padding); + output += padding; + + assert(output < output_end); + /* Return the how many bytes where written, so that the rest of the buffer * can be used for other things. */