3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-22 08:17:37 +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

@ -39,7 +39,7 @@ namespace sls {
initialize();
TRACE("arith", ctx.display_all(tout));
TRACE(arith, ctx.display_all(tout));
a.m_config.max_moves = a.m_stats.m_steps + a.m_config.max_moves_base;
@ -72,7 +72,7 @@ namespace sls {
(void)bv;
(void)v;
TRACE("arith",
TRACE(arith,
if (bv != sat::null_bool_var) tout << "bool flip " << bv << "\n";
else if (v != null_arith_var) tout << "arith flip v" << v << "\n";
else tout << "no flip\n";
@ -124,7 +124,7 @@ namespace sls {
template<typename num_t>
void arith_clausal<num_t>::add_lookahead_on_unsat_vars() {
a.m_updates.reset();
TRACE("arith_verbose", tout << "unsat-vars ";
TRACE(arith_verbose, tout << "unsat-vars ";
for (auto v : ctx.unsat_vars())
if (a.get_ineq(v)) tout << mk_bounded_pp(ctx.atom(v), a.m) << " ";
tout << "\n";);
@ -267,7 +267,7 @@ namespace sls {
return;
a.m_last_delta = delta;
a.m_last_var = v;
TRACE("arith", tout << mt << " v" << v << " " << mk_bounded_pp(a.m_vars[v].m_expr, a.m)
TRACE(arith, tout << mt << " v" << v << " " << mk_bounded_pp(a.m_vars[v].m_expr, a.m)
<< " += " << delta << " score:" << m_best_score << "\n");
a.m_vars[v].set_step(a.m_stats.m_steps, a.m_stats.m_steps + 3 + ctx.rand(10), delta);
VERIFY(a.update_num(v, delta));
@ -278,7 +278,7 @@ namespace sls {
DEBUG_CODE(
for (sat::bool_var bv = 0; bv < ctx.num_bool_vars(); ++bv) {
if (a.get_ineq(bv) && a.get_ineq(bv)->is_true() != ctx.is_true(bv)) {
TRACE("arith", tout << "bv:" << bv << " " << *a.get_ineq(bv) << " " << (ctx.is_true(bv)?"T":"F") << "\n";
TRACE(arith, tout << "bv:" << bv << " " << *a.get_ineq(bv) << " " << (ctx.is_true(bv)?"T":"F") << "\n";
tout << "v" << v << " bool vars: " << a.m_vars[v].m_bool_vars_of << "\n";
tout << mk_bounded_pp(a.m_vars[v].m_expr, a.m) << "\n";
tout << mk_bounded_pp(ctx.atom(bv), a.m) << "\n";
@ -291,7 +291,7 @@ namespace sls {
template<typename num_t>
double arith_clausal<num_t>::get_score(var_t v, num_t const& delta) {
auto& vi = a.m_vars[v];
TRACE("arith", tout << "get-score v" << v << " += " << delta << "\n";);
TRACE(arith, tout << "get-score v" << v << " += " << delta << "\n";);
if (!a.update_num(v, delta))
return -1;
double score = 0;
@ -309,7 +309,7 @@ namespace sls {
++num_true;
}
CTRACE("arith_verbose", c.m_num_trues != num_true && (c.m_num_trues == 0 || num_true == 0),
CTRACE(arith_verbose, c.m_num_trues != num_true && (c.m_num_trues == 0 || num_true == 0),
tout << "clause: " << c
<< " v" << v << " += " << delta
<< " new-true lits: " << num_true
@ -326,7 +326,7 @@ namespace sls {
// verbose_stream() << num_clauses << " " << num_dup << "\n";
// revert the update
TRACE("arith", tout << "revert update v" << v << " -= " << delta << "\n";);
TRACE(arith, tout << "revert update v" << v << " -= " << delta << "\n";);
a.update_unchecked(v, vi.value() - delta);
return score;
}
@ -348,7 +348,7 @@ namespace sls {
#endif
IF_VERBOSE(2, verbose_stream() << "restart sls-arith " << a.m_config.restart_next << "\n");
TRACE("arith", tout << "restart\n";);
TRACE(arith, tout << "restart\n";);
// reset values of (arithmetical) variables at bounds.
for (auto& vi : a.m_vars) {
if (vi.m_lo && !vi.m_lo->is_strict && vi.m_lo->value > 0)
@ -369,7 +369,7 @@ namespace sls {
DEBUG_CODE(
for (sat::bool_var bv = 0; bv < ctx.num_bool_vars(); ++bv) {
if (a.get_ineq(bv) && a.get_ineq(bv)->is_true() != ctx.is_true(bv)) {
TRACE("arith", tout << "bv:" << bv << " " << *a.get_ineq(bv) << ctx.is_true(bv) << "\n";
TRACE(arith, tout << "bv:" << bv << " " << *a.get_ineq(bv) << ctx.is_true(bv) << "\n";
tout << mk_bounded_pp(ctx.atom(bv), a.m) << "\n";
ctx.display(tout););
}
@ -403,7 +403,7 @@ namespace sls {
template<typename num_t>
void arith_clausal<num_t>::enter_bool_mode() {
CTRACE("arith", !m_bool_mode, tout << "enter bool mode\n";);
CTRACE(arith, !m_bool_mode, tout << "enter bool mode\n";);
m_best_found_cost_bool = ctx.unsat().size();
if (!m_bool_mode)
m_no_improve_bool = 0;
@ -420,7 +420,7 @@ namespace sls {
template<typename num_t>
void arith_clausal<num_t>::enter_arith_mode() {
CTRACE("arith", m_bool_mode, tout << "enter arith mode\n";);
CTRACE(arith, m_bool_mode, tout << "enter arith mode\n";);
m_best_found_cost_arith = ctx.unsat().size();
if (m_bool_mode)
m_no_improve_arith = 0;