[Mesa-dev] [PATCH 2/6] gallium/hud: add dump directory enviroment variable

Edmondo Tommasina edmondo.tommasina at gmail.com
Wed Dec 21 21:58:10 UTC 2016


Set GALLIUM_HUD_DUMP_DIR to dump values to files in this directory.

No values are dumped if the environment variable is not set, the
directory doesn't exist or the user doesn't have write access.
---
 src/gallium/auxiliary/hud/hud_driver_query.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c
index bfde16a..23fda01 100644
--- a/src/gallium/auxiliary/hud/hud_driver_query.c
+++ b/src/gallium/auxiliary/hud/hud_driver_query.c
@@ -351,6 +351,8 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq,
 {
    struct hud_graph *gr;
    struct query_info *info;
+   const char *hud_dump_dir = getenv("GALLIUM_HUD_DUMP_DIR");
+   char *dump_file;
 
    gr = CALLOC_STRUCT(hud_graph);
    if (!gr)
@@ -378,7 +380,15 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq,
       info->result_index = result_index;
    }
 
-   gr->fd = fopen(gr->name, "w+");
+   if (hud_dump_dir && access(hud_dump_dir, W_OK) == 0) {
+      dump_file = malloc(strlen(hud_dump_dir) + sizeof(gr->name));
+      if (dump_file) {
+         strcpy(dump_file, hud_dump_dir);
+         strcat(dump_file, gr->name);
+         gr->fd = fopen(dump_file, "w+");
+         free(dump_file);
+      }
+   }
 
    hud_pane_add_graph(pane, gr);
    pane->type = type; /* must be set before updating the max_value */
-- 
2.10.0



More information about the mesa-dev mailing list