trace: New pipe driver to trace incoming calls.
[mesa.git] / src / gallium / drivers / trace / tr_dump.h
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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 streams (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 TUNGSTEN GRAPHICS 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 * Trace data dumping primitives.
31 */
32
33 #ifndef TR_DUMP_H
34 #define TR_DUMP_H
35
36
37 struct trace_stream;
38
39
40 void trace_dump_trace_begin(struct trace_stream *stream, unsigned version);
41 void trace_dump_trace_end(struct trace_stream *stream);
42 void trace_dump_call_begin(struct trace_stream *stream, const char *klass, const char *method);
43 void trace_dump_call_end(struct trace_stream *stream);
44 void trace_dump_arg_begin(struct trace_stream *stream, const char *name);
45 void trace_dump_arg_end(struct trace_stream *stream);
46 void trace_dump_ret_begin(struct trace_stream *stream);
47 void trace_dump_ret_end(struct trace_stream *stream);
48 void trace_dump_bool(struct trace_stream *stream, int value);
49 void trace_dump_int(struct trace_stream *stream, long int value);
50 void trace_dump_uint(struct trace_stream *stream, long unsigned value);
51 void trace_dump_float(struct trace_stream *stream, double value);
52 void trace_dump_string(struct trace_stream *stream, const char *str);
53 void trace_dump_array_begin(struct trace_stream *stream);
54 void trace_dump_array_end(struct trace_stream *stream);
55 void trace_dump_elem_begin(struct trace_stream *stream);
56 void trace_dump_elem_end(struct trace_stream *stream);
57 void trace_dump_struct_begin(struct trace_stream *stream, const char *name);
58 void trace_dump_struct_end(struct trace_stream *stream);
59 void trace_dump_member_begin(struct trace_stream *stream, const char *name);
60 void trace_dump_member_end(struct trace_stream *stream);
61 void trace_dump_ptr(struct trace_stream *stream, const void *value);
62
63
64 /*
65 * Code saving macros.
66 */
67
68 #define trace_dump_arg(_stream, _type, _arg) \
69 do { \
70 trace_dump_arg_begin(_stream, #_arg); \
71 trace_dump_##_type(_stream, _arg); \
72 trace_dump_arg_end(_stream); \
73 } while(0)
74
75 #define trace_dump_ret(_stream, _type, _arg) \
76 do { \
77 trace_dump_ret_begin(_stream); \
78 trace_dump_##_type(_stream, _arg); \
79 trace_dump_ret_end(_stream); \
80 } while(0)
81
82 #define trace_dump_array(_stream, _type, _obj, _size) \
83 do { \
84 unsigned long idx; \
85 trace_dump_array_begin(_stream); \
86 for(idx = 0; idx < _size; ++idx) { \
87 trace_dump_elem_begin(_stream); \
88 trace_dump_##_type(_stream, _obj[idx]); \
89 trace_dump_elem_end(_stream); \
90 } \
91 trace_dump_array_end(_stream); \
92 } while(0)
93
94 #define trace_dump_member(_stream, _type, _obj, _member) \
95 do { \
96 trace_dump_member_begin(_stream, #_member); \
97 trace_dump_##_type(_stream, _obj->_member); \
98 trace_dump_member_end(_stream); \
99 } while(0)
100
101
102 #endif /* TR_DUMP_H */