radv: add radv_dump_cmd() helper
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7233>
This commit is contained in:
parent
bf66bbda80
commit
18477241c1
|
@ -485,21 +485,25 @@ radv_dump_queue_state(struct radv_queue *queue, FILE *f)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
radv_dump_dmesg(FILE *f)
|
radv_dump_cmd(const char *cmd, FILE *f)
|
||||||
{
|
{
|
||||||
char line[2000];
|
char line[2048];
|
||||||
FILE *p;
|
FILE *p;
|
||||||
|
|
||||||
p = popen("dmesg | tail -n60", "r");
|
p = popen(cmd, "r");
|
||||||
if (!p)
|
if (p) {
|
||||||
return;
|
while (fgets(line, sizeof(line), p))
|
||||||
|
fputs(line, f);
|
||||||
|
fprintf(f, "\n");
|
||||||
|
pclose(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
radv_dump_dmesg(FILE *f)
|
||||||
|
{
|
||||||
fprintf(f, "\nLast 60 lines of dmesg:\n\n");
|
fprintf(f, "\nLast 60 lines of dmesg:\n\n");
|
||||||
while (fgets(line, sizeof(line), p))
|
radv_dump_cmd("dmesg | tail -n60", f);
|
||||||
fputs(line, f);
|
|
||||||
fprintf(f, "\n");
|
|
||||||
|
|
||||||
pclose(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -602,8 +606,7 @@ void
|
||||||
radv_print_spirv(const char *data, uint32_t size, FILE *fp)
|
radv_print_spirv(const char *data, uint32_t size, FILE *fp)
|
||||||
{
|
{
|
||||||
char path[] = "/tmp/fileXXXXXX";
|
char path[] = "/tmp/fileXXXXXX";
|
||||||
char line[2048], command[128];
|
char command[128];
|
||||||
FILE *p;
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
/* Dump the binary into a temporary file. */
|
/* Dump the binary into a temporary file. */
|
||||||
|
@ -614,15 +617,9 @@ radv_print_spirv(const char *data, uint32_t size, FILE *fp)
|
||||||
if (write(fd, data, size) == -1)
|
if (write(fd, data, size) == -1)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
sprintf(command, "spirv-dis %s", path);
|
|
||||||
|
|
||||||
/* Disassemble using spirv-dis if installed. */
|
/* Disassemble using spirv-dis if installed. */
|
||||||
p = popen(command, "r");
|
sprintf(command, "spirv-dis %s", path);
|
||||||
if (p) {
|
radv_dump_cmd(command, fp);
|
||||||
while (fgets(line, sizeof(line), p))
|
|
||||||
fprintf(fp, "%s", line);
|
|
||||||
pclose(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
Loading…
Reference in New Issue