mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 22:38:05 +02:00
intel/tools/error_decode: Add function to try to open error dump file
Just to simply a bit open_error_state_file(). Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27728>
This commit is contained in:
parent
7cd677c491
commit
70e2384f8f
1 changed files with 21 additions and 12 deletions
|
|
@ -823,6 +823,25 @@ print_help(const char *progname, FILE *file)
|
|||
progname);
|
||||
}
|
||||
|
||||
static FILE *
|
||||
try_open_file(const char *format, ...)
|
||||
{
|
||||
ASSERTED int ret;
|
||||
char *filename;
|
||||
FILE *file;
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
ret = vasprintf(&filename, format, args);
|
||||
va_end(args);
|
||||
|
||||
assert(ret > 0);
|
||||
file = fopen(filename, "r");
|
||||
free(filename);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
static FILE *
|
||||
open_error_state_file(const char *path)
|
||||
{
|
||||
|
|
@ -833,21 +852,11 @@ open_error_state_file(const char *path)
|
|||
return NULL;
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
ASSERTED int ret;
|
||||
char *filename;
|
||||
|
||||
ret = asprintf(&filename, "%s/i915_error_state", path);
|
||||
assert(ret > 0);
|
||||
file = fopen(filename, "r");
|
||||
free(filename);
|
||||
file = try_open_file("%s/i915_error_state", path);
|
||||
if (!file) {
|
||||
int minor;
|
||||
for (minor = 0; minor < 64; minor++) {
|
||||
ret = asprintf(&filename, "%s/%d/i915_error_state", path, minor);
|
||||
assert(ret > 0);
|
||||
|
||||
file = fopen(filename, "r");
|
||||
free(filename);
|
||||
file = try_open_file("%s/%d/i915_error_state", path, minor);
|
||||
if (file)
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue