3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-03 22:43:56 +00:00

Implement API to set exit action to exception (#7192)

* Implement API to set exit action to exception

* Turn on exit_action_to_throw_exception upon API context creation
This commit is contained in:
Steven Moy 2024-03-27 19:06:58 -07:00 committed by GitHub
parent c18a42cf5b
commit 111fcb9366
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 47 additions and 5 deletions

View file

@ -75,6 +75,37 @@ bool is_debug_enabled(const char * tag) {
return g_enabled_debug_tags->contains(tag);
}
atomic<exit_action> g_default_exit_action(exit_action::exit);
exit_action get_default_exit_action() {
return g_default_exit_action;
}
void set_default_exit_action(exit_action a) {
g_default_exit_action = a;
}
void invoke_exit_action(unsigned int code) {
exit_action a = get_default_exit_action();
switch (a) {
case exit_action::exit:
exit(code);
case exit_action::throw_exception:
switch (code) {
case ERR_INTERNAL_FATAL:
throw default_exception("internal fatal");
case ERR_UNREACHABLE:
throw default_exception("unreachable");
case ERR_NOT_IMPLEMENTED_YET:
throw default_exception("not implemented yet");
default:
throw default_exception("unknown");
}
default:
exit(code);
}
}
atomic<debug_action> g_default_debug_action(debug_action::ask);
debug_action get_default_debug_action() {