Skip to content

Commit dc80a5f

Browse files
committed
Move some prints into trace mode
1 parent b335553 commit dc80a5f

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

platforms/CLI-Emulator/main.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,11 @@ struct Model {
399399
return;
400400

401401
z3::expr x_only_path_condition = em.x_only_path_condition(depth);
402-
std::cout << x_only_path_condition << std::endl;
402+
dbg_trace("x_only_path_condition = %s\n", x_only_path_condition.to_string().c_str());
403403
std::string sym_var_name = "x_" + std::to_string(depth);
404404
auto already_exists = std::find_if(
405405
subpaths.begin(), subpaths.end(), [x_only_path_condition, this, sym_var_name, depth](Model otherModel) {
406-
std::cout << "Compare with " << otherModel.x_only_path_condition(depth) << std::endl;
406+
dbg_trace("Compare with %s", otherModel.x_only_path_condition(depth).to_string().c_str());
407407
z3::solver s(m->ctx);
408408
s.add(z3::forall(m->ctx.bv_const(sym_var_name.c_str(), 32),
409409
otherModel.x_only_path_condition(depth) ==
@@ -412,14 +412,15 @@ struct Model {
412412
});
413413
// Doesn't exist!
414414
if (already_exists == subpaths.end()) {
415-
std::cout << sym_var_name << std::endl;
416-
std::cout << "New:" << std::endl;
417-
std::cout << em.values[sym_var_name].concrete_value.value.uint64 << std::endl;
418-
std::cout << "Existing:" << std::endl;
419-
for (Model otherModel : subpaths) {
420-
std::cout << otherModel.values[sym_var_name].concrete_value.value.uint64 << std::endl;
415+
#if TRACE
416+
dbg_trace("New branch value for %s, %llu\n", sym_var_name.c_str(), em.values[sym_var_name].concrete_value.value.uint64);
417+
if (!subpaths.empty()) {
418+
dbg_trace("Existing values:\n");
419+
for (Model otherModel : subpaths) {
420+
dbg_trace("- %llu\n", otherModel.values[sym_var_name].concrete_value.value.uint64);
421+
}
421422
}
422-
std::cout << "New subpath!" << std::endl;
423+
#endif
423424
em.add_partial_match(em, depth + 1);
424425
subpaths.push_back(em);
425426
}
@@ -561,14 +562,16 @@ void run_concolic(const std::vector<std::string>& snapshot_messages, int max_ins
561562
z3::solver s(m->ctx);
562563
s.add(m->path_condition && preconditions());
563564
auto result = s.check();
565+
if (result != z3::sat) {
566+
std::cout << m->path_condition.to_string() << std::endl;
567+
}
564568
assert(result == z3::sat);
565-
std::cout << "Iteration 0, fixing default values" << std::endl;
566-
std::cout << "Model:" << std::endl;
569+
dbg_trace("Iteration 0, fixing default values\n");
570+
dbg_trace("Model:\n");
567571
z3::model model = s.get_model();
568572
for (int i = 0; i < (int)model.size(); i++) {
569573
z3::func_decl func = model[i];
570-
std::cout << func.name() << " = "
571-
<< model.get_const_interp(func) << std::endl;
574+
dbg_trace("- %s = %s\n", func.name().str().c_str(), model.get_const_interp(func).to_string().c_str());
572575
m->symbolic_concrete_values[func.name().str()]
573576
.concrete_value.value.uint64 =
574577
model.get_const_interp(func).get_numeral_uint64();

src/Primitives/emulated.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,10 @@ void push_symbolic_int(Module *m, std::string primitive_origin, uint32_t arg) {
282282
m->symbolic_concrete_values.end()) {
283283
concrete_value = m->symbolic_concrete_values[var_name].concrete_value.value.int32;
284284

285-
std::cout << "Existing symbolic value " << var_name
286-
<< ", value = " << concrete_value << std::endl;
285+
dbg_trace("Existing symbolic value %s, value = %d\n", var_name.c_str(), concrete_value);
287286
}
288287
else {
289-
std::cout << "New symbolic value " << var_name
290-
<< ", start value = " << concrete_value << std::endl;
288+
dbg_trace("New symbolic value %s, start value = %d\n", var_name.c_str(), concrete_value);
291289
}
292290
pushInt32(concrete_value);
293291
m->symbolic_stack[m->sp] = m->ctx.bv_const(var_name.c_str(), 32);

0 commit comments

Comments
 (0)