mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-11 01:46:14 +00:00
error-decode: Operate as a pipe and accept input from stdin
Useful for feeding in compressed files from bugzilla: $ bzcat /tmp/i915_error_state.bz | intel_error_decode | less Next step would be to use gzfopen or bzfopen to automagically handle compressed files... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
aa0a346deb
commit
a3a78632bd
@ -44,6 +44,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -209,9 +210,8 @@ print_pgtbl_err(unsigned int reg, unsigned int devid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
read_data_file (const char * filename)
|
read_data_file (FILE *file)
|
||||||
{
|
{
|
||||||
FILE *file;
|
|
||||||
int devid = PCI_CHIP_I855_GM;
|
int devid = PCI_CHIP_I855_GM;
|
||||||
uint32_t *data = NULL;
|
uint32_t *data = NULL;
|
||||||
int data_size = 0, count = 0, line_number = 0, matched;
|
int data_size = 0, count = 0, line_number = 0, matched;
|
||||||
@ -222,13 +222,6 @@ read_data_file (const char * filename)
|
|||||||
char *buffer_type[2] = { "ringbuffer", "batchbuffer" };
|
char *buffer_type[2] = { "ringbuffer", "batchbuffer" };
|
||||||
int is_batch = 1;
|
int is_batch = 1;
|
||||||
|
|
||||||
file = fopen (filename, "r");
|
|
||||||
if (file == NULL) {
|
|
||||||
fprintf (stderr, "Failed to open %s: %s\n",
|
|
||||||
filename, strerror (errno));
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (getline (&line, &line_size, file) > 0) {
|
while (getline (&line, &line_size, file) > 0) {
|
||||||
line_number++;
|
line_number++;
|
||||||
|
|
||||||
@ -306,14 +299,14 @@ read_data_file (const char * filename)
|
|||||||
|
|
||||||
free (data);
|
free (data);
|
||||||
free (line);
|
free (line);
|
||||||
|
|
||||||
fclose (file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
FILE *file;
|
||||||
const char *path;
|
const char *path;
|
||||||
|
char *filename;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@ -334,17 +327,22 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
path = "/debug/dri/0";
|
if (isatty(1)) {
|
||||||
err = stat (path, &st);
|
path = "/debug/dri/0";
|
||||||
if (err != 0) {
|
|
||||||
path = "/sys/kernel/debug/dri/0";
|
|
||||||
err = stat (path, &st);
|
err = stat (path, &st);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
errx(1,
|
path = "/sys/kernel/debug/dri/0";
|
||||||
"Couldn't find i915 debugfs directory.\n\n"
|
err = stat (path, &st);
|
||||||
"Is debugfs mounted? You might try mounting it with a command such as:\n\n"
|
if (err != 0) {
|
||||||
"\tsudo mount -t debugfs debugfs /sys/kernel/debug\n");
|
errx(1,
|
||||||
|
"Couldn't find i915 debugfs directory.\n\n"
|
||||||
|
"Is debugfs mounted? You might try mounting it with a command such as:\n\n"
|
||||||
|
"\tsudo mount -t debugfs debugfs /sys/kernel/debug\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
read_data_file(stdin);
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
path = argv[1];
|
path = argv[1];
|
||||||
@ -356,15 +354,23 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISDIR (st.st_mode)) {
|
if (S_ISDIR (st.st_mode))
|
||||||
char *filename;
|
|
||||||
|
|
||||||
asprintf (&filename, "%s/i915_error_state", path);
|
asprintf (&filename, "%s/i915_error_state", path);
|
||||||
read_data_file (filename);
|
else
|
||||||
free (filename);
|
filename = (char *) path;
|
||||||
|
|
||||||
|
file = fopen(filename, "r");
|
||||||
|
if (file) {
|
||||||
|
read_data_file (file);
|
||||||
|
fclose (file);
|
||||||
} else {
|
} else {
|
||||||
read_data_file (path);
|
fprintf (stderr, "Failed to open %s: %s\n",
|
||||||
|
filename, strerror (errno));
|
||||||
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filename != path)
|
||||||
|
free (filename);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user