3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-09 09:21:56 +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

@ -101,13 +101,13 @@ bool intervals::check_nex(const nex* n, u_dependency* initial_deps) {
}
scoped_dep_interval interv_wd(get_dep_intervals());
interval_of_expr<e_with_deps::with_deps>(n, 1, interv_wd, f);
TRACE("nla_intervals", display_separating_interval(tout, n, interv_wd, initial_deps););
TRACE(nla_intervals, display_separating_interval(tout, n, interv_wd, initial_deps););
m_dep_intervals.check_interval_for_conflict_on_zero(interv_wd, initial_deps, f);
return true;
}
void intervals::add_mul_of_degree_one_to_vector(const nex_mul* e, vector<std::pair<rational, lpvar>> &v) {
TRACE("nla_intervals_details", tout << *e << "\n";);
TRACE(nla_intervals_details, tout << *e << "\n";);
SASSERT(e->size() == 1);
SASSERT((*e)[0].pow() == 1);
const nex *ev = (*e)[0].e();
@ -116,7 +116,7 @@ void intervals::add_mul_of_degree_one_to_vector(const nex_mul* e, vector<std::pa
}
void intervals::add_linear_to_vector(const nex* e, vector<std::pair<rational, lpvar>> &v) {
TRACE("nla_intervals_details", tout << *e << "\n";);
TRACE(nla_intervals_details, tout << *e << "\n";);
switch (e->type()) {
case expr_type::MUL:
add_mul_of_degree_one_to_vector(to_mul(e), v);
@ -132,7 +132,7 @@ void intervals::add_linear_to_vector(const nex* e, vector<std::pair<rational, lp
// e = a * can_t + b
lp::lar_term intervals::expression_to_normalized_term(const nex_sum* e, rational& a, rational& b) {
TRACE("nla_intervals_details", tout << *e << "\n";);
TRACE(nla_intervals_details, tout << *e << "\n";);
lpvar smallest_j = 0;
vector<std::pair<rational, lpvar>> v;
b = rational(0);
@ -150,7 +150,7 @@ lp::lar_term intervals::expression_to_normalized_term(const nex_sum* e, rational
}
}
}
TRACE("nla_intervals_details", tout << "a_index = " << a_index << ", v="; print_vector(v, tout) << "\n";);
TRACE(nla_intervals_details, tout << "a_index = " << a_index << ", v="; print_vector(v, tout) << "\n";);
a = v[a_index].first;
lp::lar_term t;
@ -167,7 +167,7 @@ lp::lar_term intervals::expression_to_normalized_term(const nex_sum* e, rational
t.add_var(p.second);
}
}
TRACE("nla_intervals_details", tout << a << "* (";
TRACE(nla_intervals_details, tout << a << "* (";
lp::lar_solver::print_term_as_indices(t, tout) << ") + " << b << std::endl;);
SASSERT(t.is_normalized());
return t;
@ -244,7 +244,7 @@ std::ostream& intervals::display(std::ostream& out, const interval& i) const {
template <e_with_deps wd>
void intervals::set_var_interval(lpvar v, interval& b) {
TRACE("nla_intervals_details", m_core->print_var(v, tout) << "\n";);
TRACE(nla_intervals_details, m_core->print_var(v, tout) << "\n";);
u_dependency* dep = nullptr;
rational val;
bool is_strict;
@ -285,7 +285,7 @@ bool intervals::interval_from_term(const nex& e, scoped_dep_interval& i) {
}
i.get().m_upper_dep = i.get().m_lower_dep;
}
TRACE("nla_intervals", tout << "explain_by_equiv\n";);
TRACE(nla_intervals, tout << "explain_by_equiv\n";);
return true;
}
lpvar j = find_term_column(norm_t, a);
@ -298,7 +298,7 @@ bool intervals::interval_from_term(const nex& e, scoped_dep_interval& i) {
m_dep_intervals.add(b, bi);
m_dep_intervals.set<wd>(i, bi);
TRACE("nla_intervals",
TRACE(nla_intervals,
m_core->lra.print_column_info(j, tout) << "\n";
tout << "a=" << a << ", b=" << b << "\n";
tout << e << ", interval = "; display(tout, i););
@ -315,20 +315,20 @@ bool intervals::interval_of_sum_no_term(const nex_sum& e, scoped_dep_interval &
if (!interval_of_expr<wd>(e[0], 1, sdi, f))
return false;
for (unsigned k = 1; k < e.size(); k++) {
TRACE("nla_intervals_details", tout << "e[" << k << "]= " << *e[k] << "\n";);
TRACE(nla_intervals_details, tout << "e[" << k << "]= " << *e[k] << "\n";);
scoped_dep_interval b(get_dep_intervals());
if (!interval_of_expr<wd>(e[k], 1, b, f)) {
return false;
}
scoped_dep_interval c(get_dep_intervals());
TRACE("nla_intervals_details", tout << "sdi = "; display(tout, sdi) << "\nb = "; display(tout, b) << "\n";);
TRACE(nla_intervals_details, tout << "sdi = "; display(tout, sdi) << "\nb = "; display(tout, b) << "\n";);
m_dep_intervals.add<wd>(sdi, b, c);
m_dep_intervals.set<wd>(sdi, c);
TRACE("nla_intervals_details", tout << *e[k] << ", ";
TRACE(nla_intervals_details, tout << *e[k] << ", ";
display(tout, sdi); tout << "\n";);
}
TRACE("nla_intervals_details", tout << "e=" << e << "\n";
TRACE(nla_intervals_details, tout << "e=" << e << "\n";
tout << " interv = "; display(tout, sdi););
return true; // no conflict
}
@ -355,21 +355,21 @@ bool intervals::conflict_u_l(const interval& a, const interval& b) const {
template <e_with_deps wd, typename T>
bool intervals::interval_of_sum(const nex_sum& e, scoped_dep_interval& a, const std::function<void (const T&)>& f) {
TRACE("nla_intervals_details", tout << "e=" << e << "\n";);
TRACE(nla_intervals_details, tout << "e=" << e << "\n";);
if(! interval_of_sum_no_term<wd>(e, a, f)) {
return false;
}
TRACE("nla_intervals_details", tout << "a = "; display(tout, a););
TRACE(nla_intervals_details, tout << "a = "; display(tout, a););
if (e.is_a_linear_term()) {
SASSERT(e.is_sum() && e.size() > 1);
scoped_dep_interval i_from_term(get_dep_intervals());
if (interval_from_term<wd>(e, i_from_term)) {
scoped_dep_interval r(get_dep_intervals());
m_dep_intervals.intersect<wd>(a, i_from_term, r);
TRACE("nla_intervals_details", tout << "intersection="; display(tout, r) << "\n";);
TRACE(nla_intervals_details, tout << "intersection="; display(tout, r) << "\n";);
if (m_dep_intervals.is_empty(r)) {
TRACE("nla_intervals_details", tout << "empty\n";);
TRACE(nla_intervals_details, tout << "empty\n";);
if (wd == e_with_deps::with_deps) {
T expl;
if (conflict_u_l(a, i_from_term)) {
@ -395,7 +395,7 @@ bool intervals::interval_of_sum(const nex_sum& e, scoped_dep_interval& a, const
template <e_with_deps wd, typename T>
bool intervals::interval_of_mul(const nex_mul& e, scoped_dep_interval& a, const std::function<void (const T&)>& f) {
TRACE("nla_intervals_details", tout << "e = " << e << "\n";);
TRACE(nla_intervals_details, tout << "e = " << e << "\n";);
const nex* zero_interval_child = get_zero_interval_child(e);
if (zero_interval_child) {
bool r = interval_of_expr<wd>(zero_interval_child, 1, a, f);
@ -403,25 +403,25 @@ bool intervals::interval_of_mul(const nex_mul& e, scoped_dep_interval& a, const
(void)r;
if(wd == e_with_deps::with_deps)
set_zero_interval_deps_for_mult(a);
TRACE("nla_intervals_details", tout << "zero_interval_child = " << *zero_interval_child << std::endl << "a = "; display(tout, a); );
TRACE(nla_intervals_details, tout << "zero_interval_child = " << *zero_interval_child << std::endl << "a = "; display(tout, a); );
return true; // regural calculation: no conflict
}
m_dep_intervals.set_interval_for_scalar(a, e.coeff());
TRACE("nla_intervals_details", tout << "a = "; display(tout, a); );
TRACE(nla_intervals_details, tout << "a = "; display(tout, a); );
for (const auto& ep : e) {
scoped_dep_interval b(get_dep_intervals());
if (!interval_of_expr<wd>(ep.e(), ep.pow(), b, f))
return false;
TRACE("nla_intervals_details", tout << "ep = " << ep << ", "; display(tout, b); );
TRACE(nla_intervals_details, tout << "ep = " << ep << ", "; display(tout, b); );
scoped_dep_interval c(get_dep_intervals());
m_dep_intervals.mul<wd>(a, b, c);
TRACE("nla_intervals_details", tout << "a "; display(tout, a););
TRACE("nla_intervals_details", tout << "c "; display(tout, c););
TRACE(nla_intervals_details, tout << "a "; display(tout, a););
TRACE(nla_intervals_details, tout << "c "; display(tout, c););
m_dep_intervals.set<wd>(a, c);
TRACE("nla_intervals_details", tout << "part mult "; display(tout, a););
TRACE(nla_intervals_details, tout << "part mult "; display(tout, a););
}
TRACE("nla_intervals_details", tout << "e=" << e << "\n";
TRACE(nla_intervals_details, tout << "e=" << e << "\n";
tout << " return "; display(tout, a););
return true;
}
@ -465,7 +465,7 @@ bool intervals::interval_of_expr(const nex* e, unsigned p, scoped_dep_interval&
}
break;
default:
TRACE("nla_intervals_details", tout << e->type() << "\n";);
TRACE(nla_intervals_details, tout << e->type() << "\n";);
UNREACHABLE();
}
return true; // no conflict