mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 10:50:10 +01:00
intel/mda: Add MDA_OUTPUT_DIR and MDA_PREFIX environment variable support
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:
parent
dfdc883833
commit
c21494576e
3 changed files with 61 additions and 1 deletions
|
|
@ -886,6 +886,15 @@ Intel driver environment variables
|
|||
If none of widths for particular shader stage was specified, then all
|
||||
widths are allowed.
|
||||
|
||||
.. envvar:: MDA_OUTPUT_DIR
|
||||
|
||||
Directory where the mda.tar files generated when using INTEL_DEBUG=mda are
|
||||
going to be written to. If not set, use the current directory.
|
||||
|
||||
.. envvar:: MDA_PREFIX
|
||||
|
||||
Prefix added to the mda.tar filenames generated when using INTEL_DEBUG=mda.
|
||||
|
||||
Anvil(ANV) driver environment variables
|
||||
---------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -7,23 +7,71 @@
|
|||
|
||||
#include "tar.h"
|
||||
#include "util/ralloc.h"
|
||||
#include "util/u_debug.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct debug_archiver
|
||||
{
|
||||
FILE *f;
|
||||
tar_writer *tw;
|
||||
char prefix[128];
|
||||
char *archive_path;
|
||||
};
|
||||
|
||||
DEBUG_GET_ONCE_OPTION(mda_output_dir, "MDA_OUTPUT_DIR", ".")
|
||||
DEBUG_GET_ONCE_OPTION(mda_prefix, "MDA_PREFIX", NULL)
|
||||
|
||||
static bool
|
||||
ensure_output_dir(const char *dir)
|
||||
{
|
||||
if (!dir || !*dir || !strcmp(dir, "."))
|
||||
return true;
|
||||
|
||||
struct stat st;
|
||||
if (stat(dir, &st) == 0)
|
||||
return S_ISDIR(st.st_mode);
|
||||
|
||||
return mkdir(dir, 0755) == 0;
|
||||
}
|
||||
|
||||
debug_archiver *
|
||||
debug_archiver_open(void *mem_ctx, const char *name, const char *info)
|
||||
{
|
||||
debug_archiver *da = rzalloc(mem_ctx, debug_archiver);
|
||||
|
||||
char *filename = ralloc_asprintf(mem_ctx, "%s.mda.tar", name);
|
||||
da->f = fopen(filename, "wb+");
|
||||
|
||||
const char *output_dir = debug_get_option_mda_output_dir();
|
||||
const char *prefix = debug_get_option_mda_prefix();
|
||||
|
||||
if (!ensure_output_dir(output_dir)) {
|
||||
/* Fallback to current directory on failure. */
|
||||
output_dir = ".";
|
||||
}
|
||||
|
||||
if (prefix) {
|
||||
/* Prefix shouldn't have any `/` characters. */
|
||||
if (strchr(prefix, '/')) {
|
||||
char *safe_prefix = ralloc_strdup(da, prefix);
|
||||
for (char *p = safe_prefix; *p; p++) {
|
||||
if (*p == '/')
|
||||
*p = '_';
|
||||
}
|
||||
prefix = safe_prefix;
|
||||
}
|
||||
}
|
||||
|
||||
da->archive_path = ralloc_asprintf(da, "%s/%s%s%s",
|
||||
output_dir,
|
||||
prefix ? prefix : "",
|
||||
prefix ? "." : "",
|
||||
filename);
|
||||
|
||||
da->f = fopen(da->archive_path, "wb+");
|
||||
|
||||
da->tw = rzalloc(da, tar_writer);
|
||||
tar_writer_init(da->tw, da->f);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ _libmda = static_library(
|
|||
'tar.h',
|
||||
'tar.c',
|
||||
],
|
||||
dependencies: [
|
||||
idep_mesautil
|
||||
],
|
||||
include_directories: [inc_src],
|
||||
c_args: [c_msvc_compat_args],
|
||||
gnu_symbol_visibility: 'hidden',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue