• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2012 VMware, Inc.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 
28 /**
29  * @file
30  * u_debug_flush.h - Header for debugging flush- and map- related issues.
31  * - Flush while synchronously mapped.
32  * - Command stream reference while synchronously mapped.
33  * - Synchronous map while referenced on command stream.
34  * - Recursive maps.
35  * - Unmap while not mapped.
36  *
37  * @author Thomas Hellstrom <thellstrom@vmware.com>
38  */
39 #ifdef DEBUG
40 
41 #ifndef U_DEBUG_FLUSH_H_
42 #define U_DEBUG_FLUSH_H_
43 
44 struct debug_flush_buf;
45 struct debug_flush_ctx;
46 
47 /**
48  * Create a buffer (AKA allocation) representation.
49  *
50  * @param supports_persistent Whether persistent maps are truly supported.
51  * @param bt_depth Depth of backtrace to be captured for this buffer
52  * representation.
53  */
54 struct debug_flush_buf *
55 debug_flush_buf_create(boolean supports_persistent, unsigned bt_depth);
56 
57 /**
58  * Reference a buffer representation.
59  *
60  * @param dst Pointer copy destination
61  * @param src Pointer copy source (may be NULL).
62  *
63  * Replace a pointer to a buffer representation with proper refcounting.
64  */
65 void
66 debug_flush_buf_reference(struct debug_flush_buf **dst,
67                           struct debug_flush_buf *src);
68 
69 /**
70  * Create a context representation.
71  *
72  * @param catch_map_of_referenced Whether to catch synchronous maps of buffers
73  * already present on the command stream.
74  * @param bt_depth Depth of backtrace to be captured for this context
75  * representation.
76  */
77 struct debug_flush_ctx *
78 debug_flush_ctx_create(boolean catch_map_of_referenced, unsigned bt_depth);
79 
80 /**
81  * Destroy a context representation.
82  *
83  * @param fctx The context representation to destroy.
84  */
85 void
86 debug_flush_ctx_destroy(struct debug_flush_ctx *fctx);
87 
88 /**
89  * Map annotation
90  *
91  * @param fbuf The buffer representation to map.
92  * @param flags Pipebuffer flags for the map.
93  *
94  * Used to annotate a map of the buffer described by the buffer representation.
95  */
96 void debug_flush_map(struct debug_flush_buf *fbuf, unsigned flags);
97 
98 /**
99  * Unmap annotation
100  *
101  * @param fbuf The buffer representation to map.
102  *
103  * Used to annotate an unmap of the buffer described by the
104  * buffer representation.
105  */
106 void debug_flush_unmap(struct debug_flush_buf *fbuf);
107 
108 /**
109  * Might flush annotation
110  *
111  * @param fctx The context representation that might be flushed.
112  *
113  * Used to annotate a conditional (possible) flush of the given context.
114  */
115 void debug_flush_might_flush(struct debug_flush_ctx *fctx);
116 
117 /**
118  * Flush annotation
119  *
120  * @param fctx The context representation that is flushed.
121  *
122  * Used to annotate a real flush of the given context.
123  */
124 void debug_flush_flush(struct debug_flush_ctx *fctx);
125 
126 
127 /**
128  * Flush annotation
129  *
130  * @param fctx The context representation that is flushed.
131  *
132  * Used to annotate a real flush of the given context.
133  */
134 void debug_flush_cb_reference(struct debug_flush_ctx *fctx,
135                               struct debug_flush_buf *fbuf);
136 
137 #endif
138 #endif
139