@@ -43,18 +43,30 @@ bool is_threaded() {
4343std::ofstream tout (" .z3-trace" );
4444
4545static bool g_enable_all_trace_tags = false ;
46- static str_hashtable* g_enabled_trace_tags = nullptr ;
4746
48- static str_hashtable& get_enabled_trace_tags () {
49- if (!g_enabled_trace_tags) {
50- g_enabled_trace_tags = alloc (str_hashtable);
51- }
52- return *g_enabled_trace_tags;
47+ static bool s_tag_enabled[] = {
48+ #define X (tag, tc, desc ) false ,
49+ #include " util/trace_tags.def"
50+ #undef X
51+ };
52+
53+
54+ bool tag_enabled (TraceTag tag) {
55+ return tag < TraceTag::Count && s_tag_enabled[static_cast <unsigned >(tag)];
56+ }
57+
58+ static void enable_tag (TraceTag tag) {
59+ if (tag < TraceTag::Count)
60+ s_tag_enabled[static_cast <unsigned >(tag)] = true ;
5361}
5462
63+ static void disable_tag (TraceTag tag) {
64+ if (tag < TraceTag::Count)
65+ s_tag_enabled[static_cast <unsigned >(tag)] = false ;
66+ }
67+
68+
5569void finalize_trace () {
56- dealloc (g_enabled_trace_tags);
57- g_enabled_trace_tags = nullptr ;
5870}
5971
6072static const TraceTag* get_tag_classes () {
@@ -88,21 +100,22 @@ static const TraceTag* get_tag_classes() {
88100}
89101
90102
103+
91104void enable_trace (const char * tag) {
92- get_enabled_trace_tags ().insert (tag);
93-
94105 TraceTag tag_str = find_trace_tag_by_string (tag);
95- if (tag_str == TraceTag::Count)
106+ if (tag_str == TraceTag::Count)
96107 return ;
97108
109+ enable_tag (tag_str);
110+
98111 auto tag_class = get_trace_tag_class (tag_str);
99112 if (tag_class != tag_str)
100113 return ; // Only enable the tag if it is a class tag.
101114 auto const & next_tag = get_tag_classes ();
102115
103116 auto t = next_tag[static_cast <unsigned >(tag_str)];
104117 while (t != tag_str) {
105- get_enabled_trace_tags (). insert ( tracetag_to_string (t) );
118+ enable_tag (t );
106119 t = next_tag[static_cast <unsigned >(t)];
107120 }
108121}
@@ -112,12 +125,12 @@ void enable_all_trace(bool flag) {
112125}
113126
114127void disable_trace (const char * tag) {
115- get_enabled_trace_tags ().erase (tag);
128+ TraceTag tag_str = find_trace_tag_by_string (tag);
129+ disable_tag (tag_str);
116130}
117131
118132bool is_trace_enabled (TraceTag tag) {
119- return g_enable_all_trace_tags ||
120- (g_enabled_trace_tags && get_enabled_trace_tags ().contains (tracetag_to_string (tag)));
133+ return g_enable_all_trace_tags || tag_enabled (tag);
121134}
122135
123136void close_trace () {
0 commit comments