Skip to content

Commit 012fc1b

Browse files
more detailed tracing of where unmaterialized exceptions happen
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent 7de0c29 commit 012fc1b

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

src/api/api_solver.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ extern "C" {
628628
Z3_CATCH_RETURN(nullptr);
629629
}
630630

631+
#define STRINGIFY(x) #x
632+
#define TOSTRING(x) STRINGIFY(x)
633+
631634
static Z3_lbool _solver_check(Z3_context c, Z3_solver s, unsigned num_assumptions, Z3_ast const assumptions[]) {
632635
for (unsigned i = 0; i < num_assumptions; i++) {
633636
if (!is_expr(to_ast(assumptions[i]))) {
@@ -662,15 +665,15 @@ extern "C" {
662665
}
663666
return Z3_L_UNDEF;
664667
}
665-
catch (...) {
666-
to_solver_ref(s)->set_reason_unknown(eh);
668+
catch (std::exception& ex) {
669+
to_solver_ref(s)->set_reason_unknown(eh, ex);
667670
to_solver(s)->set_eh(nullptr);
668671
return Z3_L_UNDEF;
669672
}
670673
}
671674
to_solver(s)->set_eh(nullptr);
672675
if (result == l_undef) {
673-
to_solver_ref(s)->set_reason_unknown(eh);
676+
to_solver_ref(s)->set_reason_unknown(eh, __FILE__ ":" TOSTRING(__LINE__));
674677
}
675678
return static_cast<Z3_lbool>(result);
676679
}
@@ -887,7 +890,7 @@ extern "C" {
887890
}
888891
to_solver(s)->set_eh(nullptr);
889892
if (result == l_undef) {
890-
to_solver_ref(s)->set_reason_unknown(eh);
893+
to_solver_ref(s)->set_reason_unknown(eh, __FILE__ ":" TOSTRING(__LINE__));
891894
}
892895
for (expr* e : _consequences) {
893896
to_ast_vector_ref(consequences).push_back(e);

src/cmd_context/cmd_context.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -1782,19 +1782,15 @@ void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions
17821782
try {
17831783
r = m_solver->check_sat(num_assumptions, assumptions);
17841784
if (r == l_undef && !m().inc()) {
1785-
m_solver->set_reason_unknown(eh);
1785+
m_solver->set_reason_unknown(eh, "canceled");
17861786
}
17871787
}
17881788
catch (z3_error & ex) {
1789+
m_solver->set_reason_unknown(eh, ex);
17891790
throw ex;
17901791
}
17911792
catch (z3_exception & ex) {
1792-
if (!m().inc()) {
1793-
m_solver->set_reason_unknown(eh);
1794-
}
1795-
else {
1796-
m_solver->set_reason_unknown(ex.what());
1797-
}
1793+
m_solver->set_reason_unknown(eh, ex);
17981794
r = l_undef;
17991795
}
18001796
m_solver->set_status(r);

src/solver/check_sat_result.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Module Name:
1818
--*/
1919
#include "solver/check_sat_result.h"
2020

21-
void check_sat_result::set_reason_unknown(event_handler& eh) {
21+
void check_sat_result::set_reason_unknown(event_handler& eh, char const* what) {
2222
switch (eh.caller_id()) {
2323
case UNSET_EH_CALLER:
2424
if (reason_unknown() == "")
25-
set_reason_unknown("unclassified exception");
25+
set_reason_unknown(what);
2626
break;
2727
case CTRL_C_EH_CALLER:
2828
set_reason_unknown("interrupted from keyboard");
@@ -46,7 +46,7 @@ void check_sat_result::set_reason_unknown(event_handler& eh, std::exception& ex)
4646
set_reason_unknown(ex.what());
4747
break;
4848
default:
49-
set_reason_unknown(eh);
49+
set_reason_unknown(eh, ex.what());
5050
break;
5151
}
5252
}

src/solver/check_sat_result.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class check_sat_result {
6868
virtual proof * get_proof_core() = 0;
6969
virtual std::string reason_unknown() const = 0;
7070
virtual void set_reason_unknown(char const* msg) = 0;
71-
void set_reason_unknown(event_handler& eh);
71+
void set_reason_unknown(event_handler& eh, char const* msg);
7272
void set_reason_unknown(event_handler& eh, std::exception& ex);
7373
virtual void get_labels(svector<symbol> & r) = 0;
7474
virtual ast_manager& get_manager() const = 0;

0 commit comments

Comments
 (0)