3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-27 08:28:44 +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

@ -30,7 +30,7 @@ void register_z3_replayer_cmds(z3_replayer & in);
void throw_invalid_reference() {
TRACE("z3_replayer", tout << "invalid argument reference\n";);
TRACE(z3_replayer, tout << "invalid argument reference\n";);
throw z3_replayer_exception("invalid argument reference");
}
@ -72,14 +72,14 @@ struct z3_replayer::imp {
void check_arg(unsigned pos, value_kind k) const {
if (pos >= m_args.size()) {
TRACE("z3_replayer", tout << pos << " too few arguments " << m_args.size() << " expecting " << kind2string(k) << "\n";);
TRACE(z3_replayer, tout << pos << " too few arguments " << m_args.size() << " expecting " << kind2string(k) << "\n";);
throw z3_replayer_exception("invalid argument reference");
}
if (m_args[pos].m_kind != k) {
std::stringstream strm;
strm << "expecting " << kind2string(k) << " at position "
<< pos << " but got " << kind2string(m_args[pos].m_kind);
TRACE("z3_replayer", tout << strm.str() << "\n";);
TRACE(z3_replayer, tout << strm.str() << "\n";);
throw z3_replayer_exception(std::move(strm).str());
}
}
@ -196,7 +196,7 @@ struct z3_replayer::imp {
throw z3_replayer_exception("invalid escaped character");
next();
}
TRACE("z3_replayer_escape", tout << "val: " << val << "\n";);
TRACE(z3_replayer_escape, tout << "val: " << val << "\n";);
m_string.push_back(static_cast<char>(val));
}
else if (c == delimiter) {
@ -300,7 +300,7 @@ struct z3_replayer::imp {
void read_ptr() {
if (!(('0' <= curr() && curr() <= '9') || ('A' <= curr() && curr() <= 'F') || ('a' <= curr() && curr() <= 'f'))) {
TRACE("invalid_ptr", tout << "curr: " << curr() << "\n";);
TRACE(invalid_ptr, tout << "curr: " << curr() << "\n";);
throw z3_replayer_exception("invalid ptr");
}
unsigned pos = 0;
@ -380,7 +380,7 @@ struct z3_replayer::imp {
}
}
else if (k == OBJECT) {
TRACE("z3_replayer_bug",
TRACE(z3_replayer_bug,
tout << "args: "; display_args(tout); tout << "\n";
tout << "push_back, sz: " << sz << ", m_obj_arrays.size(): " << m_obj_arrays.size() << "\n";
for (unsigned i = asz - sz; i < asz; i++) {
@ -427,13 +427,13 @@ struct z3_replayer::imp {
case 'R':
// reset
next();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "R\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "R\n";);
reset();
break;
case 'P': {
// push pointer
next(); skip_blank(); read_ptr();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "P " << m_ptr << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "P " << m_ptr << "\n";);
if (m_ptr == 0) {
m_args.push_back(nullptr);
}
@ -442,14 +442,14 @@ struct z3_replayer::imp {
if (!m_heap.find(m_ptr, obj))
throw z3_replayer_exception("invalid pointer");
m_args.push_back(value(obj));
TRACE("z3_replayer_bug", tout << "args after 'P':\n"; display_args(tout); tout << "\n";);
TRACE(z3_replayer_bug, tout << "args after 'P':\n"; display_args(tout); tout << "\n";);
}
break;
}
case 'S': {
// push string
next(); skip_blank(); read_string();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "S " << m_string.begin() << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "S " << m_string.begin() << "\n";);
symbol sym(m_string.begin()); // save string
m_args.push_back(value(STRING, sym.bare_str()));
break;
@ -457,20 +457,20 @@ struct z3_replayer::imp {
case 'N':
// push null symbol
next();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "N\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "N\n";);
m_args.push_back(value(SYMBOL, symbol::null));
break;
case '$': {
// push symbol
next(); skip_blank(); read_quoted_symbol();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "$ " << m_id << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "$ " << m_id << "\n";);
m_args.push_back(value(SYMBOL, m_id));
break;
}
case '#': {
// push numeral symbol
next(); skip_blank(); read_uint64();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "# " << m_uint64 << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "# " << m_uint64 << "\n";);
symbol sym(static_cast<unsigned>(m_uint64));
m_args.push_back(value(SYMBOL, sym));
break;
@ -478,25 +478,25 @@ struct z3_replayer::imp {
case 'I':
// push integer;
next(); skip_blank(); read_int64();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "I " << m_int64 << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "I " << m_int64 << "\n";);
m_args.push_back(value(INT64, m_int64));
break;
case 'U':
// push unsigned;
next(); skip_blank(); read_uint64();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "U " << m_uint64 << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "U " << m_uint64 << "\n";);
m_args.push_back(value(UINT64, m_uint64));
break;
case 'F':
// push float
next(); skip_blank(); read_float();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "F " << m_float << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "F " << m_float << "\n";);
m_args.push_back(value(FLOAT, m_float));
break;
case 'D':
// push double
next(); skip_blank(); read_double();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "D " << m_double << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "D " << m_double << "\n";);
m_args.push_back(value(DOUBLE, m_double));
break;
case 'p':
@ -505,7 +505,7 @@ struct z3_replayer::imp {
case 'i':
// push array
next(); skip_blank(); read_uint64();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "A " << m_uint64 << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "A " << m_uint64 << "\n";);
if (c == 'p')
push_array(static_cast<unsigned>(m_uint64), OBJECT);
else if (c == 's')
@ -518,12 +518,12 @@ struct z3_replayer::imp {
case 'C': {
// call procedure
next(); skip_blank(); read_uint64();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "C " << m_uint64 << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "C " << m_uint64 << "\n";);
unsigned idx = static_cast<unsigned>(m_uint64);
if (idx >= m_cmds.size())
throw z3_replayer_exception("invalid command");
try {
TRACE("z3_replayer_cmd", tout << idx << ":" << m_cmds_names[idx] << "\n";);
TRACE(z3_replayer_cmd, tout << idx << ":" << m_cmds_names[idx] << "\n";);
m_cmds[idx](m_owner);
}
catch (z3_error & ex) {
@ -541,7 +541,7 @@ struct z3_replayer::imp {
// save result
// = obj_id
next(); skip_blank(); read_ptr();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "= " << m_ptr << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "= " << m_ptr << "\n";);
m_heap.insert(m_ptr, m_result);
break;
case '*': {
@ -549,7 +549,7 @@ struct z3_replayer::imp {
// @ obj_id pos
next(); skip_blank(); read_ptr(); skip_blank(); read_uint64();
unsigned pos = static_cast<unsigned>(m_uint64);
TRACE("z3_replayer", tout << "[" << m_line << "] " << "* " << m_ptr << " " << pos << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "* " << m_ptr << " " << pos << "\n";);
check_arg(pos, OBJECT);
m_heap.insert(m_ptr, m_args[pos].m_obj);
break;
@ -564,19 +564,19 @@ struct z3_replayer::imp {
ptr_vector<void> & v = m_obj_arrays[aidx];
skip_blank(); read_uint64();
unsigned idx = static_cast<unsigned>(m_uint64);
TRACE("z3_replayer", tout << "[" << m_line << "] " << "@ " << m_ptr << " " << pos << " " << idx << "\n";);
TRACE("z3_replayer_bug", tout << "v[idx]: " << v[idx] << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "@ " << m_ptr << " " << pos << " " << idx << "\n";);
TRACE(z3_replayer_bug, tout << "v[idx]: " << v[idx] << "\n";);
m_heap.insert(m_ptr, v[idx]);
break;
}
case 'M':
// user message
next(); skip_blank(); read_string();
TRACE("z3_replayer", tout << "[" << m_line << "] " << "M " << m_string.begin() << "\n";);
TRACE(z3_replayer, tout << "[" << m_line << "] " << "M " << m_string.begin() << "\n";);
std::cout << m_string.begin() << "\n"; std::cout.flush();
break;
default:
TRACE("z3_replayer", tout << "unknown command " << c << "\n";);
TRACE(z3_replayer, tout << "unknown command " << c << "\n";);
throw z3_replayer_exception("unknown log command");
break;
}
@ -657,7 +657,7 @@ struct z3_replayer::imp {
check_arg(pos, OBJECT_ARRAY);
unsigned idx = static_cast<unsigned>(m_args[pos].m_uint);
ptr_vector<void> const & v = m_obj_arrays[idx];
TRACE("z3_replayer_bug", tout << "pos: " << pos << ", idx: " << idx << " size(): " << v.size() << "\n";
TRACE(z3_replayer_bug, tout << "pos: " << pos << ", idx: " << idx << " size(): " << v.size() << "\n";
for (unsigned i = 0; i < v.size(); i++) tout << v[i] << " "; tout << "\n";);
return v.data();
}