intel/mda: Add MDA_FILTER to select which archives to generate

Matches if names contains the filter value, multiple values separated by
commas.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
This commit is contained in:
Caio Oliveira 2025-09-19 15:19:08 -07:00
parent 34198545aa
commit f00fca998e
4 changed files with 46 additions and 3 deletions

View file

@ -896,6 +896,11 @@ Intel driver environment variables
Prefix added to the mda.tar filenames generated when using INTEL_DEBUG=mda.
If set to ``timestamp`` it will generate the current time/date as prefix.
.. envvar:: MDA_FILTER
When set, will only generate mda.tar files which names contain any of the
comma-separated filter values as substrings.
Anvil(ANV) driver environment variables
---------------------------------------

View file

@ -1858,8 +1858,10 @@ iris_debug_archiver_open(void *tmp_ctx, struct iris_screen *screen,
debug_archiver *debug_archiver =
debug_archiver_open(tmp_ctx, name, PACKAGE_VERSION MESA_GIT_SHA1);
debug_archiver_set_prefix(debug_archiver,
_mesa_shader_stage_to_abbrev(ish->nir->info.stage));
if (debug_archiver) {
debug_archiver_set_prefix(debug_archiver,
_mesa_shader_stage_to_abbrev(ish->nir->info.stage));
}
return debug_archiver;
}

View file

@ -5,6 +5,7 @@
#include "debug_archiver.h"
#include "slice.h"
#include "tar.h"
#include "util/ralloc.h"
#include "util/u_debug.h"
@ -26,6 +27,7 @@ struct debug_archiver
DEBUG_GET_ONCE_OPTION(mda_output_dir, "MDA_OUTPUT_DIR", ".")
DEBUG_GET_ONCE_OPTION(mda_prefix, "MDA_PREFIX", NULL)
DEBUG_GET_ONCE_OPTION(mda_filter, "MDA_FILTER", NULL)
static bool
ensure_output_dir(const char *dir)
@ -40,9 +42,38 @@ ensure_output_dir(const char *dir)
return mkdir(dir, 0755) == 0;
}
static bool
debug_archiver_should_create(const char *name_str)
{
const char *filter_str = debug_get_option_mda_filter();
if (filter_str && *filter_str) {
slice filter = slice_from_cstr(filter_str);
slice name = slice_from_cstr(name_str);
while (!slice_is_empty(filter)) {
slice_cut_result cut = slice_cut(filter, ',');
slice pattern = cut.before;
if (!slice_is_empty(pattern) &&
slice_contains_str(name, pattern))
return true;
filter = cut.after;
}
/* MDA_FILTER exist but did not match, don't create. */
return false;
}
return true;
}
debug_archiver *
debug_archiver_open(void *mem_ctx, const char *name, const char *info)
{
if (!debug_archiver_should_create(name))
return NULL;
debug_archiver *da = rzalloc(mem_ctx, debug_archiver);
char *filename = ralloc_asprintf(mem_ctx, "%s.mda.tar", name);
@ -117,6 +148,9 @@ debug_archiver_open(void *mem_ctx, const char *name, const char *info)
void
debug_archiver_set_prefix(debug_archiver *da, const char *prefix)
{
if (!da)
return;
if (!prefix || !*prefix) {
snprintf(da->prefix, ARRAY_SIZE(da->prefix) - 1, "%s", da->mda_dir_in_archive);
} else {

View file

@ -1690,8 +1690,10 @@ anv_debug_archiver_init(void *mem_ctx, struct anv_shader_data *shaders_data,
shader_data->archiver =
debug_archiver_open(mem_ctx, name, PACKAGE_VERSION MESA_GIT_SHA1);
debug_archiver_set_prefix(shader_data->archiver,
if (shader_data->archiver) {
debug_archiver_set_prefix(shader_data->archiver,
_mesa_shader_stage_to_abbrev(info->stage));
}
}
}