3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-26 13:06:05 +00:00

Centralize and document TRACE tags using X-macros (#7657)

* Introduce X-macro-based trace tag definition
- Created trace_tags.def to centralize TRACE tag definitions
- Each tag includes a symbolic name and description
- Set up enum class TraceTag for type-safe usage in TRACE macros

* Add script to generate Markdown documentation from trace_tags.def
- Python script parses trace_tags.def and outputs trace_tags.md

* Refactor TRACE_NEW to prepend TraceTag and pass enum to is_trace_enabled

* trace: improve trace tag handling system with hierarchical tagging

- Introduce hierarchical tag-class structure: enabling a tag class activates all child tags
- Unify TRACE, STRACE, SCTRACE, and CTRACE under enum TraceTag
- Implement initial version of trace_tag.def using X(tag, tag_class, description)
  (class names and descriptions to be refined in a future update)

* trace: replace all string-based TRACE tags with enum TraceTag
- Migrated all TRACE, STRACE, SCTRACE, and CTRACE macros to use enum TraceTag values instead of raw string literals

* trace : add cstring header

* trace : Add Markdown documentation generation from trace_tags.def via mk_api_doc.py

* trace : rename macro parameter 'class' to 'tag_class' and remove Unicode comment in trace_tags.h.

* trace : Add TODO comment for future implementation of tag_class activation

* trace : Disable code related to tag_class until implementation is ready (#7663).
This commit is contained in:
LeeYoungJoon 2025-05-28 22:31:25 +09:00 committed by GitHub
parent d766292dab
commit 0a93ff515d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
583 changed files with 8698 additions and 7299 deletions

View file

@ -55,7 +55,7 @@ namespace smt {
watch_list::clause_iterator end = wl.end_clause();
for (; it != end; ++it) {
clause * cls = *it;
TRACE("watch_list", tout << "l: "; display_literal(tout, l); tout << "\n";
TRACE(watch_list, tout << "l: "; display_literal(tout, l); tout << "\n";
display_clause(tout, cls); tout << "\n";);
SASSERT(l == cls->get_literal(0) || l == cls->get_literal(1));
}
@ -92,7 +92,7 @@ namespace smt {
n->get_num_args() == 0 ||
(!is_true_eq && (!n->is_cgc_enabled() || n->is_cgr() == (m_cg_table.contains_ptr(n)))) ||
(is_true_eq && !m_cg_table.contains_ptr(n));
CTRACE("check_enode", !cg_inv,
CTRACE(check_enode, !cg_inv,
tout << "n: #" << n->get_expr_id() << ", m_cg: #" << n->m_cg->get_expr_id() << ", contains: " << m_cg_table.contains(n) << "\n"; display(tout););
SASSERT(cg_inv);
return true;
@ -116,7 +116,7 @@ namespace smt {
bool context::check_missing_clause_propagation(clause_vector const & v) const {
for (clause * cls : v) {
CTRACE("missing_propagation", is_unit_clause(cls), display_clause_detail(tout, cls); tout << "\n";);
CTRACE(missing_propagation, is_unit_clause(cls), display_clause_detail(tout, cls); tout << "\n";);
SASSERT(!is_unit_clause(cls));
}
return true;
@ -159,7 +159,7 @@ namespace smt {
if (n->get_root() != n2->get_root()) {
if (n->is_true_eq() && n2->is_true_eq())
continue;
CTRACE("missing_propagation", congruent(n, n2),
CTRACE(missing_propagation, congruent(n, n2),
tout << mk_pp(n->get_expr(), m) << "\n" << mk_pp(n2->get_expr(), m) << "\n";
display(tout););
SASSERT(!congruent(n, n2));
@ -174,7 +174,7 @@ namespace smt {
if (m.is_bool(n->get_expr()) && get_assignment(n) == l_undef) {
enode * first = n;
do {
CTRACE("missing_propagation", get_assignment(n) != l_undef,
CTRACE(missing_propagation, get_assignment(n) != l_undef,
tout << mk_pp(first->get_expr(), m) << "\nassignment: " << get_assignment(first) << "\n"
<< mk_pp(n->get_expr(), m) << "\nassignment: " << get_assignment(n) << "\n";);
SASSERT(get_assignment(n) == l_undef);
@ -209,17 +209,17 @@ namespace smt {
for (unsigned i = 0; i < sz; i++) {
expr * n = m_asserted_formulas.get_formula(i);
if (m.is_or(n)) {
CTRACE("relevancy_bug", !is_relevant(n), tout << "n: " << mk_ismt2_pp(n, m) << "\n";);
CTRACE(relevancy_bug, !is_relevant(n), tout << "n: " << mk_ismt2_pp(n, m) << "\n";);
SASSERT(is_relevant(n));
TRACE("check_relevancy", tout << "checking:\n" << mk_ll_pp(n, m) << "\n";);
TRACE(check_relevancy, tout << "checking:\n" << mk_ll_pp(n, m) << "\n";);
SASSERT(m_relevancy_propagator->check_relevancy_or(to_app(n), true));
}
else if (m.is_not(n)) {
CTRACE("relevancy_bug", !is_relevant(to_app(n)->get_arg(0)), tout << "n: " << mk_ismt2_pp(n, m) << "\n";);
CTRACE(relevancy_bug, !is_relevant(to_app(n)->get_arg(0)), tout << "n: " << mk_ismt2_pp(n, m) << "\n";);
SASSERT(is_relevant(to_app(n)->get_arg(0)));
}
else {
CTRACE("relevancy_bug", !is_relevant(n), tout << "n: " << mk_ismt2_pp(n, m) << "\n";);
CTRACE(relevancy_bug, !is_relevant(n), tout << "n: " << mk_ismt2_pp(n, m) << "\n";);
SASSERT(is_relevant(n));
}
}
@ -234,7 +234,7 @@ namespace smt {
for (enode* e : m_enodes) {
if (m.is_bool(e->get_expr())) {
enode * r = e->get_root();
CTRACE("eqc_bool", get_assignment(e) != get_assignment(r),
CTRACE(eqc_bool, get_assignment(e) != get_assignment(r),
tout << "#" << e->get_expr_id() << "\n" << mk_pp(e->get_expr(), m) << "\n";
tout << "#" << r->get_expr_id() << "\n" << mk_pp(r->get_expr(), m) << "\n";
tout << "assignments: " << get_assignment(e) << " " << get_assignment(r) << "\n";
@ -262,7 +262,7 @@ namespace smt {
(= get_enode(v1') get_enode(v2')) is congruent to (= lhs rhs).
*/
bool context::check_th_diseq_propagation() const {
TRACE("check_th_diseq_propagation", tout << "m_propagated_th_diseqs.size() " << m_propagated_th_diseqs.size() << "\n";);
TRACE(check_th_diseq_propagation, tout << "m_propagated_th_diseqs.size() " << m_propagated_th_diseqs.size() << "\n";);
unsigned num = get_num_bool_vars();
if (inconsistent() || get_manager().limit().is_canceled()) {
return true;
@ -271,20 +271,20 @@ namespace smt {
if (has_enode(v)) {
enode * n = bool_var2enode(v);
if (n->is_eq() && is_relevant(n) && get_assignment(v) == l_false && !m.is_iff(n->get_expr())) {
TRACE("check_th_diseq_propagation", tout << "checking: #" << n->get_expr_id() << " " << mk_bounded_pp(n->get_expr(), m) << "\n";);
TRACE(check_th_diseq_propagation, tout << "checking: #" << n->get_expr_id() << " " << mk_bounded_pp(n->get_expr(), m) << "\n";);
enode * lhs = n->get_arg(0)->get_root();
enode * rhs = n->get_arg(1)->get_root();
if (rhs->is_interpreted() && lhs->is_interpreted())
continue;
if (lhs == rhs)
continue;
TRACE("check_th_diseq_propagation", tout << "num. theory_vars: " << lhs->get_num_th_vars() << " "
TRACE(check_th_diseq_propagation, tout << "num. theory_vars: " << lhs->get_num_th_vars() << " "
<< mk_pp(lhs->get_expr()->get_sort(), m) << "\n";);
theory_var_list * l = lhs->get_th_var_list();
while (l) {
theory_id th_id = l->get_id();
theory * th = get_theory(th_id);
TRACE("check_th_diseq_propagation", tout << "checking theory: " << m.get_family_name(th_id) << "\n";);
TRACE(check_th_diseq_propagation, tout << "checking theory: " << m.get_family_name(th_id) << "\n";);
// if the theory doesn't use diseqs, then the diseqs are not propagated.
if (th->use_diseqs() && rhs->get_th_var(th_id) != null_theory_var) {
bool found = false;
@ -296,13 +296,13 @@ namespace smt {
if ((lhs == lhs_prime && rhs == rhs_prime) ||
(rhs == lhs_prime && lhs == rhs_prime)) {
TRACE("check_th_diseq_propagation", tout << "ok v" << v << " " << get_assignment(v) << "\n";);
TRACE(check_th_diseq_propagation, tout << "ok v" << v << " " << get_assignment(v) << "\n";);
found = true;
break;
}
}
}
CTRACE("check_th_diseq_propagation", !found,
CTRACE(check_th_diseq_propagation, !found,
tout
<< "checking theory: " << m.get_family_name(th_id) << "\n"
<< "root: #" << n->get_root()->get_expr_id() << " node: #" << n->get_expr_id() << "\n"
@ -324,7 +324,7 @@ namespace smt {
enode * n1 = p.first;
enode * n2 = p.second;
if (n1->get_root() == n2->get_root()) {
TRACE("diseq_bug",
TRACE(diseq_bug,
tout << "n1: #" << n1->get_expr_id() << ", n2: #" << n2->get_expr_id() <<
", r: #" << n1->get_root()->get_expr_id() << "\n";
tout << "n1 parents:\n"; display_parent_eqs(tout, n1);
@ -371,7 +371,7 @@ namespace smt {
case l_true:
if (!m_proto_model->eval(n, res, false))
return true;
CTRACE("model", !m.is_true(res), tout << n << " evaluates to " << res << "\n" << *m_proto_model << "\n";);
CTRACE(model, !m.is_true(res), tout << n << " evaluates to " << res << "\n" << *m_proto_model << "\n";);
if (m.is_false(res)) {
return false;
}
@ -379,7 +379,7 @@ namespace smt {
case l_false:
if (!m_proto_model->eval(n, res, false))
return true;
CTRACE("model", !m.is_false(res), tout << n << " evaluates to " << res << "\n" << *m_proto_model << "\n";);
CTRACE(model, !m.is_false(res), tout << n << " evaluates to " << res << "\n" << *m_proto_model << "\n";);
if (m.is_true(res)) {
return false;
}