summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_log.h
blob: d4e6018c9f700ea6546a26e6150e923665338d2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * Copyright 2017 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * on the rights to use, copy, modify, merge, publish, distribute, sub
 * license, and/or sell copies of the Software, and to permit persons to whom
 * the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/**
 * @file u_log.h
 * @brief Context logging facilities
 *
 * Provides a means of logging context events (draw calls, command streams, ...)
 * into files.
 *
 * Log entries start their life cycle as "chunks". Chunks can be plain text
 * written by \ref u_log_printf or custom internal representations added by
 * \ref u_log_chunk that are only converted to text on-demand (e.g. for higher
 * performance pipelined hang-debugging).
 *
 * Chunks are accumulated into "pages". The manager of the log can periodically
 * take out the current page using \ref u_log_new_page and dump it to a file.
 */

#ifndef U_LOG_H
#define U_LOG_H

#include <stdio.h>

#include "u_debug.h"

struct u_log_page;

struct u_log_chunk_type {
   void (*destroy)(void *data);
   void (*print)(void *data, FILE *stream);
};

struct u_log_context {
   struct u_log_page *cur;
};

void
u_log_context_init(struct u_log_context *ctx);

void
u_log_context_destroy(struct u_log_context *ctx);

void
u_log_printf(struct u_log_context *ctx, const char *fmt, ...) _util_printf_format(2,3);

void
u_log_chunk(struct u_log_context *ctx, const struct u_log_chunk_type *type,
            void *data);

void
u_log_new_page_print(struct u_log_context *ctx, FILE *stream);

struct u_log_page *
u_log_new_page(struct u_log_context *ctx);

void
u_log_page_destroy(struct u_log_page *page);

void
u_log_page_print(struct u_log_page *page, FILE *stream);

#endif /* U_LOG_H */