[Mesa-dev] [PATCH 04/16] ddebug: add driver log to record dumps

Nicolai Hähnle nhaehnle at gmail.com
Wed Aug 16 11:05:34 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/gallium/drivers/ddebug/dd_context.c |  9 +++++++++
 src/gallium/drivers/ddebug/dd_draw.c    | 17 +++++++++++++++++
 src/gallium/drivers/ddebug/dd_pipe.h    |  4 ++++
 3 files changed, 30 insertions(+)

diff --git a/src/gallium/drivers/ddebug/dd_context.c b/src/gallium/drivers/ddebug/dd_context.c
index 5b0b27e006a..fc44a4bd1b9 100644
--- a/src/gallium/drivers/ddebug/dd_context.c
+++ b/src/gallium/drivers/ddebug/dd_context.c
@@ -583,6 +583,11 @@ dd_context_destroy(struct pipe_context *_pipe)
       pipe->transfer_unmap(pipe, dctx->fence_transfer);
       pipe_resource_reference(&dctx->fence, NULL);
    }
+
+   if (pipe->set_log_context)
+      pipe->set_log_context(pipe, NULL);
+   u_log_context_destroy(&dctx->log);
+
    pipe->destroy(pipe);
    FREE(dctx);
 }
@@ -899,6 +904,10 @@ dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
 
    dd_init_draw_functions(dctx);
 
+   u_log_context_init(&dctx->log);
+   if (pipe->set_log_context)
+      pipe->set_log_context(pipe, &dctx->log);
+
    dctx->draw_state.sample_mask = ~0;
 
    if (dscreen->mode == DD_DETECT_HANGS_PIPELINED) {
diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c
index ae8f99bf2b4..8a435a37fcb 100644
--- a/src/gallium/drivers/ddebug/dd_draw.c
+++ b/src/gallium/drivers/ddebug/dd_draw.c
@@ -561,6 +561,12 @@ dd_write_report(struct dd_context *dctx, struct dd_call *call, unsigned flags,
 
    dd_dump_call(f, &dctx->draw_state, call);
    dd_dump_driver_state(dctx, f, flags);
+
+   fprintf(f,"\n\n**************************************************"
+             "***************************\n");
+   fprintf(f, "Context Log:\n\n");
+   u_log_new_page_print(&dctx->log, f);
+
    if (dump_dmesg)
       dd_dump_dmesg(f);
    dd_close_file_stream(f);
@@ -936,6 +942,7 @@ dd_free_record(struct dd_draw_record **record)
 {
    struct dd_draw_record *next = (*record)->next;
 
+   u_log_page_destroy((*record)->log_page);
    dd_unreference_copy_of_call(&(*record)->call);
    dd_unreference_copy_of_draw_state(&(*record)->draw_state);
    FREE((*record)->driver_state_log);
@@ -960,6 +967,11 @@ dd_dump_record(struct dd_context *dctx, struct dd_draw_record *record,
    dd_dump_call(f, &record->draw_state.base, &record->call);
    fprintf(f, "%s\n", record->driver_state_log);
 
+   fprintf(f,"\n\n**************************************************"
+             "***************************\n");
+   fprintf(f, "Context Log:\n\n");
+   u_log_page_print(record->log_page, f);
+
    dctx->pipe->dump_debug_state(dctx->pipe, f,
                                 PIPE_DUMP_DEVICE_STATUS_REGISTERS);
    dd_dump_dmesg(f);
@@ -1101,6 +1113,7 @@ dd_pipelined_process_draw(struct dd_context *dctx, struct dd_call *call)
    record->timestamp = os_time_get();
    record->sequence_no = dctx->sequence_no;
    record->driver_state_log = log;
+   record->log_page = u_log_new_page(&dctx->log);
 
    memset(&record->call, 0, sizeof(record->call));
    dd_copy_call(&record->call, call);
@@ -1170,6 +1183,8 @@ dd_after_draw(struct dd_context *dctx, struct dd_call *call)
 
             /* Terminate the process to prevent future hangs. */
             dd_kill_process();
+         } else {
+            u_log_page_destroy(u_log_new_page(&dctx->log));
          }
          break;
       case DD_DETECT_HANGS_PIPELINED:
@@ -1193,6 +1208,8 @@ dd_after_draw(struct dd_context *dctx, struct dd_call *call)
                             false);
             /* No need to continue. */
             exit(0);
+         } else {
+            u_log_page_destroy(u_log_new_page(&dctx->log));
          }
          break;
       default:
diff --git a/src/gallium/drivers/ddebug/dd_pipe.h b/src/gallium/drivers/ddebug/dd_pipe.h
index e21b5fee086..f89f3820b43 100644
--- a/src/gallium/drivers/ddebug/dd_pipe.h
+++ b/src/gallium/drivers/ddebug/dd_pipe.h
@@ -33,6 +33,7 @@
 #include "pipe/p_screen.h"
 #include "dd_util.h"
 #include "os/os_thread.h"
+#include "util/u_log.h"
 
 enum dd_mode {
    DD_DETECT_HANGS,
@@ -224,6 +225,7 @@ struct dd_draw_record {
 
    struct dd_call call;
    struct dd_draw_state_copy draw_state;
+   struct u_log_page *log_page;
    char *driver_state_log;
 };
 
@@ -235,6 +237,8 @@ struct dd_context
    struct dd_draw_state draw_state;
    unsigned num_draw_calls;
 
+   struct u_log_context log;
+
    /* Pipelined hang detection.
     *
     * This is without unnecessary flushes and waits. There is a memory-based
-- 
2.11.0



More information about the mesa-dev mailing list