forked from urbit/vere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrace.h
187 lines (152 loc) · 4.14 KB
/
trace.h
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/// @file
#ifndef U3_TRACE_H
#define U3_TRACE_H
#include "c3/c3.h"
#include "options.h"
#include "types.h"
#ifdef U3_CPU_DEBUG
# include "options.h"
#endif
/** Data structures.
**/
/* u3t_trace: fast execution flags.
*/
typedef struct _u3t_trace {
c3_o noc_o; // now executing in nock interpreter
c3_o glu_o; // now executing in jet glue
c3_o mal_o; // now executing in allocator
c3_o far_o; // now executing in fragmentor
c3_o coy_o; // now executing in copy
c3_o euq_o; // now executing in equal
} u3t_trace;
/** Macros.
**/
# ifdef U3_CPU_DEBUG
# define u3t_on(var) \
(u3T.var = (u3C.wag_w & u3o_debug_cpu) \
? (c3n == u3T.var) ? c3y : (abort(), 0) \
: u3T.var)
# else
# define u3t_on(var)
#endif
# ifdef U3_CPU_DEBUG
# define u3t_off(var) \
(u3T.var = (u3C.wag_w & u3o_debug_cpu) \
? (c3y == u3T.var) ? c3n : (abort(), 0) \
: u3T.var)
# else
# define u3t_off(var)
#endif
/** Functions.
**/
/* u3t_init(): initialize tracing layer.
*/
void
u3t_init(void);
/// @return Number of entries written to the JSON trace file.
c3_w
u3t_trace_cnt(void);
/// @return Number of times u3t_trace_close() has been called.
c3_w
u3t_file_cnt(void);
/* u3t_push(): push on trace stack.
*/
void
u3t_push(u3_noun mon);
/* u3t_mean(): push `[%mean roc]` on trace stack.
*/
void
u3t_mean(u3_noun roc);
/* u3t_drop(): drop from meaning stack.
*/
void
u3t_drop(void);
/* u3t_slog(): print directly.
*/
void
u3t_slog(u3_noun hod);
/* u3t_heck(): profile point.
*/
void
u3t_heck(u3_atom cog);
/* u3t_samp(): sample.
*/
void
u3t_samp(void);
/* u3t_come(): push on profile stack; return yes if active push. RETAIN.
*/
c3_o
u3t_come(u3_noun bat);
/* u3t_flee(): pop off profile stack.
*/
void
u3t_flee(void);
/* u3t_trace_open(): opens the path for writing tracing information.
*/
void
u3t_trace_open(const c3_c *dir_c);
/* u3t_trace_close(): closes the trace file. optional.
*/
void
u3t_trace_close();
/* u3t_trace_time(): returns current time since system epoc,
* whatever it is per system, in microseconds.
*/
c3_d
u3t_trace_time();
/* u3t_nock_trace_push(): pushes a frame onto the trace stack;
* return yes if active push.
*/
c3_o
u3t_nock_trace_push(u3_noun lab);
/* u3t_nock_trace_pop(): pop off trace stack.
*/
void
u3t_nock_trace_pop();
/* u3t_event_trace(): record a lifecycle event.
*/
void
u3t_event_trace(const c3_c* name, c3_c type);
/* u3t_damp(): print and clear profile data.
*/
void
u3t_damp(FILE* fil_u);
/* u3t_boff(): turn profile sampling off.
*/
void
u3t_boff(void);
/* u3t_boot(): turn sampling on.
*/
void
u3t_boot(void);
/* u3t_slog_cap(): slog a tank with a caption with
** a given priority c3_l (assumed 0-3).
*/
void
u3t_slog_cap(c3_l pri_l, u3_noun cap, u3_noun tan);
/* u3t_slog_trace(): given a c3_l priority pri and a raw stack tax
** flop the order into start-to-end, render, and slog each item
** until done.
*/
void
u3t_slog_trace(c3_l pri_l, u3_noun tax);
/* u3t_slog_nara(): slog only the deepest road's trace with
** c3_l priority pri
*/
void
u3t_slog_nara(c3_l pri_l);
/* u3t_slog_hela(): join all roads' traces together into one tax
** and pass it to slog_trace along with the given c3_l priority pri_l
*/
void
u3t_slog_hela(c3_l pri_l);
/* u3t_etch_meme(): report memory stats at call time
*/
u3_noun
u3t_etch_meme(c3_l mod_l);
/** Globals.
**/
/// Tracing profiler.
extern u3t_trace u3t_Trace;
# define u3T u3t_Trace
#endif /* ifndef U3_TRACE_H */