2 * Written by Josh Dybnis and released to the public domain, as explained at
3 * http://creativecommons.org/licenses/publicdomain
11 #define TRACE(...) do { } while (0)
13 #define TRACE(flag, format, v1, v2) lwt_trace(flag, format, (size_t)(v1), (size_t)(v2))
16 // Dump trace records to <file_name>. The file should be post-processed with "sort" before viewing.
17 void lwt_dump (const char *file_name) __attribute__ ((externally_visible));
19 // <flags> indicates what kind of trace messages should be included in the dump. <flags> is a sequence of letters
20 // followed by numbers (e.g. "x1c9n2g3"). The letters indicate trace categories and the numbers are trace levels
21 // for each category. If a category appears in <flags>, then messages from that category will be included in the
22 // dump if they have a trace level less than or equal to the one specified in <flags>. Categories are case
24 void lwt_set_trace_level (const char *flags);
26 // <flag> is a two character string containing a letter followed by a number (e.g. "f3"). The letter indicates a
27 // trace category, and the number a trace level. <flag> controls whether or not the trace message gets included in
28 // the dump. It is only included when its specified category is enabled at a trace level greater than or equal to
29 // the one in <flag>. Categories are case sensitive.
30 static inline void lwt_trace (const char *flag, const char *format, size_t value1, size_t value2) {
31 extern char flag_state_[256];
32 if (EXPECT_FALSE(flag_state_[(unsigned)flag[0]] >= flag[1])) {
33 // embed <flags> in <format> so we don't have to make the lwt_record_t any bigger than it already is
34 format = (const char *)((size_t)format | ((uint64_t)flag[0] << 56) | ((uint64_t)flag[1] << 48));
35 extern void lwt_trace_i (const char *format, size_t value1, size_t value2);
36 lwt_trace_i(format, value1, value2);