diff options
author | Lionel Landwerlin <[email protected]> | 2019-12-24 02:40:26 +0200 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-05-20 15:58:22 +0000 |
commit | 805b32cab90547a576afba4a16b04603d355a4af (patch) | |
tree | b0fd054b8483957a397b5713889b582d53ad6a40 /src/intel | |
parent | e81de67d858ce2d6bde9f4c7b06a05ec3c1f4f2b (diff) |
intel: add identifier for debug purposes
Signed-off-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3203>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/Android.dev.mk | 7 | ||||
-rw-r--r-- | src/intel/dev/gen_debug.c | 96 | ||||
-rw-r--r-- | src/intel/dev/gen_debug.h | 36 |
3 files changed, 138 insertions, 1 deletions
diff --git a/src/intel/Android.dev.mk b/src/intel/Android.dev.mk index 4f14b0362d7..5c7ddd4d35e 100644 --- a/src/intel/Android.dev.mk +++ b/src/intel/Android.dev.mk @@ -29,7 +29,12 @@ LOCAL_MODULE := libmesa_intel_dev LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_C_INCLUDES := $(MESA_TOP)/include +LOCAL_STATIC_LIBRARIES := \ + libmesa_git_sha1 + +LOCAL_C_INCLUDES := \ + $(MESA_TOP)/include \ + $(MESA_TOP)/src LOCAL_SRC_FILES := $(DEV_FILES) diff --git a/src/intel/dev/gen_debug.c b/src/intel/dev/gen_debug.c index 4e610dc4169..d8651390c47 100644 --- a/src/intel/dev/gen_debug.c +++ b/src/intel/dev/gen_debug.c @@ -29,9 +29,12 @@ * miscellaneous debugging code. */ +#include <stdio.h> #include <stdlib.h> +#include <string.h> #include "dev/gen_debug.h" +#include "git_sha1.h" #include "util/macros.h" #include "util/debug.h" #include "c11/threads.h" @@ -123,3 +126,96 @@ brw_process_intel_debug_variable(void) call_once(&process_intel_debug_variable_flag, brw_process_intel_debug_variable_once); } + +static uint64_t debug_identifier[4] = { + 0xffeeddccbbaa9988, + 0x7766554433221100, + 0xffeeddccbbaa9988, + 0x7766554433221100, +}; + +void * +intel_debug_identifier(void) +{ + return debug_identifier; +} + +uint32_t +intel_debug_identifier_size(void) +{ + return sizeof(debug_identifier); +} + +uint32_t +intel_debug_write_identifiers(void *_output, + uint32_t output_size, + const char *driver_name) +{ + void *output = _output, *output_end = _output + output_size; + + assert(output_size > intel_debug_identifier_size()); + + memcpy(output, intel_debug_identifier(), intel_debug_identifier_size()); + output += intel_debug_identifier_size(); + + for (uint32_t id = GEN_DEBUG_BLOCK_TYPE_DRIVER; id < GEN_DEBUG_BLOCK_TYPE_MAX; id++) { + switch (id) { + case GEN_DEBUG_BLOCK_TYPE_DRIVER: { + struct gen_debug_block_driver driver_desc = { + .base = { + .type = id, + }, + }; + int len = snprintf(output + sizeof(driver_desc), + output_end - (output + sizeof(driver_desc)), + "%s " PACKAGE_VERSION " build " MESA_GIT_SHA1, + driver_name); + driver_desc.base.length = sizeof(driver_desc) + len + 1; + memcpy(output, &driver_desc, sizeof(driver_desc)); + output += driver_desc.base.length; + break; + } + + default: + unreachable("Missing identifier write"); + } + + assert(output < output_end); + } + + struct gen_debug_block_base end = { + .type = GEN_DEBUG_BLOCK_TYPE_END, + .length = sizeof(end), + }; + memcpy(output, &end, sizeof(end)); + output += sizeof(end); + + assert(output < output_end); + + /* Return the how many bytes where written, so that the rest of the buffer + * can be used for other things. + */ + return output - _output; +} + +void * +intel_debug_get_identifier_block(void *_buffer, + uint32_t buffer_size, + enum gen_debug_block_type type) +{ + void *buffer = _buffer + intel_debug_identifier_size(), + *end_buffer = _buffer + buffer_size; + + while (buffer < end_buffer) { + struct gen_debug_block_base *item = buffer; + + if (item->type == type) + return item; + if (item->type == GEN_DEBUG_BLOCK_TYPE_END) + return NULL; + + buffer += item->length; + } + + return NULL; +} diff --git a/src/intel/dev/gen_debug.h b/src/intel/dev/gen_debug.h index aff96ae3fa2..687bedb1a42 100644 --- a/src/intel/dev/gen_debug.h +++ b/src/intel/dev/gen_debug.h @@ -123,6 +123,42 @@ extern uint64_t intel_debug_flag_for_shader_stage(gl_shader_stage stage); extern void brw_process_intel_debug_variable(void); +/* Below is a list of structure located in the identifier buffer. The driver + * can fill those in for debug purposes. + */ + +enum gen_debug_block_type { + /* End of the debug blocks */ + GEN_DEBUG_BLOCK_TYPE_END = 1, + + /* Driver identifier (struct gen_debug_block_driver) */ + GEN_DEBUG_BLOCK_TYPE_DRIVER, + + /* Internal, never to be written out */ + GEN_DEBUG_BLOCK_TYPE_MAX, +}; + +struct gen_debug_block_base { + uint32_t type; /* enum gen_debug_block_type */ + uint32_t length; /* inclusive of this structure size */ +}; + +struct gen_debug_block_driver { + struct gen_debug_block_base base; + uint8_t description[]; +}; + +extern void *intel_debug_identifier(void); +extern uint32_t intel_debug_identifier_size(void); + +extern uint32_t intel_debug_write_identifiers(void *output, + uint32_t output_size, + const char *driver_name); + +extern void *intel_debug_get_identifier_block(void *buffer, + uint32_t buffer_size, + enum gen_debug_block_type type); + #ifdef __cplusplus } #endif |