diff --git a/docs/envvars.rst b/docs/envvars.rst index 534a30ed1b6..3cb56c21e13 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -894,6 +894,7 @@ Intel driver environment variables .. envvar:: MDA_PREFIX 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. Anvil(ANV) driver environment variables --------------------------------------- diff --git a/src/intel/mda/debug_archiver.c b/src/intel/mda/debug_archiver.c index 206037f129b..42aa85a4115 100644 --- a/src/intel/mda/debug_archiver.c +++ b/src/intel/mda/debug_archiver.c @@ -12,6 +12,7 @@ #include #include #include +#include #include struct debug_archiver @@ -54,6 +55,21 @@ debug_archiver_open(void *mem_ctx, const char *name, const char *info) } if (prefix) { + if (!strcmp(prefix, "timestamp")) { + time_t now = time(NULL); + struct tm *tm_info = localtime(&now); + + if (tm_info) { + prefix = ralloc_asprintf(da, "%04d%02d%02d-%02d%02d%02d", + tm_info->tm_year + 1900, + tm_info->tm_mon + 1, + tm_info->tm_mday, + tm_info->tm_hour, + tm_info->tm_min, + tm_info->tm_sec); + } + } + /* Prefix shouldn't have any `/` characters. */ if (strchr(prefix, '/')) { char *safe_prefix = ralloc_strdup(da, prefix);