Module: Mesa
Branch: master
Commit: 18477241c1d84fb5cbef4285dced7c5900302290
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=18477241c1d84fb5cbef4285dced7c5900302290

Author: Samuel Pitoiset <samuel.pitoi...@gmail.com>
Date:   Mon Oct 19 16:38:13 2020 +0200

radv: add radv_dump_cmd() helper

Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7233>

---

 src/amd/vulkan/radv_debug.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/src/amd/vulkan/radv_debug.c b/src/amd/vulkan/radv_debug.c
index 0fe4ebc9b64..72e678d2b4d 100644
--- a/src/amd/vulkan/radv_debug.c
+++ b/src/amd/vulkan/radv_debug.c
@@ -485,21 +485,25 @@ radv_dump_queue_state(struct radv_queue *queue, FILE *f)
 }
 
 static void
-radv_dump_dmesg(FILE *f)
+radv_dump_cmd(const char *cmd, FILE *f)
 {
-       char line[2000];
+       char line[2048];
        FILE *p;
 
-       p = popen("dmesg | tail -n60", "r");
-       if (!p)
-               return;
+       p = popen(cmd, "r");
+       if (p) {
+               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");
-       while (fgets(line, sizeof(line), p))
-               fputs(line, f);
-       fprintf(f, "\n");
-
-       pclose(p);
+       radv_dump_cmd("dmesg | tail -n60", f);
 }
 
 void
@@ -602,8 +606,7 @@ void
 radv_print_spirv(const char *data, uint32_t size, FILE *fp)
 {
        char path[] = "/tmp/fileXXXXXX";
-       char line[2048], command[128];
-       FILE *p;
+       char command[128];
        int fd;
 
        /* 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)
                goto fail;
 
-       sprintf(command, "spirv-dis %s", path);
-
        /* Disassemble using spirv-dis if installed. */
-       p = popen(command, "r");
-       if (p) {
-               while (fgets(line, sizeof(line), p))
-                       fprintf(fp, "%s", line);
-               pclose(p);
-       }
+       sprintf(command, "spirv-dis %s", path);
+       radv_dump_cmd(command, fp);
 
 fail:
        close(fd);

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to