mirror of
https://github.com/Z3Prover/z3
synced 2025-10-11 10:18:06 +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:
parent
d766292dab
commit
0a93ff515d
583 changed files with 8698 additions and 7299 deletions
|
@ -58,12 +58,12 @@ public:
|
|||
|
||||
|
||||
void run(nex *e) {
|
||||
TRACE("nla_cn", tout << *e << "\n";);
|
||||
TRACE(nla_cn, tout << *e << "\n";);
|
||||
SASSERT(m_nex_creator.is_simplified(*e));
|
||||
m_e = e;
|
||||
#ifdef Z3DEBUG
|
||||
m_e_clone = m_nex_creator.clone(m_e);
|
||||
TRACE("nla_cn", tout << "m_e_clone = " << * m_e_clone << "\n";);
|
||||
TRACE(nla_cn, tout << "m_e_clone = " << * m_e_clone << "\n";);
|
||||
|
||||
#endif
|
||||
vector<nex**> front;
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
static nex** pop_front(vector<nex**>& front) {
|
||||
nex** c = front.back();
|
||||
TRACE("nla_cn", tout << **c << "\n";);
|
||||
TRACE(nla_cn, tout << **c << "\n";);
|
||||
front.pop_back();
|
||||
return c;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
|
||||
nex* extract_common_factor(nex* e) {
|
||||
nex_sum* c = to_sum(e);
|
||||
TRACE("nla_cn", tout << "c=" << *c << "\n"; tout << "occs:"; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
|
||||
TRACE(nla_cn, tout << "c=" << *c << "\n"; tout << "occs:"; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
|
||||
unsigned size = c->size();
|
||||
bool have_factor = false;
|
||||
for (const auto & p : m_nex_creator.occurences_map()) {
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
}
|
||||
|
||||
static bool has_common_factor(const nex_sum* c) {
|
||||
TRACE("nla_cn", tout << "c=" << *c << "\n";);
|
||||
TRACE(nla_cn, tout << "c=" << *c << "\n";);
|
||||
auto & ch = *c;
|
||||
auto common_vars = get_vars_of_expr(ch[0]);
|
||||
for (lpvar j : common_vars) {
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
divides_the_rest = false;
|
||||
}
|
||||
if (divides_the_rest) {
|
||||
TRACE("nla_cn_common_factor", tout << c << "\n";);
|
||||
TRACE(nla_cn_common_factor, tout << c << "\n";);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -118,26 +118,26 @@ public:
|
|||
}
|
||||
|
||||
bool proceed_with_common_factor(nex** c, vector<nex**>& front) {
|
||||
TRACE("nla_cn", tout << "c=" << **c << "\n";);
|
||||
TRACE(nla_cn, tout << "c=" << **c << "\n";);
|
||||
nex* f = extract_common_factor(*c);
|
||||
if (f == nullptr) {
|
||||
TRACE("nla_cn", tout << "no common factor\n"; );
|
||||
TRACE(nla_cn, tout << "no common factor\n"; );
|
||||
return false;
|
||||
}
|
||||
TRACE("nla_cn", tout << "common factor f=" << *f << "\n";);
|
||||
TRACE(nla_cn, tout << "common factor f=" << *f << "\n";);
|
||||
|
||||
nex* c_over_f = m_nex_creator.mk_div(**c, *f);
|
||||
c_over_f = m_nex_creator.simplify(c_over_f);
|
||||
TRACE("nla_cn", tout << "c_over_f = " << *c_over_f << std::endl;);
|
||||
TRACE(nla_cn, tout << "c_over_f = " << *c_over_f << std::endl;);
|
||||
nex_mul* cm;
|
||||
*c = cm = m_nex_creator.mk_mul(f, c_over_f);
|
||||
TRACE("nla_cn", tout << "common factor=" << *f << ", c=" << **c << "\ne = " << *m_e << "\n";);
|
||||
TRACE(nla_cn, tout << "common factor=" << *f << ", c=" << **c << "\ne = " << *m_e << "\n";);
|
||||
explore_expr_on_front_elem((*cm)[1].ee(), front);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void push_to_front(vector<nex**>& front, nex** e) {
|
||||
TRACE("nla_cn", tout << **e << "\n";);
|
||||
TRACE(nla_cn, tout << **e << "\n";);
|
||||
front.push_back(e);
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ public:
|
|||
}
|
||||
|
||||
void explore_expr_on_front_elem_vars(nex** c, vector<nex**>& front, const svector<lpvar> & vars) {
|
||||
TRACE("nla_cn", tout << "save c=" << **c << "; front:"; print_front(front, tout) << "\n";);
|
||||
TRACE(nla_cn, tout << "save c=" << **c << "; front:"; print_front(front, tout) << "\n";);
|
||||
nex* copy_of_c = *c;
|
||||
auto copy_of_front = copy_front(front);
|
||||
int alloc_size = m_nex_creator.size();
|
||||
|
@ -173,11 +173,11 @@ public:
|
|||
explore_of_expr_on_sum_and_var(c, j, front);
|
||||
if (m_done)
|
||||
return;
|
||||
TRACE("nla_cn", tout << "before restore c=" << **c << "\nm_e=" << *m_e << "\n";);
|
||||
TRACE(nla_cn, tout << "before restore c=" << **c << "\nm_e=" << *m_e << "\n";);
|
||||
*c = copy_of_c;
|
||||
restore_front(copy_of_front, front);
|
||||
pop_allocated(alloc_size);
|
||||
TRACE("nla_cn", tout << "after restore c=" << **c << "\nm_e=" << *m_e << "\n";);
|
||||
TRACE(nla_cn, tout << "after restore c=" << **c << "\nm_e=" << *m_e << "\n";);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ public:
|
|||
}
|
||||
}
|
||||
remove_singular_occurences();
|
||||
TRACE("nla_cn_details", tout << "e=" << *e << "\noccs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
|
||||
TRACE(nla_cn_details, tout << "e=" << *e << "\noccs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
|
||||
}
|
||||
|
||||
void fill_vars_from_occurences_map(svector<lpvar>& vars) {
|
||||
|
@ -210,7 +210,7 @@ public:
|
|||
vars.push_back(p.first);
|
||||
|
||||
m_random_bit = m_random() % 2;
|
||||
TRACE("nla_cn", tout << "m_random_bit = " << m_random_bit << "\n";);
|
||||
TRACE(nla_cn, tout << "m_random_bit = " << m_random_bit << "\n";);
|
||||
std::sort(vars.begin(), vars.end(), [this](lpvar j, lpvar k)
|
||||
{
|
||||
auto it_j = m_nex_creator.occurences_map().find(j);
|
||||
|
@ -247,15 +247,15 @@ public:
|
|||
if (proceed_with_common_factor_or_get_vars_to_factor_out(c, vars, front))
|
||||
return;
|
||||
|
||||
TRACE("nla_cn", tout << "m_e=" << *m_e << "\nc=" << **c << ", c vars=";
|
||||
TRACE(nla_cn, tout << "m_e=" << *m_e << "\nc=" << **c << ", c vars=";
|
||||
print_vector(vars, tout) << "; front:"; print_front(front, tout) << "\n";);
|
||||
|
||||
if (vars.empty()) {
|
||||
if (front.empty()) {
|
||||
TRACE("nla_cn", tout << "got the cn form: =" << *m_e << "\n";);
|
||||
TRACE(nla_cn, tout << "got the cn form: =" << *m_e << "\n";);
|
||||
m_done = m_call_on_result(m_e) || ++m_reported > 100;
|
||||
#ifdef Z3DEBUG
|
||||
TRACE("nla_cn", tout << "m_e_clone " << *m_e_clone << "\n";);
|
||||
TRACE(nla_cn, tout << "m_e_clone " << *m_e_clone << "\n";);
|
||||
SASSERT(nex_creator::equal(m_e, m_e_clone));
|
||||
#endif
|
||||
} else {
|
||||
|
@ -276,13 +276,13 @@ public:
|
|||
// c is the sub expressiond which is going to be changed from sum to the cross nested form
|
||||
// front will be explored more
|
||||
void explore_of_expr_on_sum_and_var(nex** c, lpvar j, vector<nex**> front) {
|
||||
TRACE("nla_cn", tout << "m_e=" << *m_e << "\nc=" << **c << "\nj = " << nex_creator::ch(j) << "\nfront="; print_front(front, tout) << "\n";);
|
||||
TRACE(nla_cn, tout << "m_e=" << *m_e << "\nc=" << **c << "\nj = " << nex_creator::ch(j) << "\nfront="; print_front(front, tout) << "\n";);
|
||||
if (!split_with_var(*c, j, front))
|
||||
return;
|
||||
TRACE("nla_cn", tout << "after split c=" << **c << "\nfront="; print_front(front, tout) << "\n";);
|
||||
TRACE(nla_cn, tout << "after split c=" << **c << "\nfront="; print_front(front, tout) << "\n";);
|
||||
if (front.empty()) {
|
||||
#ifdef Z3DEBUG
|
||||
TRACE("nla_cn", tout << "got the cn form: =" << *m_e << ", clone = " << *m_e_clone << "\n";);
|
||||
TRACE(nla_cn, tout << "got the cn form: =" << *m_e << ", clone = " << *m_e_clone << "\n";);
|
||||
#endif
|
||||
m_done = m_call_on_result(m_e) || ++m_reported > 100;
|
||||
#ifdef Z3DEBUG
|
||||
|
@ -316,7 +316,7 @@ public:
|
|||
it->second.m_power = std::min(it->second.m_power, jp);
|
||||
}
|
||||
}
|
||||
TRACE("nla_cn_details", tout << "occs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
|
||||
TRACE(nla_cn_details, tout << "occs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
|
||||
}
|
||||
|
||||
void remove_singular_occurences() {
|
||||
|
@ -348,7 +348,7 @@ public:
|
|||
}
|
||||
}
|
||||
remove_singular_occurences();
|
||||
TRACE("nla_cn_details", tout << "e=" << *e << "\noccs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
|
||||
TRACE(nla_cn_details, tout << "e=" << *e << "\noccs="; dump_occurences(tout, m_nex_creator.occurences_map()) << "\n";);
|
||||
vector<std::pair<lpvar, occ>> ret;
|
||||
for (auto & p : m_nex_creator.occurences_map())
|
||||
ret.push_back(p);
|
||||
|
@ -373,12 +373,12 @@ public:
|
|||
}
|
||||
// all factors of j go to a, the rest to b
|
||||
void pre_split(nex_sum * e, lpvar j, nex_sum const*& a, nex const*& b) {
|
||||
TRACE("nla_cn_details", tout << "e = " << * e << ", j = " << m_nex_creator.ch(j) << std::endl;);
|
||||
TRACE(nla_cn_details, tout << "e = " << * e << ", j = " << m_nex_creator.ch(j) << std::endl;);
|
||||
SASSERT(m_nex_creator.is_simplified(*e));
|
||||
nex_creator::sum_factory sf(m_nex_creator);
|
||||
m_b_split_vec.clear();
|
||||
for (nex const* ce: *e) {
|
||||
TRACE("nla_cn_details", tout << "ce = " << *ce << "\n";);
|
||||
TRACE(nla_cn_details, tout << "ce = " << *ce << "\n";);
|
||||
if (is_divisible_by_var(ce, j)) {
|
||||
sf += m_nex_creator.mk_div(*ce , j);
|
||||
} else {
|
||||
|
@ -386,22 +386,22 @@ public:
|
|||
}
|
||||
}
|
||||
a = sf.mk();
|
||||
TRACE("nla_cn_details", tout << "a = " << *a << "\n";);
|
||||
TRACE(nla_cn_details, tout << "a = " << *a << "\n";);
|
||||
SASSERT(a->size() >= 2 && m_b_split_vec.size());
|
||||
a = to_sum(m_nex_creator.simplify_sum(const_cast<nex_sum*>(a)));
|
||||
|
||||
if (m_b_split_vec.size() == 1) {
|
||||
b = m_b_split_vec[0];
|
||||
TRACE("nla_cn_details", tout << "b = " << *b << "\n";);
|
||||
TRACE(nla_cn_details, tout << "b = " << *b << "\n";);
|
||||
} else {
|
||||
SASSERT(m_b_split_vec.size() > 1);
|
||||
b = m_nex_creator.mk_sum(m_b_split_vec);
|
||||
TRACE("nla_cn_details", tout << "b = " << *b << "\n";);
|
||||
TRACE(nla_cn_details, tout << "b = " << *b << "\n";);
|
||||
}
|
||||
}
|
||||
|
||||
void update_front_with_split_with_non_empty_b(nex* &e, lpvar j, vector<nex**> & front, nex_sum const* a, nex const* b) {
|
||||
TRACE("nla_cn_details", tout << "b = " << *b << "\n";);
|
||||
TRACE(nla_cn_details, tout << "b = " << *b << "\n";);
|
||||
e = m_nex_creator.mk_sum(m_nex_creator.mk_mul(m_nex_creator.mk_var(j), a), b); // e = j*a + b
|
||||
if (!a->is_linear()) {
|
||||
nex **ptr_to_a = e->to_sum()[0]->to_mul()[1].ee();
|
||||
|
@ -426,7 +426,7 @@ public:
|
|||
// it returns true if the recursion brings a cross-nested form
|
||||
bool split_with_var(nex*& e, lpvar j, vector<nex**> & front) {
|
||||
SASSERT(e->is_sum());
|
||||
TRACE("nla_cn", tout << "e = " << *e << ", j=" << nex_creator::ch(j) << "\n";);
|
||||
TRACE(nla_cn, tout << "e = " << *e << ", j=" << nex_creator::ch(j) << "\n";);
|
||||
nex_sum const* a; nex const* b;
|
||||
pre_split(to_sum(e), j, a, b);
|
||||
/*
|
||||
|
@ -458,7 +458,7 @@ public:
|
|||
}
|
||||
|
||||
nex * normalize_mul(nex_mul* a) {
|
||||
TRACE("nla_cn", tout << *a << "\n";);
|
||||
TRACE(nla_cn, tout << *a << "\n";);
|
||||
NOT_IMPLEMENTED_YET();
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue