3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-11-11 08:32:03 +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

@ -344,7 +344,7 @@ namespace datalog {
if (!is_predicate(decl)) {
m_pinned.push_back(decl);
m_preds.insert(decl);
TRACE("dl", tout << mk_pp(decl, m) << "\n";);
TRACE(dl, tout << mk_pp(decl, m) << "\n";);
if (named) {
m_preds_by_name.insert(decl->get_name(), decl);
}
@ -354,7 +354,7 @@ namespace datalog {
void context::restrict_predicates(func_decl_set const& preds) {
m_preds.reset();
for (func_decl* p : preds) {
TRACE("dl", tout << mk_pp(p, m) << "\n";);
TRACE(dl, tout << mk_pp(p, m) << "\n";);
m_preds.insert(p);
}
}
@ -569,7 +569,7 @@ namespace datalog {
void context::check_rules(rule_set& r) {
m_rule_properties.set_generate_proof(generate_proof_trace());
TRACE("dl", m_rule_set.display(tout););
TRACE(dl, m_rule_set.display(tout););
switch(get_engine()) {
case DATALOG_ENGINE:
m_rule_properties.collect(r);
@ -715,13 +715,13 @@ namespace datalog {
void context::transform_rules(rule_transformer& transf) {
SASSERT(m_closed); //we must finish adding rules before we start transforming them
TRACE("dl", display_rules(tout););
TRACE(dl, display_rules(tout););
if (transf(m_rule_set)) {
//we have already ensured the negation is stratified and transformations
//should not break the stratification
m_rule_set.ensure_closed();
TRACE("dl", display_rules(tout););
TRACE("dl_verbose", display(tout););
TRACE(dl, display_rules(tout););
TRACE(dl_verbose, display(tout););
}
}
@ -759,7 +759,7 @@ namespace datalog {
}
void context::assert_expr(expr* e) {
TRACE("dl", tout << mk_ismt2_pp(e, m) << "\n";);
TRACE(dl, tout << mk_ismt2_pp(e, m) << "\n";);
m_background.push_back(e);
}
@ -808,7 +808,7 @@ namespace datalog {
};
void context::configure_engine(expr* q) {
TRACE("dl", tout << mk_pp(q, m) << " " << m_engine_type << "\n";);
TRACE(dl, tout << mk_pp(q, m) << " " << m_engine_type << "\n";);
if (m_engine_type != LAST_ENGINE) {
return;
}
@ -987,7 +987,7 @@ namespace datalog {
const symbol& rule_name = r->name();
names.push_back (rule_name);
TRACE ("dl",
TRACE(dl,
if (rule_name == symbol::null) {
tout << "Encountered unnamed rule: ";
r->display(*this, tout);

View file

@ -188,7 +188,7 @@ namespace datalog {
m_neg.reset();
unsigned index = extract_horn(fml, m_body, m_head);
hoist_compound_predicates(index, m_head, m_body);
TRACE("dl_rule",
TRACE(dl_rule,
tout << mk_pp(m_head, m) << " :- ";
for (expr* b : m_body)
tout << mk_pp(b, m) << " ";
@ -260,7 +260,7 @@ namespace datalog {
func_decl* rule_manager::mk_query(expr* query, rule_set& rules) {
TRACE("dl", tout << mk_pp(query, m) << "\n";);
TRACE(dl, tout << mk_pp(query, m) << "\n";);
ptr_vector<sort> vars;
svector<symbol> names;
@ -339,7 +339,7 @@ namespace datalog {
if (!vars.empty()) {
rule_expr = m.mk_forall(vars.size(), vars.data(), names.data(), impl);
}
TRACE("dl", tout << rule_expr << "\n";);
TRACE(dl, tout << rule_expr << "\n";);
scoped_proof_mode _sc(m, m_ctx.generate_proof_trace()?PGM_ENABLED:PGM_DISABLED);
proof_ref pr(m);
@ -399,7 +399,7 @@ namespace datalog {
}
}
fml = m.mk_app(fml->get_decl(), m_args.size(), m_args.data());
TRACE("dl_rule", tout << mk_pp(fml.get(), m) << "\n";);
TRACE(dl_rule, tout << mk_pp(fml.get(), m) << "\n";);
}
class contains_predicate_proc {
@ -636,7 +636,7 @@ namespace datalog {
}
tail_neg.resize(tail.size(), false);
r = mk(r->get_head(), tail.size(), tail.data(), tail_neg.data(), r->name());
TRACE("dl", r->display(m_ctx, tout << "reduced rule\n"););
TRACE(dl, r->display(m_ctx, tout << "reduced rule\n"););
}
}
@ -745,7 +745,7 @@ namespace datalog {
quant_tail = m.mk_exists(q_var_cnt, qsorts.data(), qnames.data(), unbound_tail_pre_quant);
if (try_quantifier_elimination) {
TRACE("dl_rule_unbound_fix_pre_qe",
TRACE(dl_rule_unbound_fix_pre_qe,
tout<<"rule: ";
r->display(m_ctx, tout);
tout<<"tail with unbound vars: "<<mk_pp(unbound_tail, m)<<"\n";
@ -760,7 +760,7 @@ namespace datalog {
fixed_tail = quant_tail;
}
TRACE("dl_rule_unbound_fix",
TRACE(dl_rule_unbound_fix,
tout<<"rule: ";
r->display(m_ctx, tout);
tout<<"tail with unbound vars: "<<mk_pp(unbound_tail, m)<<"\n";

View file

@ -95,7 +95,7 @@ namespace datalog {
}
void rule_dependencies::populate(rule const* r) {
TRACE("dl_verbose", tout << r->get_decl()->get_name() << "\n";);
TRACE(dl_verbose, tout << r->get_decl()->get_name() << "\n";);
m_visited.reset();
func_decl * d = r->get_decl();
func_decl_set & s = ensure_key(d);
@ -316,7 +316,7 @@ namespace datalog {
}
void rule_set::add_rule(rule * r) {
TRACE("dl_verbose", r->display(m_context, tout << "add:"););
TRACE(dl_verbose, r->display(m_context, tout << "add:"););
SASSERT(!is_closed());
m_rules.push_back(r);
app * head = r->get_head();
@ -328,7 +328,7 @@ namespace datalog {
}
void rule_set::del_rule(rule * r) {
TRACE("dl", r->display(m_context, tout << "del:"););
TRACE(dl, r->display(m_context, tout << "del:"););
func_decl* d = r->get_decl();
rule_vector* rules = m_head2rules.find(d);
#define DEL_VECTOR(_v) \
@ -346,7 +346,7 @@ namespace datalog {
}
void rule_set::replace_rule(rule * r, rule * other) {
TRACE("dl", r->display(m_context, tout << "replace:"););
TRACE(dl, r->display(m_context, tout << "replace:"););
func_decl* d = r->get_decl();
rule_vector* rules = m_head2rules.find(d);
#define REPLACE_VECTOR(_v) \

View file

@ -71,7 +71,7 @@ namespace datalog {
bool modified = false;
TRACE("dl_rule_transf",
TRACE(dl_rule_transf,
tout<<"init:\n";
rules.display(tout);
);
@ -107,7 +107,7 @@ namespace datalog {
new_rules->ensure_closed();
IF_VERBOSE(1, verbose_stream() << new_rules->get_num_rules() << " rules " << sec << "s)\n";);
TRACE("dl_rule_transf",
TRACE(dl_rule_transf,
tout << typeid(p).name()<<":\n";
new_rules->display(tout);
);

View file

@ -285,7 +285,7 @@ namespace datalog {
if (mc) {
ast_manager& m = mc->get_manager();
expr_ref_vector body(m);
TRACE("dl", tout << "unreachable: " << unreachable << " " << r.get_decl()->get_name() << "\n");
TRACE(dl, tout << "unreachable: " << unreachable << " " << r.get_decl()->get_name() << "\n");
switch (unreachable) {
case l_true:
body.push_back(m.mk_true());
@ -304,7 +304,7 @@ namespace datalog {
}
break;
}
TRACE("dl",
TRACE(dl,
tout << mk_pp(r.get_head(), m) << " :- \n";
for (unsigned i = 0; i < body.size(); ++i) {
tout << mk_pp(body.get(i), m) << "\n";
@ -336,7 +336,7 @@ namespace datalog {
premises.push_back(m.mk_asserted(fml2));
positions.push_back(std::make_pair(idx+1, 0));
TRACE("dl",
TRACE(dl,
tout << premises[0]->get_id() << " " << mk_pp(premises[0].get(), m) << "\n";
for (unsigned i = 0; i < s1.size(); ++i) {
tout << mk_pp(s1[i], m) << " ";
@ -374,7 +374,7 @@ namespace datalog {
premises.push_back(r2.get_proof());
positions.push_back(std::make_pair(idx+1, 0));
TRACE("dl",
TRACE(dl,
tout << premises[0]->get_id() << " " << mk_pp(premises[0].get(), m) << "\n";
for (unsigned i = 0; i < s1.size(); ++i) {
tout << mk_pp(s1[i], m) << " ";

View file

@ -163,7 +163,7 @@ public:
ps.push_back(pr);
}
}
TRACE("hnf",
TRACE(hnf,
tout << mk_pp(n, m) << "\n==>\n" << result << "\n";);
}
@ -334,7 +334,7 @@ private:
if (!contains_predicate(b)) {
return;
}
TRACE("hnf", tout << mk_pp(b, m) << "\n";);
TRACE(hnf, tout << mk_pp(b, m) << "\n";);
if (m.is_or(b)) {
is_disj = true;
negate_args = false;
@ -522,7 +522,7 @@ hnf::~hnf() {
void hnf::operator()(expr * n, proof* p, expr_ref_vector & rs, proof_ref_vector& ps) {
m_imp->operator()(n, p, rs, ps);
TRACE("hnf",
TRACE(hnf,
ast_manager& m = rs.get_manager();
tout << mk_ismt2_pp(n, m) << "\nHNF result:\n";
for (unsigned i = 0; i < rs.size(); ++i) {